Let UNTRUSTED/UNDECIDED keys become INACTIVE
This commit is contained in:
parent
60cd307f73
commit
6cd9383e53
|
@ -191,11 +191,11 @@ public class AxolotlService {
|
|||
return axolotlStore.getIdentityKeyPair().getPublicKey();
|
||||
}
|
||||
|
||||
public Set<IdentityKey> getKeysWithTrust(SQLiteAxolotlStore.Trust trust) {
|
||||
public Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust) {
|
||||
return axolotlStore.getContactKeysWithTrust(account.getJid().toBareJid().toString(), trust);
|
||||
}
|
||||
|
||||
public Set<IdentityKey> getKeysWithTrust(SQLiteAxolotlStore.Trust trust, Contact contact) {
|
||||
public Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust, Contact contact) {
|
||||
return axolotlStore.getContactKeysWithTrust(contact.getJid().toBareJid().toString(), trust);
|
||||
}
|
||||
|
||||
|
@ -241,8 +241,8 @@ public class AxolotlService {
|
|||
}
|
||||
|
||||
private void setTrustOnSessions(final Jid jid, @NonNull final Set<Integer> deviceIds,
|
||||
final SQLiteAxolotlStore.Trust from,
|
||||
final SQLiteAxolotlStore.Trust to) {
|
||||
final XmppAxolotlSession.Trust from,
|
||||
final XmppAxolotlSession.Trust to) {
|
||||
for (Integer deviceId : deviceIds) {
|
||||
AxolotlAddress address = new AxolotlAddress(jid.toBareJid().toString(), deviceId);
|
||||
XmppAxolotlSession session = sessions.get(address);
|
||||
|
@ -267,11 +267,19 @@ public class AxolotlService {
|
|||
}
|
||||
Set<Integer> expiredDevices = new HashSet<>(axolotlStore.getSubDeviceSessions(jid.toBareJid().toString()));
|
||||
expiredDevices.removeAll(deviceIds);
|
||||
setTrustOnSessions(jid, expiredDevices, SQLiteAxolotlStore.Trust.TRUSTED,
|
||||
SQLiteAxolotlStore.Trust.INACTIVE);
|
||||
setTrustOnSessions(jid, expiredDevices, XmppAxolotlSession.Trust.TRUSTED,
|
||||
XmppAxolotlSession.Trust.INACTIVE_TRUSTED);
|
||||
setTrustOnSessions(jid, expiredDevices, XmppAxolotlSession.Trust.UNDECIDED,
|
||||
XmppAxolotlSession.Trust.INACTIVE_UNDECIDED);
|
||||
setTrustOnSessions(jid, expiredDevices, XmppAxolotlSession.Trust.UNTRUSTED,
|
||||
XmppAxolotlSession.Trust.INACTIVE_UNTRUSTED);
|
||||
Set<Integer> newDevices = new HashSet<>(deviceIds);
|
||||
setTrustOnSessions(jid, newDevices, SQLiteAxolotlStore.Trust.INACTIVE,
|
||||
SQLiteAxolotlStore.Trust.TRUSTED);
|
||||
setTrustOnSessions(jid, newDevices, XmppAxolotlSession.Trust.INACTIVE_TRUSTED,
|
||||
XmppAxolotlSession.Trust.TRUSTED);
|
||||
setTrustOnSessions(jid, newDevices, XmppAxolotlSession.Trust.INACTIVE_UNDECIDED,
|
||||
XmppAxolotlSession.Trust.UNDECIDED);
|
||||
setTrustOnSessions(jid, newDevices, XmppAxolotlSession.Trust.INACTIVE_UNTRUSTED,
|
||||
XmppAxolotlSession.Trust.UNTRUSTED);
|
||||
this.deviceIds.put(jid, deviceIds);
|
||||
mXmppConnectionService.keyStatusUpdated();
|
||||
publishOwnDeviceIdIfNeeded();
|
||||
|
@ -291,7 +299,7 @@ public class AxolotlService {
|
|||
}
|
||||
|
||||
public void purgeKey(IdentityKey identityKey) {
|
||||
axolotlStore.setFingerprintTrust(identityKey.getFingerprint().replaceAll("\\s", ""), SQLiteAxolotlStore.Trust.COMPROMISED);
|
||||
axolotlStore.setFingerprintTrust(identityKey.getFingerprint().replaceAll("\\s", ""), XmppAxolotlSession.Trust.COMPROMISED);
|
||||
}
|
||||
|
||||
public void publishOwnDeviceIdIfNeeded() {
|
||||
|
@ -419,11 +427,11 @@ public class AxolotlService {
|
|||
(deviceIds.containsKey(jid) && !deviceIds.get(jid).isEmpty());
|
||||
}
|
||||
|
||||
public SQLiteAxolotlStore.Trust getFingerprintTrust(String fingerprint) {
|
||||
public XmppAxolotlSession.Trust getFingerprintTrust(String fingerprint) {
|
||||
return axolotlStore.getFingerprintTrust(fingerprint);
|
||||
}
|
||||
|
||||
public void setFingerprintTrust(String fingerprint, SQLiteAxolotlStore.Trust trust) {
|
||||
public void setFingerprintTrust(String fingerprint, XmppAxolotlSession.Trust trust) {
|
||||
axolotlStore.setFingerprintTrust(fingerprint, trust);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ import org.whispersystems.libaxolotl.state.SessionRecord;
|
|||
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.libaxolotl.util.KeyHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
|
@ -51,64 +49,14 @@ public class SQLiteAxolotlStore implements AxolotlStore {
|
|||
private int localRegistrationId;
|
||||
private int currentPreKeyId = 0;
|
||||
|
||||
private final LruCache<String, Trust> trustCache =
|
||||
new LruCache<String, Trust>(NUM_TRUSTS_TO_CACHE) {
|
||||
private final LruCache<String, XmppAxolotlSession.Trust> trustCache =
|
||||
new LruCache<String, XmppAxolotlSession.Trust>(NUM_TRUSTS_TO_CACHE) {
|
||||
@Override
|
||||
protected Trust create(String fingerprint) {
|
||||
protected XmppAxolotlSession.Trust create(String fingerprint) {
|
||||
return mXmppConnectionService.databaseBackend.isIdentityKeyTrusted(account, fingerprint);
|
||||
}
|
||||
};
|
||||
|
||||
public enum Trust {
|
||||
UNDECIDED(0),
|
||||
TRUSTED(1),
|
||||
UNTRUSTED(2),
|
||||
COMPROMISED(3),
|
||||
INACTIVE(4);
|
||||
|
||||
private static final Map<Integer, Trust> trustsByValue = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (Trust trust : Trust.values()) {
|
||||
trustsByValue.put(trust.getCode(), trust);
|
||||
}
|
||||
}
|
||||
|
||||
private final int code;
|
||||
|
||||
Trust(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
switch (this) {
|
||||
case UNDECIDED:
|
||||
return "Trust undecided " + getCode();
|
||||
case TRUSTED:
|
||||
return "Trusted " + getCode();
|
||||
case COMPROMISED:
|
||||
return "Compromised " + getCode();
|
||||
case INACTIVE:
|
||||
return "Inactive " + getCode();
|
||||
case UNTRUSTED:
|
||||
default:
|
||||
return "Untrusted " + getCode();
|
||||
}
|
||||
}
|
||||
|
||||
public static Trust fromBoolean(Boolean trusted) {
|
||||
return trusted ? TRUSTED : UNTRUSTED;
|
||||
}
|
||||
|
||||
public static Trust fromCode(int code) {
|
||||
return trustsByValue.get(code);
|
||||
}
|
||||
}
|
||||
|
||||
private static IdentityKeyPair generateIdentityKeyPair() {
|
||||
Log.i(Config.LOGTAG, AxolotlService.LOGPREFIX + " : " + "Generating axolotl IdentityKeyPair...");
|
||||
ECKeyPair identityKeyPairKeys = Curve.generateKeyPair();
|
||||
|
@ -258,16 +206,16 @@ public class SQLiteAxolotlStore implements AxolotlStore {
|
|||
return true;
|
||||
}
|
||||
|
||||
public Trust getFingerprintTrust(String fingerprint) {
|
||||
public XmppAxolotlSession.Trust getFingerprintTrust(String fingerprint) {
|
||||
return (fingerprint == null)? null : trustCache.get(fingerprint);
|
||||
}
|
||||
|
||||
public void setFingerprintTrust(String fingerprint, Trust trust) {
|
||||
public void setFingerprintTrust(String fingerprint, XmppAxolotlSession.Trust trust) {
|
||||
mXmppConnectionService.databaseBackend.setIdentityKeyTrust(account, fingerprint, trust);
|
||||
trustCache.remove(fingerprint);
|
||||
}
|
||||
|
||||
public Set<IdentityKey> getContactKeysWithTrust(String bareJid, Trust trust) {
|
||||
public Set<IdentityKey> getContactKeysWithTrust(String bareJid, XmppAxolotlSession.Trust trust) {
|
||||
return mXmppConnectionService.databaseBackend.loadIdentityKeys(account, bareJid, trust);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
|
|||
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
||||
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
|
||||
|
@ -30,6 +33,62 @@ public class XmppAxolotlSession {
|
|||
private Integer preKeyId = null;
|
||||
private boolean fresh = true;
|
||||
|
||||
public enum Trust {
|
||||
UNDECIDED(0),
|
||||
TRUSTED(1),
|
||||
UNTRUSTED(2),
|
||||
COMPROMISED(3),
|
||||
INACTIVE_TRUSTED(4),
|
||||
INACTIVE_UNDECIDED(5),
|
||||
INACTIVE_UNTRUSTED(6);
|
||||
|
||||
private static final Map<Integer, Trust> trustsByValue = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (Trust trust : Trust.values()) {
|
||||
trustsByValue.put(trust.getCode(), trust);
|
||||
}
|
||||
}
|
||||
|
||||
private final int code;
|
||||
|
||||
Trust(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
switch (this) {
|
||||
case UNDECIDED:
|
||||
return "Trust undecided " + getCode();
|
||||
case TRUSTED:
|
||||
return "Trusted " + getCode();
|
||||
case COMPROMISED:
|
||||
return "Compromised " + getCode();
|
||||
case INACTIVE_TRUSTED:
|
||||
return "Inactive (Trusted)" + getCode();
|
||||
case INACTIVE_UNDECIDED:
|
||||
return "Inactive (Undecided)" + getCode();
|
||||
case INACTIVE_UNTRUSTED:
|
||||
return "Inactive (Untrusted)" + getCode();
|
||||
case UNTRUSTED:
|
||||
default:
|
||||
return "Untrusted " + getCode();
|
||||
}
|
||||
}
|
||||
|
||||
public static Trust fromBoolean(Boolean trusted) {
|
||||
return trusted ? TRUSTED : UNTRUSTED;
|
||||
}
|
||||
|
||||
public static Trust fromCode(int code) {
|
||||
return trustsByValue.get(code);
|
||||
}
|
||||
}
|
||||
|
||||
public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress, String fingerprint) {
|
||||
this(account, store, remoteAddress);
|
||||
this.fingerprint = fingerprint;
|
||||
|
@ -67,21 +126,21 @@ public class XmppAxolotlSession {
|
|||
this.fresh = false;
|
||||
}
|
||||
|
||||
protected void setTrust(SQLiteAxolotlStore.Trust trust) {
|
||||
protected void setTrust(Trust trust) {
|
||||
sqLiteAxolotlStore.setFingerprintTrust(fingerprint, trust);
|
||||
}
|
||||
|
||||
protected SQLiteAxolotlStore.Trust getTrust() {
|
||||
SQLiteAxolotlStore.Trust trust = sqLiteAxolotlStore.getFingerprintTrust(fingerprint);
|
||||
return (trust == null) ? SQLiteAxolotlStore.Trust.UNDECIDED : trust;
|
||||
protected Trust getTrust() {
|
||||
Trust trust = sqLiteAxolotlStore.getFingerprintTrust(fingerprint);
|
||||
return (trust == null) ? Trust.UNDECIDED : trust;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] processReceiving(byte[] encryptedKey) {
|
||||
byte[] plaintext = null;
|
||||
SQLiteAxolotlStore.Trust trust = getTrust();
|
||||
Trust trust = getTrust();
|
||||
switch (trust) {
|
||||
case INACTIVE:
|
||||
case INACTIVE_TRUSTED:
|
||||
case UNDECIDED:
|
||||
case UNTRUSTED:
|
||||
case TRUSTED:
|
||||
|
@ -110,8 +169,8 @@ public class XmppAxolotlSession {
|
|||
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Error decrypting axolotl header, " + e.getClass().getName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
if (plaintext != null && trust == SQLiteAxolotlStore.Trust.INACTIVE) {
|
||||
setTrust(SQLiteAxolotlStore.Trust.TRUSTED);
|
||||
if (plaintext != null && trust == Trust.INACTIVE_TRUSTED) {
|
||||
setTrust(Trust.TRUSTED);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -126,8 +185,8 @@ public class XmppAxolotlSession {
|
|||
|
||||
@Nullable
|
||||
public byte[] processSending(@NonNull byte[] outgoingMessage) {
|
||||
SQLiteAxolotlStore.Trust trust = getTrust();
|
||||
if (trust == SQLiteAxolotlStore.Trust.TRUSTED) {
|
||||
Trust trust = getTrust();
|
||||
if (trust == Trust.TRUSTED) {
|
||||
CiphertextMessage ciphertextMessage = cipher.encrypt(outgoingMessage);
|
||||
return ciphertextMessage.serialize();
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.net.URL;
|
|||
import java.util.Arrays;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.utils.GeoHelper;
|
||||
import eu.siacs.conversations.utils.MimeUtils;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
|
@ -707,7 +707,7 @@ public class Message extends AbstractEntity {
|
|||
|
||||
public boolean isTrusted() {
|
||||
return conversation.getAccount().getAxolotlService().getFingerprintTrust(axolotlFingerprint)
|
||||
== SQLiteAxolotlStore.Trust.TRUSTED;
|
||||
== XmppAxolotlSession.Trust.TRUSTED;
|
||||
}
|
||||
|
||||
private int getPreviousEncryption() {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
|
@ -844,7 +845,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
return loadIdentityKeys(account, name, null);
|
||||
}
|
||||
|
||||
public Set<IdentityKey> loadIdentityKeys(Account account, String name, SQLiteAxolotlStore.Trust trust) {
|
||||
public Set<IdentityKey> loadIdentityKeys(Account account, String name, XmppAxolotlSession.Trust trust) {
|
||||
Set<IdentityKey> identityKeys = new HashSet<>();
|
||||
Cursor cursor = getIdentityKeyCursor(account, name, false);
|
||||
|
||||
|
@ -870,7 +871,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
String[] args = {
|
||||
account.getUuid(),
|
||||
name,
|
||||
String.valueOf(SQLiteAxolotlStore.Trust.TRUSTED.getCode())
|
||||
String.valueOf(XmppAxolotlSession.Trust.TRUSTED.getCode())
|
||||
};
|
||||
return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME,
|
||||
SQLiteAxolotlStore.ACCOUNT + " = ?"
|
||||
|
@ -881,10 +882,10 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
private void storeIdentityKey(Account account, String name, boolean own, String fingerprint, String base64Serialized) {
|
||||
storeIdentityKey(account, name, own, fingerprint, base64Serialized, SQLiteAxolotlStore.Trust.UNDECIDED);
|
||||
storeIdentityKey(account, name, own, fingerprint, base64Serialized, XmppAxolotlSession.Trust.UNDECIDED);
|
||||
}
|
||||
|
||||
private void storeIdentityKey(Account account, String name, boolean own, String fingerprint, String base64Serialized, SQLiteAxolotlStore.Trust trusted) {
|
||||
private void storeIdentityKey(Account account, String name, boolean own, String fingerprint, String base64Serialized, XmppAxolotlSession.Trust trusted) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(SQLiteAxolotlStore.ACCOUNT, account.getUuid());
|
||||
|
@ -896,19 +897,19 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
db.insert(SQLiteAxolotlStore.IDENTITIES_TABLENAME, null, values);
|
||||
}
|
||||
|
||||
public SQLiteAxolotlStore.Trust isIdentityKeyTrusted(Account account, String fingerprint) {
|
||||
public XmppAxolotlSession.Trust isIdentityKeyTrusted(Account account, String fingerprint) {
|
||||
Cursor cursor = getIdentityKeyCursor(account, fingerprint);
|
||||
SQLiteAxolotlStore.Trust trust = null;
|
||||
XmppAxolotlSession.Trust trust = null;
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
int trustValue = cursor.getInt(cursor.getColumnIndex(SQLiteAxolotlStore.TRUSTED));
|
||||
trust = SQLiteAxolotlStore.Trust.fromCode(trustValue);
|
||||
trust = XmppAxolotlSession.Trust.fromCode(trustValue);
|
||||
}
|
||||
cursor.close();
|
||||
return trust;
|
||||
}
|
||||
|
||||
public boolean setIdentityKeyTrust(Account account, String fingerprint, SQLiteAxolotlStore.Trust trust) {
|
||||
public boolean setIdentityKeyTrust(Account account, String fingerprint, XmppAxolotlSession.Trust trust) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
String[] selectionArgs = {
|
||||
account.getUuid(),
|
||||
|
@ -928,7 +929,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
public void storeOwnIdentityKeyPair(Account account, String name, IdentityKeyPair identityKeyPair) {
|
||||
storeIdentityKey(account, name, true, identityKeyPair.getPublicKey().getFingerprint().replaceAll("\\s", ""), Base64.encodeToString(identityKeyPair.serialize(), Base64.DEFAULT), SQLiteAxolotlStore.Trust.TRUSTED);
|
||||
storeIdentityKey(account, name, true, identityKeyPair.getPublicKey().getFingerprint().replaceAll("\\s", ""), Base64.encodeToString(identityKeyPair.serialize(), Base64.DEFAULT), XmppAxolotlSession.Trust.TRUSTED);
|
||||
}
|
||||
|
||||
public void recreateAxolotlDb() {
|
||||
|
|
|
@ -38,7 +38,7 @@ import de.timroes.android.listview.EnhancedListView;
|
|||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore.Trust;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Blockable;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
|
@ -1260,7 +1260,7 @@ public class ConversationActivity extends XmppActivity
|
|||
|
||||
protected boolean trustKeysIfNeeded(int requestCode, int attachmentChoice) {
|
||||
AxolotlService axolotlService = mSelectedConversation.getAccount().getAxolotlService();
|
||||
boolean hasPendingKeys = !axolotlService.getKeysWithTrust(Trust.UNDECIDED,
|
||||
boolean hasPendingKeys = !axolotlService.getKeysWithTrust(XmppAxolotlSession.Trust.UNDECIDED,
|
||||
mSelectedConversation.getContact()).isEmpty()
|
||||
|| !axolotlService.findDevicesWithoutSession(mSelectedConversation).isEmpty();
|
||||
boolean hasNoTrustedKeys = axolotlService.getNumTrustedKeys(mSelectedConversation.getContact()) == 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore.Trust;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
|
@ -119,7 +119,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
|
|||
for(final IdentityKey identityKey : ownKeysToTrust.keySet()) {
|
||||
hasOwnKeys = true;
|
||||
addFingerprintRowWithListeners(ownKeys, contact.getAccount(), identityKey, false,
|
||||
Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false,
|
||||
XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false,
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -135,7 +135,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
|
|||
for(final IdentityKey identityKey : foreignKeysToTrust.keySet()) {
|
||||
hasForeignKeys = true;
|
||||
addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), identityKey, false,
|
||||
Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false,
|
||||
XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false,
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -171,11 +171,11 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
|
|||
}
|
||||
|
||||
private void getFingerprints(final Account account) {
|
||||
Set<IdentityKey> ownKeysSet = account.getAxolotlService().getKeysWithTrust(Trust.UNDECIDED);
|
||||
Set<IdentityKey> foreignKeysSet = account.getAxolotlService().getKeysWithTrust(Trust.UNDECIDED, contact);
|
||||
Set<IdentityKey> ownKeysSet = account.getAxolotlService().getKeysWithTrust(XmppAxolotlSession.Trust.UNDECIDED);
|
||||
Set<IdentityKey> foreignKeysSet = account.getAxolotlService().getKeysWithTrust(XmppAxolotlSession.Trust.UNDECIDED, contact);
|
||||
if (hasNoTrustedKeys) {
|
||||
ownKeysSet.addAll(account.getAxolotlService().getKeysWithTrust(Trust.UNTRUSTED));
|
||||
foreignKeysSet.addAll(account.getAxolotlService().getKeysWithTrust(Trust.UNTRUSTED, contact));
|
||||
ownKeysSet.addAll(account.getAxolotlService().getKeysWithTrust(XmppAxolotlSession.Trust.UNTRUSTED));
|
||||
foreignKeysSet.addAll(account.getAxolotlService().getKeysWithTrust(XmppAxolotlSession.Trust.UNTRUSTED, contact));
|
||||
}
|
||||
for(final IdentityKey identityKey : ownKeysSet) {
|
||||
if(!ownKeysToTrust.containsKey(identityKey)) {
|
||||
|
@ -226,12 +226,12 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
|
|||
for(IdentityKey identityKey:ownKeysToTrust.keySet()) {
|
||||
contact.getAccount().getAxolotlService().setFingerprintTrust(
|
||||
identityKey.getFingerprint().replaceAll("\\s", ""),
|
||||
Trust.fromBoolean(ownKeysToTrust.get(identityKey)));
|
||||
XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey)));
|
||||
}
|
||||
for(IdentityKey identityKey:foreignKeysToTrust.keySet()) {
|
||||
contact.getAccount().getAxolotlService().setFingerprintTrust(
|
||||
identityKey.getFingerprint().replaceAll("\\s", ""),
|
||||
Trust.fromBoolean(foreignKeysToTrust.get(identityKey)));
|
||||
XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ import java.util.concurrent.RejectedExecutionException;
|
|||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
|
@ -615,24 +615,22 @@ public abstract class XmppActivity extends Activity {
|
|||
|
||||
protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey, boolean highlight) {
|
||||
final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
|
||||
final SQLiteAxolotlStore.Trust trust = account.getAxolotlService()
|
||||
final XmppAxolotlSession.Trust trust = account.getAxolotlService()
|
||||
.getFingerprintTrust(fingerprint);
|
||||
return addFingerprintRowWithListeners(keys, account, identityKey, highlight, trust, true,
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked != (trust == SQLiteAxolotlStore.Trust.TRUSTED)) {
|
||||
account.getAxolotlService().setFingerprintTrust(fingerprint,
|
||||
(isChecked) ? SQLiteAxolotlStore.Trust.TRUSTED :
|
||||
SQLiteAxolotlStore.Trust.UNTRUSTED);
|
||||
}
|
||||
(isChecked) ? XmppAxolotlSession.Trust.TRUSTED :
|
||||
XmppAxolotlSession.Trust.UNTRUSTED);
|
||||
}
|
||||
},
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
account.getAxolotlService().setFingerprintTrust(fingerprint,
|
||||
SQLiteAxolotlStore.Trust.UNTRUSTED);
|
||||
XmppAxolotlSession.Trust.UNTRUSTED);
|
||||
v.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -643,12 +641,12 @@ public abstract class XmppActivity extends Activity {
|
|||
protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account,
|
||||
final IdentityKey identityKey,
|
||||
boolean highlight,
|
||||
SQLiteAxolotlStore.Trust trust,
|
||||
XmppAxolotlSession.Trust trust,
|
||||
boolean showTag,
|
||||
CompoundButton.OnCheckedChangeListener
|
||||
onCheckedChangeListener,
|
||||
View.OnClickListener onClickListener) {
|
||||
if (trust == SQLiteAxolotlStore.Trust.COMPROMISED) {
|
||||
if (trust == XmppAxolotlSession.Trust.COMPROMISED) {
|
||||
return false;
|
||||
}
|
||||
View view = getLayoutInflater().inflate(R.layout.contact_key, keys, false);
|
||||
|
@ -669,7 +667,7 @@ public abstract class XmppActivity extends Activity {
|
|||
switch (trust) {
|
||||
case UNTRUSTED:
|
||||
case TRUSTED:
|
||||
trustToggle.setChecked(trust == SQLiteAxolotlStore.Trust.TRUSTED, false);
|
||||
trustToggle.setChecked(trust == XmppAxolotlSession.Trust.TRUSTED, false);
|
||||
trustToggle.setEnabled(true);
|
||||
key.setTextColor(getPrimaryTextColor());
|
||||
keyType.setTextColor(getSecondaryTextColor());
|
||||
|
@ -680,7 +678,15 @@ public abstract class XmppActivity extends Activity {
|
|||
key.setTextColor(getPrimaryTextColor());
|
||||
keyType.setTextColor(getSecondaryTextColor());
|
||||
break;
|
||||
case INACTIVE:
|
||||
case INACTIVE_UNTRUSTED:
|
||||
case INACTIVE_UNDECIDED:
|
||||
trustToggle.setOnClickListener(null);
|
||||
trustToggle.setChecked(false, false);
|
||||
trustToggle.setEnabled(false);
|
||||
key.setTextColor(getTertiaryTextColor());
|
||||
keyType.setTextColor(getTertiaryTextColor());
|
||||
break;
|
||||
case INACTIVE_TRUSTED:
|
||||
trustToggle.setOnClickListener(null);
|
||||
trustToggle.setChecked(true, false);
|
||||
trustToggle.setEnabled(false);
|
||||
|
|
|
@ -27,7 +27,7 @@ import android.widget.Toast;
|
|||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
|
||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
|
@ -169,11 +169,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
} else {
|
||||
viewHolder.indicator.setVisibility(View.VISIBLE);
|
||||
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
||||
SQLiteAxolotlStore.Trust trust = message.getConversation()
|
||||
XmppAxolotlSession.Trust trust = message.getConversation()
|
||||
.getAccount().getAxolotlService().getFingerprintTrust(
|
||||
message.getAxolotlFingerprint());
|
||||
|
||||
if(trust == null || trust != SQLiteAxolotlStore.Trust.TRUSTED) {
|
||||
if(trust == null || trust != XmppAxolotlSession.Trust.TRUSTED) {
|
||||
viewHolder.indicator.setColorFilter(activity.getWarningTextColor());
|
||||
viewHolder.indicator.setAlpha(1.0f);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue