diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-05-01 10:29:13 -0700 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-05-01 10:29:13 -0700 |
commit | a7b04fce1942060d833b769f13ac21ae2a590393 (patch) | |
tree | a2bd0fc9c129d516db52764e19cf5d36134300e1 /tests | |
parent | 8ec896129ddb5adefa5d94d73e4f99206bdac2d9 (diff) |
Upgrade to Curve25519 0.2.4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java | 25 |
1 files changed, 25 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 aad8b083..23d26cab 100644 --- a/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java +++ b/tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java @@ -12,6 +12,8 @@ import org.whispersystems.libaxolotl.protocol.SenderKeyDistributionMessage; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; public class GroupCipherTest extends TestCase { @@ -64,6 +66,29 @@ public class GroupCipherTest extends TestCase { assertTrue(new String(plaintextFromAlice).equals("smert ze smert")); } + public void testLargeMessages() 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[] plaintext = new byte[1024 * 1024]; + new Random().nextBytes(plaintext); + + byte[] ciphertextFromAlice = aliceGroupCipher.encrypt(plaintext); + byte[] plaintextFromAlice = bobGroupCipher.decrypt(ciphertextFromAlice); + + assertTrue(Arrays.equals(plaintext, plaintextFromAlice)); + } + public void testBasicRatchet() throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException { |