Upgrade to Curve25519 0.2.4

This commit is contained in:
Moxie Marlinspike 2015-05-01 10:29:13 -07:00
parent 8ec896129d
commit a7b04fce19
4 changed files with 44 additions and 19 deletions

View File

@ -11,16 +11,16 @@ public class CurveTest extends TestCase {
assertTrue(Curve.isNative());
}
public void testSignatureOverflow() throws InvalidKeyException {
ECKeyPair keys = Curve.generateKeyPair();
byte[] message = new byte[4096];
public void testLargeSignatures() throws InvalidKeyException {
ECKeyPair keys = Curve.generateKeyPair();
byte[] message = new byte[1024 * 1024];
byte[] signature = Curve.calculateSignature(keys.getPrivateKey(), message);
try {
byte[] signature = Curve.calculateSignature(keys.getPrivateKey(), message);
throw new InvalidKeyException("Should have asserted!");
} catch (AssertionError e) {
// Success!
}
assertTrue(Curve.verifySignature(keys.getPublicKey(), message, signature));
message[0] ^= 0x01;
assertFalse(Curve.verifySignature(keys.getPublicKey(), message, signature));
}
}

View File

@ -1,7 +1,7 @@
subprojects {
ext.version_number = "1.3.3"
ext.group_info = "org.whispersystems"
ext.curve25519_version = "0.2.2"
ext.curve25519_version = "0.2.4"
if (JavaVersion.current().isJava8Compatible()) {
allprojects {

View File

@ -11,16 +11,16 @@ public class CurveTest extends TestCase {
assertFalse(Curve.isNative());
}
public void testSignatureOverflow() throws InvalidKeyException {
ECKeyPair keys = Curve.generateKeyPair();
byte[] message = new byte[4096];
public void testLargeSignatures() throws InvalidKeyException {
ECKeyPair keys = Curve.generateKeyPair();
byte[] message = new byte[1024 * 1024];
byte[] signature = Curve.calculateSignature(keys.getPrivateKey(), message);
try {
byte[] signature = Curve.calculateSignature(keys.getPrivateKey(), message);
throw new InvalidKeyException("Should have asserted!");
} catch (IllegalArgumentException e) {
// Success!
}
assertTrue(Curve.verifySignature(keys.getPublicKey(), message, signature));
message[0] ^= 0x01;
assertFalse(Curve.verifySignature(keys.getPublicKey(), message, signature));
}
}

View File

@ -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
{