aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/whispersystems/libaxolotl/groups/GroupCipherTest.java25
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
{