diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-03-03 11:20:36 -0800 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-03-03 11:20:36 -0800 |
commit | 327f82be41058ca1eaf1b501dc91426f8555d892 (patch) | |
tree | 5419b592ced22f595de3423bc72c007ab1c4836a /tests/src/test/java/org | |
parent | d53ed1bb0037ac8ea9717844ae4ab71e5fb75563 (diff) |
Use more generic AxololAddress for identifying recipients.
Diffstat (limited to 'tests/src/test/java/org')
7 files changed, 144 insertions, 142 deletions
diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryAxolotlStore.java b/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryAxolotlStore.java index e375c574..f4bf38eb 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryAxolotlStore.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryAxolotlStore.java @@ -26,13 +26,13 @@ public class InMemoryAxolotlStore implements AxolotlStore { } @Override - public void saveIdentity(long recipientId, IdentityKey identityKey) { - identityKeyStore.saveIdentity(recipientId, identityKey); + public void saveIdentity(String name, IdentityKey identityKey) { + identityKeyStore.saveIdentity(name, identityKey); } @Override - public boolean isTrustedIdentity(long recipientId, IdentityKey identityKey) { - return identityKeyStore.isTrustedIdentity(recipientId, identityKey); + public boolean isTrustedIdentity(String name, IdentityKey identityKey) { + return identityKeyStore.isTrustedIdentity(name, identityKey); } @Override @@ -56,33 +56,33 @@ public class InMemoryAxolotlStore implements AxolotlStore { } @Override - public SessionRecord loadSession(long recipientId, int deviceId) { - return sessionStore.loadSession(recipientId, deviceId); + public SessionRecord loadSession(AxolotlAddress address) { + return sessionStore.loadSession(address); } @Override - public List<Integer> getSubDeviceSessions(long recipientId) { - return sessionStore.getSubDeviceSessions(recipientId); + public List<Integer> getSubDeviceSessions(String name) { + return sessionStore.getSubDeviceSessions(name); } @Override - public void storeSession(long recipientId, int deviceId, SessionRecord record) { - sessionStore.storeSession(recipientId, deviceId, record); + public void storeSession(AxolotlAddress address, SessionRecord record) { + sessionStore.storeSession(address, record); } @Override - public boolean containsSession(long recipientId, int deviceId) { - return sessionStore.containsSession(recipientId, deviceId); + public boolean containsSession(AxolotlAddress address) { + return sessionStore.containsSession(address); } @Override - public void deleteSession(long recipientId, int deviceId) { - sessionStore.deleteSession(recipientId, deviceId); + public void deleteSession(AxolotlAddress address) { + sessionStore.deleteSession(address); } @Override - public void deleteAllSessions(long recipientId) { - sessionStore.deleteAllSessions(recipientId); + public void deleteAllSessions(String name) { + sessionStore.deleteAllSessions(name); } @Override diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryIdentityKeyStore.java b/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryIdentityKeyStore.java index acb6110a..bf6dc318 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryIdentityKeyStore.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/InMemoryIdentityKeyStore.java @@ -11,7 +11,7 @@ import java.util.Map; public class InMemoryIdentityKeyStore implements IdentityKeyStore { - private final Map<Long, IdentityKey> trustedKeys = new HashMap<>(); + private final Map<String, IdentityKey> trustedKeys = new HashMap<>(); private final IdentityKeyPair identityKeyPair; private final int localRegistrationId; @@ -39,13 +39,13 @@ public class InMemoryIdentityKeyStore implements IdentityKeyStore { } @Override - public void saveIdentity(long recipientId, IdentityKey identityKey) { - trustedKeys.put(recipientId, identityKey); + public void saveIdentity(String name, IdentityKey identityKey) { + trustedKeys.put(name, identityKey); } @Override - public boolean isTrustedIdentity(long recipientId, IdentityKey identityKey) { - IdentityKey trusted = trustedKeys.get(recipientId); + public boolean isTrustedIdentity(String name, IdentityKey identityKey) { + IdentityKey trusted = trustedKeys.get(name); return (trusted == null || trusted.equals(identityKey)); } } diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySessionStore.java b/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySessionStore.java index 2d03d437..f707773e 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySessionStore.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySessionStore.java @@ -2,7 +2,6 @@ package org.whispersystems.libaxolotl; import org.whispersystems.libaxolotl.state.SessionRecord; import org.whispersystems.libaxolotl.state.SessionStore; -import org.whispersystems.libaxolotl.util.Pair; import java.io.IOException; import java.util.HashMap; @@ -12,15 +11,15 @@ import java.util.Map; public class InMemorySessionStore implements SessionStore { - private Map<Pair<Long, Integer>, byte[]> sessions = new HashMap<>(); + private Map<AxolotlAddress, byte[]> sessions = new HashMap<>(); public InMemorySessionStore() {} @Override - public synchronized SessionRecord loadSession(long recipientId, int deviceId) { + public synchronized SessionRecord loadSession(AxolotlAddress remoteAddress) { try { - if (containsSession(recipientId, deviceId)) { - return new SessionRecord(sessions.get(new Pair<>(recipientId, deviceId))); + if (containsSession(remoteAddress)) { + return new SessionRecord(sessions.get(remoteAddress)); } else { return new SessionRecord(); } @@ -30,12 +29,12 @@ public class InMemorySessionStore implements SessionStore { } @Override - public synchronized List<Integer> getSubDeviceSessions(long recipientId) { + public synchronized List<Integer> getSubDeviceSessions(String name) { List<Integer> deviceIds = new LinkedList<>(); - for (Pair<Long, Integer> key : sessions.keySet()) { - if (key.first() == recipientId) { - deviceIds.add(key.second()); + for (AxolotlAddress key : sessions.keySet()) { + if (key.getName().equals(name)) { + deviceIds.add(key.getDeviceId()); } } @@ -43,24 +42,24 @@ public class InMemorySessionStore implements SessionStore { } @Override - public synchronized void storeSession(long recipientId, int deviceId, SessionRecord record) { - sessions.put(new Pair<>(recipientId, deviceId), record.serialize()); + public synchronized void storeSession(AxolotlAddress address, SessionRecord record) { + sessions.put(address, record.serialize()); } @Override - public synchronized boolean containsSession(long recipientId, int deviceId) { - return sessions.containsKey(new Pair<>(recipientId, deviceId)); + public synchronized boolean containsSession(AxolotlAddress address) { + return sessions.containsKey(address); } @Override - public synchronized void deleteSession(long recipientId, int deviceId) { - sessions.remove(new Pair<>(recipientId, deviceId)); + public synchronized void deleteSession(AxolotlAddress address) { + sessions.remove(address); } @Override - public synchronized void deleteAllSessions(long recipientId) { - for (Pair<Long, Integer> key : sessions.keySet()) { - if (key.first() == recipientId) { + public synchronized void deleteAllSessions(String name) { + for (AxolotlAddress key : sessions.keySet()) { + if (key.getName().equals(name)) { sessions.remove(key); } } diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/SessionBuilderTest.java b/tests/src/test/java/org/whispersystems/libaxolotl/SessionBuilderTest.java index 0912493e..539131f0 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/SessionBuilderTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/SessionBuilderTest.java @@ -20,13 +20,13 @@ import java.util.Set; public class SessionBuilderTest extends TestCase { - private static final long ALICE_RECIPIENT_ID = 5L; - private static final long BOB_RECIPIENT_ID = 2L; + private static final AxolotlAddress ALICE_ADDRESS = new AxolotlAddress("+14151111111", 1); + private static final AxolotlAddress BOB_ADDRESS = new AxolotlAddress("+14152222222", 1); public void testBasicPreKeyV2() throws InvalidKeyException, InvalidVersionException, InvalidMessageException, InvalidKeyIdException, DuplicateMessageException, LegacyMessageException, UntrustedIdentityException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); ECKeyPair bobPreKeyPair = Curve.generateKeyPair(); @@ -37,11 +37,11 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); - assertTrue(aliceStore.containsSession(BOB_RECIPIENT_ID, 1)); - assertTrue(aliceStore.loadSession(BOB_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 2); + assertTrue(aliceStore.containsSession(BOB_ADDRESS)); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 2); String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessage = aliceSessionCipher.encrypt(originalMessage.getBytes()); assertTrue(outgoingMessage.getType() == CiphertextMessage.PREKEY_TYPE); @@ -49,11 +49,11 @@ public class SessionBuilderTest extends TestCase { PreKeyWhisperMessage incomingMessage = new PreKeyWhisperMessage(outgoingMessage.serialize()); bobStore.storePreKey(31337, new PreKeyRecord(bobPreKey.getPreKeyId(), bobPreKeyPair)); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = bobSessionCipher.decrypt(incomingMessage); - assertTrue(bobStore.containsSession(ALICE_RECIPIENT_ID, 1)); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 2); + assertTrue(bobStore.containsSession(ALICE_ADDRESS)); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 2); assertTrue(originalMessage.equals(new String(plaintext))); CiphertextMessage bobOutgoingMessage = bobSessionCipher.encrypt(originalMessage.getBytes()); @@ -65,8 +65,8 @@ public class SessionBuilderTest extends TestCase { runInteraction(aliceStore, bobStore); aliceStore = new InMemoryAxolotlStore(); - aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); - aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); bobPreKeyPair = Curve.generateKeyPair(); bobPreKey = new PreKeyBundle(bobStore.getLocalRegistrationId(), @@ -82,7 +82,7 @@ public class SessionBuilderTest extends TestCase { bobSessionCipher.decrypt(new PreKeyWhisperMessage(outgoingMessage.serialize())); throw new AssertionError("shouldn't be trusted!"); } catch (UntrustedIdentityException uie) { - bobStore.saveIdentity(ALICE_RECIPIENT_ID, new PreKeyWhisperMessage(outgoingMessage.serialize()).getIdentityKey()); + bobStore.saveIdentity(ALICE_ADDRESS.getName(), new PreKeyWhisperMessage(outgoingMessage.serialize()).getIdentityKey()); } plaintext = bobSessionCipher.decrypt(new PreKeyWhisperMessage(outgoingMessage.serialize())); @@ -105,7 +105,7 @@ public class SessionBuilderTest extends TestCase { public void testBasicPreKeyV3() throws InvalidKeyException, InvalidVersionException, InvalidMessageException, InvalidKeyIdException, DuplicateMessageException, LegacyMessageException, UntrustedIdentityException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); final AxolotlStore bobStore = new InMemoryAxolotlStore(); ECKeyPair bobPreKeyPair = Curve.generateKeyPair(); @@ -121,11 +121,11 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); - assertTrue(aliceStore.containsSession(BOB_RECIPIENT_ID, 1)); - assertTrue(aliceStore.loadSession(BOB_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.containsSession(BOB_ADDRESS)); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); final String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessage = aliceSessionCipher.encrypt(originalMessage.getBytes()); assertTrue(outgoingMessage.getType() == CiphertextMessage.PREKEY_TYPE); @@ -134,18 +134,18 @@ public class SessionBuilderTest extends TestCase { bobStore.storePreKey(31337, new PreKeyRecord(bobPreKey.getPreKeyId(), bobPreKeyPair)); bobStore.storeSignedPreKey(22, new SignedPreKeyRecord(22, System.currentTimeMillis(), bobSignedPreKeyPair, bobSignedPreKeySignature)); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = bobSessionCipher.decrypt(incomingMessage, new SessionCipher.DecryptionCallback() { @Override public void handlePlaintext(byte[] plaintext) { assertTrue(originalMessage.equals(new String(plaintext))); - assertFalse(bobStore.containsSession(ALICE_RECIPIENT_ID, 1)); + assertFalse(bobStore.containsSession(ALICE_ADDRESS)); } }); - assertTrue(bobStore.containsSession(ALICE_RECIPIENT_ID, 1)); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getAliceBaseKey() != null); + assertTrue(bobStore.containsSession(ALICE_ADDRESS)); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getAliceBaseKey() != null); assertTrue(originalMessage.equals(new String(plaintext))); CiphertextMessage bobOutgoingMessage = bobSessionCipher.encrypt(originalMessage.getBytes()); @@ -157,8 +157,8 @@ public class SessionBuilderTest extends TestCase { runInteraction(aliceStore, bobStore); aliceStore = new InMemoryAxolotlStore(); - aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); - aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); bobPreKeyPair = Curve.generateKeyPair(); bobSignedPreKeyPair = Curve.generateKeyPair(); @@ -178,7 +178,7 @@ public class SessionBuilderTest extends TestCase { plaintext = bobSessionCipher.decrypt(new PreKeyWhisperMessage(outgoingMessage.serialize())); throw new AssertionError("shouldn't be trusted!"); } catch (UntrustedIdentityException uie) { - bobStore.saveIdentity(ALICE_RECIPIENT_ID, new PreKeyWhisperMessage(outgoingMessage.serialize()).getIdentityKey()); + bobStore.saveIdentity(ALICE_ADDRESS.getName(), new PreKeyWhisperMessage(outgoingMessage.serialize()).getIdentityKey()); } plaintext = bobSessionCipher.decrypt(new PreKeyWhisperMessage(outgoingMessage.serialize())); @@ -199,7 +199,7 @@ public class SessionBuilderTest extends TestCase { public void testBadSignedPreKeySignature() throws InvalidKeyException, UntrustedIdentityException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); IdentityKeyStore bobIdentityKeyStore = new InMemoryIdentityKeyStore(); @@ -238,7 +238,7 @@ public class SessionBuilderTest extends TestCase { public void testRepeatBundleMessageV2() throws InvalidKeyException, UntrustedIdentityException, InvalidVersionException, InvalidMessageException, InvalidKeyIdException, DuplicateMessageException, LegacyMessageException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); @@ -258,7 +258,7 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessageOne = aliceSessionCipher.encrypt(originalMessage.getBytes()); CiphertextMessage outgoingMessageTwo = aliceSessionCipher.encrypt(originalMessage.getBytes()); @@ -266,7 +266,7 @@ public class SessionBuilderTest extends TestCase { PreKeyWhisperMessage incomingMessage = new PreKeyWhisperMessage(outgoingMessageOne.serialize()); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = bobSessionCipher.decrypt(incomingMessage); assertTrue(originalMessage.equals(new String(plaintext))); @@ -291,7 +291,7 @@ public class SessionBuilderTest extends TestCase { public void testRepeatBundleMessageV3() throws InvalidKeyException, UntrustedIdentityException, InvalidVersionException, InvalidMessageException, InvalidKeyIdException, DuplicateMessageException, LegacyMessageException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); @@ -311,7 +311,7 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessageOne = aliceSessionCipher.encrypt(originalMessage.getBytes()); CiphertextMessage outgoingMessageTwo = aliceSessionCipher.encrypt(originalMessage.getBytes()); @@ -320,7 +320,7 @@ public class SessionBuilderTest extends TestCase { PreKeyWhisperMessage incomingMessage = new PreKeyWhisperMessage(outgoingMessageOne.serialize()); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = bobSessionCipher.decrypt(incomingMessage); assertTrue(originalMessage.equals(new String(plaintext))); @@ -345,7 +345,7 @@ public class SessionBuilderTest extends TestCase { public void testBadMessageBundle() throws InvalidKeyException, UntrustedIdentityException, InvalidVersionException, InvalidMessageException, DuplicateMessageException, LegacyMessageException, InvalidKeyIdException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); @@ -365,7 +365,7 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessageOne = aliceSessionCipher.encrypt(originalMessage.getBytes()); assertTrue(outgoingMessageOne.getType() == CiphertextMessage.PREKEY_TYPE); @@ -377,7 +377,7 @@ public class SessionBuilderTest extends TestCase { badMessage[badMessage.length-10] ^= 0x01; PreKeyWhisperMessage incomingMessage = new PreKeyWhisperMessage(badMessage); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = new byte[0]; @@ -398,10 +398,10 @@ public class SessionBuilderTest extends TestCase { public void testBasicKeyExchange() throws InvalidKeyException, LegacyMessageException, InvalidMessageException, DuplicateMessageException, UntrustedIdentityException, StaleKeyExchangeException, InvalidVersionException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); KeyExchangeMessage aliceKeyExchangeMessage = aliceSessionBuilder.process(); assertTrue(aliceKeyExchangeMessage != null); @@ -415,20 +415,20 @@ public class SessionBuilderTest extends TestCase { KeyExchangeMessage response = aliceSessionBuilder.process(new KeyExchangeMessage(bobKeyExchangeMessageBytes)); assertTrue(response == null); - assertTrue(aliceStore.containsSession(BOB_RECIPIENT_ID, 1)); - assertTrue(bobStore.containsSession(ALICE_RECIPIENT_ID, 1)); + assertTrue(aliceStore.containsSession(BOB_ADDRESS)); + assertTrue(bobStore.containsSession(ALICE_ADDRESS)); runInteraction(aliceStore, bobStore); aliceStore = new InMemoryAxolotlStore(); - aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); aliceKeyExchangeMessage = aliceSessionBuilder.process(); try { bobKeyExchangeMessage = bobSessionBuilder.process(aliceKeyExchangeMessage); throw new AssertionError("This identity shouldn't be trusted!"); } catch (UntrustedIdentityException uie) { - bobStore.saveIdentity(ALICE_RECIPIENT_ID, aliceKeyExchangeMessage.getIdentityKey()); + bobStore.saveIdentity(ALICE_ADDRESS.getName(), aliceKeyExchangeMessage.getIdentityKey()); bobKeyExchangeMessage = bobSessionBuilder.process(aliceKeyExchangeMessage); } @@ -440,10 +440,10 @@ public class SessionBuilderTest extends TestCase { public void testSimultaneousKeyExchange() throws InvalidKeyException, DuplicateMessageException, LegacyMessageException, InvalidMessageException, UntrustedIdentityException, StaleKeyExchangeException, NoSessionException { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); KeyExchangeMessage aliceKeyExchange = aliceSessionBuilder.process(); KeyExchangeMessage bobKeyExchange = bobSessionBuilder.process(); @@ -468,7 +468,7 @@ public class SessionBuilderTest extends TestCase { public void testOptionalOneTimePreKey() throws Exception { AxolotlStore aliceStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); AxolotlStore bobStore = new InMemoryAxolotlStore(); @@ -485,11 +485,11 @@ public class SessionBuilderTest extends TestCase { aliceSessionBuilder.process(bobPreKey); - assertTrue(aliceStore.containsSession(BOB_RECIPIENT_ID, 1)); - assertTrue(aliceStore.loadSession(BOB_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.containsSession(BOB_ADDRESS)); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); String originalMessage = "L'homme est condamné à être libre"; - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); CiphertextMessage outgoingMessage = aliceSessionCipher.encrypt(originalMessage.getBytes()); assertTrue(outgoingMessage.getType() == CiphertextMessage.PREKEY_TYPE); @@ -500,12 +500,12 @@ public class SessionBuilderTest extends TestCase { bobStore.storePreKey(31337, new PreKeyRecord(bobPreKey.getPreKeyId(), bobPreKeyPair)); bobStore.storeSignedPreKey(22, new SignedPreKeyRecord(22, System.currentTimeMillis(), bobSignedPreKeyPair, bobSignedPreKeySignature)); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); byte[] plaintext = bobSessionCipher.decrypt(incomingMessage); - assertTrue(bobStore.containsSession(ALICE_RECIPIENT_ID, 1)); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getAliceBaseKey() != null); + assertTrue(bobStore.containsSession(ALICE_ADDRESS)); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getAliceBaseKey() != null); assertTrue(originalMessage.equals(new String(plaintext))); } @@ -513,8 +513,8 @@ public class SessionBuilderTest extends TestCase { private void runInteraction(AxolotlStore aliceStore, AxolotlStore bobStore) throws DuplicateMessageException, LegacyMessageException, InvalidMessageException, NoSessionException { - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPIENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); String originalMessage = "smert ze smert"; CiphertextMessage aliceMessage = aliceSessionCipher.encrypt(originalMessage.getBytes()); diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/SessionCipherTest.java b/tests/src/test/java/org/whispersystems/libaxolotl/SessionCipherTest.java index e956ed77..a3b5db4c 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/SessionCipherTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/SessionCipherTest.java @@ -52,11 +52,11 @@ public class SessionCipherTest extends TestCase { AxolotlStore aliceStore = new InMemoryAxolotlStore(); AxolotlStore bobStore = new InMemoryAxolotlStore(); - aliceStore.storeSession(2L, 1, aliceSessionRecord); - bobStore.storeSession(3L, 1, bobSessionRecord); + aliceStore.storeSession(new AxolotlAddress("+14159999999", 1), aliceSessionRecord); + bobStore.storeSession(new AxolotlAddress("+14158888888", 1), bobSessionRecord); - SessionCipher aliceCipher = new SessionCipher(aliceStore, 2L, 1); - SessionCipher bobCipher = new SessionCipher(bobStore, 3L, 1); + SessionCipher aliceCipher = new SessionCipher(aliceStore, new AxolotlAddress("+14159999999", 1)); + SessionCipher bobCipher = new SessionCipher(bobStore, new AxolotlAddress("+14158888888", 1)); byte[] alicePlaintext = "This is a plaintext message.".getBytes(); CiphertextMessage message = aliceCipher.encrypt(alicePlaintext); diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/SimultaneousInitiateTests.java b/tests/src/test/java/org/whispersystems/libaxolotl/SimultaneousInitiateTests.java index f09fedf8..6e68508c 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/SimultaneousInitiateTests.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/SimultaneousInitiateTests.java @@ -18,8 +18,8 @@ import java.util.Random; public class SimultaneousInitiateTests extends TestCase { - private static final long BOB_RECIPENT_ID = 12345; - private static final long ALICE_RECIPIENT_ID = 6789; + private static final AxolotlAddress BOB_ADDRESS = new AxolotlAddress("+14151231234", 1); + private static final AxolotlAddress ALICE_ADDRESS = new AxolotlAddress("+14159998888", 1); private static final ECKeyPair aliceSignedPreKey = Curve.generateKeyPair(); private static final ECKeyPair bobSignedPreKey = Curve.generateKeyPair(); @@ -38,11 +38,11 @@ public class SimultaneousInitiateTests extends TestCase { PreKeyBundle alicePreKeyBundle = createAlicePreKeyBundle(aliceStore); PreKeyBundle bobPreKeyBundle = createBobPreKeyBundle(bobStore); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); aliceSessionBuilder.process(bobPreKeyBundle); bobSessionBuilder.process(alicePreKeyBundle); @@ -61,8 +61,8 @@ public class SimultaneousInitiateTests extends TestCase { assertTrue(new String(alicePlaintext).equals("sample message")); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); assertFalse(isSessionIdEqual(aliceStore, bobStore)); @@ -92,11 +92,11 @@ public class SimultaneousInitiateTests extends TestCase { PreKeyBundle alicePreKeyBundle = createAlicePreKeyBundle(aliceStore); PreKeyBundle bobPreKeyBundle = createBobPreKeyBundle(bobStore); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); aliceSessionBuilder.process(bobPreKeyBundle); bobSessionBuilder.process(alicePreKeyBundle); @@ -112,7 +112,7 @@ public class SimultaneousInitiateTests extends TestCase { byte[] bobPlaintext = bobSessionCipher.decrypt(new PreKeyWhisperMessage(messageForBob.serialize())); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); CiphertextMessage aliceResponse = aliceSessionCipher.encrypt("second message".getBytes()); @@ -144,11 +144,11 @@ public class SimultaneousInitiateTests extends TestCase { PreKeyBundle alicePreKeyBundle = createAlicePreKeyBundle(aliceStore); PreKeyBundle bobPreKeyBundle = createBobPreKeyBundle(bobStore); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); aliceSessionBuilder.process(bobPreKeyBundle); bobSessionBuilder.process(alicePreKeyBundle); @@ -167,8 +167,8 @@ public class SimultaneousInitiateTests extends TestCase { assertTrue(new String(alicePlaintext).equals("sample message")); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); assertFalse(isSessionIdEqual(aliceStore, bobStore)); @@ -203,11 +203,11 @@ public class SimultaneousInitiateTests extends TestCase { PreKeyBundle alicePreKeyBundle = createAlicePreKeyBundle(aliceStore); PreKeyBundle bobPreKeyBundle = createBobPreKeyBundle(bobStore); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); aliceSessionBuilder.process(bobPreKeyBundle); bobSessionBuilder.process(alicePreKeyBundle); @@ -226,8 +226,8 @@ public class SimultaneousInitiateTests extends TestCase { assertTrue(new String(alicePlaintext).equals("sample message")); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); assertFalse(isSessionIdEqual(aliceStore, bobStore)); @@ -277,11 +277,11 @@ public class SimultaneousInitiateTests extends TestCase { AxolotlStore bobStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); for (int i=0;i<15;i++) { PreKeyBundle alicePreKeyBundle = createAlicePreKeyBundle(aliceStore); @@ -304,8 +304,8 @@ public class SimultaneousInitiateTests extends TestCase { assertTrue(new String(alicePlaintext).equals("sample message")); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); assertFalse(isSessionIdEqual(aliceStore, bobStore)); } @@ -356,11 +356,11 @@ public class SimultaneousInitiateTests extends TestCase { AxolotlStore bobStore = new InMemoryAxolotlStore(); - SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_RECIPENT_ID, 1); - SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_RECIPIENT_ID, 1); + SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, BOB_ADDRESS); + SessionBuilder bobSessionBuilder = new SessionBuilder(bobStore, ALICE_ADDRESS); - SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_RECIPENT_ID, 1); - SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_RECIPIENT_ID, 1); + SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); + SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); // PreKeyBundle aliceLostPreKeyBundle = createAlicePreKeyBundle(aliceStore); PreKeyBundle bobLostPreKeyBundle = createBobPreKeyBundle(bobStore); @@ -392,8 +392,8 @@ public class SimultaneousInitiateTests extends TestCase { assertTrue(new String(alicePlaintext).equals("sample message")); assertTrue(new String(bobPlaintext).equals("hey there")); - assertTrue(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getSessionVersion() == 3); - assertTrue(bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getSessionVersion() == 3); + assertTrue(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getSessionVersion() == 3); + assertTrue(bobStore.loadSession(ALICE_ADDRESS).getSessionState().getSessionVersion() == 3); assertFalse(isSessionIdEqual(aliceStore, bobStore)); } @@ -447,8 +447,8 @@ public class SimultaneousInitiateTests extends TestCase { } private boolean isSessionIdEqual(AxolotlStore aliceStore, AxolotlStore bobStore) { - return Arrays.equals(aliceStore.loadSession(BOB_RECIPENT_ID, 1).getSessionState().getAliceBaseKey(), - bobStore.loadSession(ALICE_RECIPIENT_ID, 1).getSessionState().getAliceBaseKey()); + return Arrays.equals(aliceStore.loadSession(BOB_ADDRESS).getSessionState().getAliceBaseKey(), + bobStore.loadSession(ALICE_ADDRESS).getSessionState().getAliceBaseKey()); } private PreKeyBundle createAlicePreKeyBundle(AxolotlStore aliceStore) throws InvalidKeyException { diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java index b41adb58..dd5a306f 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java @@ -2,6 +2,7 @@ package org.whispersystems.libaxolotl.groups; import junit.framework.TestCase; +import org.whispersystems.libaxolotl.AxolotlAddress; import org.whispersystems.libaxolotl.DuplicateMessageException; import org.whispersystems.libaxolotl.InvalidMessageException; import org.whispersystems.libaxolotl.LegacyMessageException; @@ -14,6 +15,9 @@ import java.util.ArrayList; public class GroupCipherTest extends TestCase { + private static final AxolotlAddress SENDER_ADDRESS = new AxolotlAddress("+14150001111", 1); + private static final SenderKeyName GROUP_SENDER = new SenderKeyName("nihilist history reading group", SENDER_ADDRESS); + public void testBasicEncryptDecrypt() throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException { @@ -23,13 +27,12 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("cool group", 1111, 0)); - GroupCipher bobGroupCipher = new GroupCipher(bobStore, new SenderKeyName("cool group", 1111, 0)); + GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER); + GroupCipher bobGroupCipher = new GroupCipher(bobStore, GROUP_SENDER); - SenderKeyDistributionMessage aliceDistributionMessage = - aliceSessionBuilder.create(new SenderKeyName("cool group", 1111, 0)); + SenderKeyDistributionMessage aliceDistributionMessage = aliceSessionBuilder.create(GROUP_SENDER); - bobSessionBuilder.process(new SenderKeyName("cool group", 1111, 0), aliceDistributionMessage); + bobSessionBuilder.process(GROUP_SENDER, aliceDistributionMessage); byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes()); byte[] plaintextFromAlice = bobGroupCipher.decrypt(ciphertextFromAlice); @@ -46,7 +49,7 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - SenderKeyName aliceName = new SenderKeyName("cool group", 1111, 0); + SenderKeyName aliceName = GROUP_SENDER; GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName); GroupCipher bobGroupCipher = new GroupCipher(bobStore, aliceName); @@ -86,7 +89,7 @@ public class GroupCipherTest extends TestCase { GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); - SenderKeyName aliceName = new SenderKeyName("cool group", 1111, 0); + SenderKeyName aliceName = GROUP_SENDER; GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName); GroupCipher bobGroupCipher = new GroupCipher(bobStore, aliceName); @@ -113,7 +116,7 @@ public class GroupCipherTest extends TestCase { public void testEncryptNoSession() { InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore(); - GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("coolio groupio", 1111, 0)); + GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, new SenderKeyName("coolio groupio", new AxolotlAddress("+10002223333", 1))); try { aliceGroupCipher.encrypt("up the punks".getBytes()); throw new AssertionError("Should have failed!"); |