diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-04-06 12:28:16 -0700 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-04-06 12:28:16 -0700 |
commit | 8335b0ef0333e0e7e7204182783fa05cc93dff7d (patch) | |
tree | 314e3f8ef74d7f48f95e563b5df78a606ffc6b6b /tests/src | |
parent | 3d9c94428898f6e633b67082237b620c7877f5c1 (diff) |
Throw NoSessionException in GroupCipher decrypt()
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
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 32fcc652..aad8b083 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java @@ -18,6 +18,30 @@ 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 testNoSession() throws InvalidMessageException, LegacyMessageException, NoSessionException, DuplicateMessageException { + InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore(); + InMemorySenderKeyStore bobStore = new InMemorySenderKeyStore(); + + GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore); + GroupSessionBuilder bobSessionBuilder = new GroupSessionBuilder(bobStore); + + GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER); + GroupCipher bobGroupCipher = new GroupCipher(bobStore, GROUP_SENDER); + + SenderKeyDistributionMessage sentAliceDistributionMessage = aliceSessionBuilder.create(GROUP_SENDER); + SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize()); + +// bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage); + + byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes()); + try { + byte[] plaintextFromAlice = bobGroupCipher.decrypt(ciphertextFromAlice); + throw new AssertionError("Should be no session!"); + } catch (NoSessionException e) { + // good + } + } + public void testBasicEncryptDecrypt() throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException { |