Switch to updated Curve25519 dependency.

This commit is contained in:
Moxie Marlinspike 2015-02-02 16:21:06 -08:00
parent d5d2ea9213
commit 0ee1caa77b
3 changed files with 14 additions and 34 deletions

View File

@ -1,21 +1,7 @@
buildscript {
dependencies {
classpath files('libs/gradle-witness.jar')
}
}
subprojects {
apply plugin: 'witness'
ext.version_number = "1.0.1"
ext.group_info = "org.whispersystems"
ext.curve25519_version = "0.1.3"
dependencyVerification {
verify = [
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
]
}
ext.curve25519_version = "0.2.1"
if (JavaVersion.current().isJava8Compatible()) {
allprojects {

View File

@ -16,24 +16,23 @@
*/
package org.whispersystems.libaxolotl.ecc;
import org.whispersystems.curve25519.Curve25519KeyPair;
import org.whispersystems.libaxolotl.InvalidKeyException;
import org.whispersystems.curve25519.Curve25519;
import org.whispersystems.curve25519.Curve25519KeyPair;
import org.whispersystems.curve25519.NoSuchProviderException;
import org.whispersystems.libaxolotl.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import static org.whispersystems.curve25519.Curve25519.BEST;
public class Curve {
public static final int DJB_TYPE = 0x05;
public static boolean isNative() {
return Curve25519.isNative();
return Curve25519.getInstance(BEST).isNative();
}
public static ECKeyPair generateKeyPair() {
SecureRandom secureRandom = getSecureRandom();
Curve25519KeyPair keyPair = Curve25519.generateKeyPair(secureRandom);
Curve25519KeyPair keyPair = Curve25519.getInstance(BEST).generateKeyPair();
return new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
new DjbECPrivateKey(keyPair.getPrivateKey()));
@ -66,8 +65,9 @@ public class Curve {
}
if (publicKey.getType() == DJB_TYPE) {
return Curve25519.calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
((DjbECPrivateKey)privateKey).getPrivateKey());
return Curve25519.getInstance(BEST)
.calculateAgreement(((DjbECPublicKey) publicKey).getPublicKey(),
((DjbECPrivateKey) privateKey).getPrivateKey());
} else {
throw new InvalidKeyException("Unknown type: " + publicKey.getType());
}
@ -77,7 +77,8 @@ public class Curve {
throws InvalidKeyException
{
if (signingKey.getType() == DJB_TYPE) {
return Curve25519.verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature);
return Curve25519.getInstance(BEST)
.verifySignature(((DjbECPublicKey) signingKey).getPublicKey(), message, signature);
} else {
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
}
@ -87,17 +88,10 @@ public class Curve {
throws InvalidKeyException
{
if (signingKey.getType() == DJB_TYPE) {
return Curve25519.calculateSignature(getSecureRandom(), ((DjbECPrivateKey)signingKey).getPrivateKey(), message);
return Curve25519.getInstance(BEST)
.calculateSignature(((DjbECPrivateKey) signingKey).getPrivateKey(), message);
} else {
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
}
}
private static SecureRandom getSecureRandom() {
try {
return SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
}
}

Binary file not shown.