aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java b/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
index 23024a610..3c5ddd3db 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
@@ -3,17 +3,17 @@ package de.pixart.messenger.crypto.axolotl;
import android.util.Log;
import android.util.LruCache;
-import org.whispersystems.libaxolotl.AxolotlAddress;
-import org.whispersystems.libaxolotl.IdentityKey;
-import org.whispersystems.libaxolotl.IdentityKeyPair;
-import org.whispersystems.libaxolotl.InvalidKeyIdException;
-import org.whispersystems.libaxolotl.ecc.Curve;
-import org.whispersystems.libaxolotl.ecc.ECKeyPair;
-import org.whispersystems.libaxolotl.state.AxolotlStore;
-import org.whispersystems.libaxolotl.state.PreKeyRecord;
-import org.whispersystems.libaxolotl.state.SessionRecord;
-import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
-import org.whispersystems.libaxolotl.util.KeyHelper;
+import org.whispersystems.libsignal.SignalProtocolAddress;
+import org.whispersystems.libsignal.IdentityKey;
+import org.whispersystems.libsignal.IdentityKeyPair;
+import org.whispersystems.libsignal.InvalidKeyIdException;
+import org.whispersystems.libsignal.ecc.Curve;
+import org.whispersystems.libsignal.ecc.ECKeyPair;
+import org.whispersystems.libsignal.state.SignalProtocolStore;
+import org.whispersystems.libsignal.state.PreKeyRecord;
+import org.whispersystems.libsignal.state.SessionRecord;
+import org.whispersystems.libsignal.state.SignedPreKeyRecord;
+import org.whispersystems.libsignal.util.KeyHelper;
import java.security.cert.X509Certificate;
import java.util.List;
@@ -23,7 +23,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.services.XmppConnectionService;
-public class SQLiteAxolotlStore implements AxolotlStore {
+public class SQLiteAxolotlStore implements SignalProtocolStore {
public static final String PREKEY_TABLENAME = "prekeys";
public static final String SIGNED_PREKEY_TABLENAME = "signed_prekeys";
@@ -179,17 +179,18 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* <p/>
* Store a remote client's identity key as trusted.
*
- * @param name The name of the remote client.
+ * @param address The address of the remote client.
* @param identityKey The remote client's identity key.
+ * @return true on success
*/
@Override
- public void saveIdentity(String name, IdentityKey identityKey) {
- if (!mXmppConnectionService.databaseBackend.loadIdentityKeys(account, name).contains(identityKey)) {
+ public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
+ if (!mXmppConnectionService.databaseBackend.loadIdentityKeys(account, address.getName()).contains(identityKey)) {
String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
FingerprintStatus status = getFingerprintStatus(fingerprint);
if (status == null) {
- if (mXmppConnectionService.blindTrustBeforeVerification() && !account.getAxolotlService().hasVerifiedKeys(name)) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": blindly trusted "+fingerprint+" of "+name);
+ if (mXmppConnectionService.blindTrustBeforeVerification() && !account.getAxolotlService().hasVerifiedKeys(address.getName())) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": blindly trusted " + fingerprint + " of " + address.getName());
status = FingerprintStatus.createActiveTrusted();
} else {
status = FingerprintStatus.createActiveUndecided();
@@ -197,9 +198,10 @@ public class SQLiteAxolotlStore implements AxolotlStore {
} else {
status = status.toActive();
}
- mXmppConnectionService.databaseBackend.storeIdentityKey(account, name, identityKey, status);
+ mXmppConnectionService.databaseBackend.storeIdentityKey(account, address.getName(), identityKey, status);
trustCache.remove(fingerprint);
}
+ return true;
}
/**
@@ -217,7 +219,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* @return true if trusted, false if untrusted.
*/
@Override
- public boolean isTrustedIdentity(String name, IdentityKey identityKey) {
+ public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) {
return true;
}
@@ -264,7 +266,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* a new SessionRecord if one does not currently exist.
*/
@Override
- public SessionRecord loadSession(AxolotlAddress address) {
+ public SessionRecord loadSession(SignalProtocolAddress address) {
SessionRecord session = mXmppConnectionService.databaseBackend.loadSession(this.account, address);
return (session != null) ? session : new SessionRecord();
}
@@ -278,7 +280,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
@Override
public List<Integer> getSubDeviceSessions(String name) {
return mXmppConnectionService.databaseBackend.getSubDeviceSessions(account,
- new AxolotlAddress(name, 0));
+ new SignalProtocolAddress(name, 0));
}
/**
@@ -288,7 +290,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* @param record the current SessionRecord for the remote client.
*/
@Override
- public void storeSession(AxolotlAddress address, SessionRecord record) {
+ public void storeSession(SignalProtocolAddress address, SessionRecord record) {
mXmppConnectionService.databaseBackend.storeSession(account, address, record);
}
@@ -299,7 +301,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* @return true if a {@link SessionRecord} exists, false otherwise.
*/
@Override
- public boolean containsSession(AxolotlAddress address) {
+ public boolean containsSession(SignalProtocolAddress address) {
return mXmppConnectionService.databaseBackend.containsSession(account, address);
}
@@ -309,7 +311,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
* @param address the address of the remote client.
*/
@Override
- public void deleteSession(AxolotlAddress address) {
+ public void deleteSession(SignalProtocolAddress address) {
mXmppConnectionService.databaseBackend.deleteSession(account, address);
}
@@ -320,7 +322,7 @@ public class SQLiteAxolotlStore implements AxolotlStore {
*/
@Override
public void deleteAllSessions(String name) {
- AxolotlAddress address = new AxolotlAddress(name, 0);
+ SignalProtocolAddress address = new SignalProtocolAddress(name, 0);
mXmppConnectionService.databaseBackend.deleteAllSessions(account,
address);
}