Switch to updated Curve25519 dependency.
This commit is contained in:
parent
d5d2ea9213
commit
0ee1caa77b
16
build.gradle
16
build.gradle
|
@ -1,21 +1,7 @@
|
||||||
buildscript {
|
|
||||||
dependencies {
|
|
||||||
classpath files('libs/gradle-witness.jar')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'witness'
|
|
||||||
|
|
||||||
ext.version_number = "1.0.1"
|
ext.version_number = "1.0.1"
|
||||||
ext.group_info = "org.whispersystems"
|
ext.group_info = "org.whispersystems"
|
||||||
ext.curve25519_version = "0.1.3"
|
ext.curve25519_version = "0.2.1"
|
||||||
|
|
||||||
dependencyVerification {
|
|
||||||
verify = [
|
|
||||||
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JavaVersion.current().isJava8Compatible()) {
|
if (JavaVersion.current().isJava8Compatible()) {
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
|
@ -16,24 +16,23 @@
|
||||||
*/
|
*/
|
||||||
package org.whispersystems.libaxolotl.ecc;
|
package org.whispersystems.libaxolotl.ecc;
|
||||||
|
|
||||||
import org.whispersystems.curve25519.Curve25519KeyPair;
|
|
||||||
import org.whispersystems.libaxolotl.InvalidKeyException;
|
|
||||||
import org.whispersystems.curve25519.Curve25519;
|
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 static org.whispersystems.curve25519.Curve25519.BEST;
|
||||||
import java.security.SecureRandom;
|
|
||||||
|
|
||||||
public class Curve {
|
public class Curve {
|
||||||
|
|
||||||
public static final int DJB_TYPE = 0x05;
|
public static final int DJB_TYPE = 0x05;
|
||||||
|
|
||||||
public static boolean isNative() {
|
public static boolean isNative() {
|
||||||
return Curve25519.isNative();
|
return Curve25519.getInstance(BEST).isNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ECKeyPair generateKeyPair() {
|
public static ECKeyPair generateKeyPair() {
|
||||||
SecureRandom secureRandom = getSecureRandom();
|
Curve25519KeyPair keyPair = Curve25519.getInstance(BEST).generateKeyPair();
|
||||||
Curve25519KeyPair keyPair = Curve25519.generateKeyPair(secureRandom);
|
|
||||||
|
|
||||||
return new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
|
return new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
|
||||||
new DjbECPrivateKey(keyPair.getPrivateKey()));
|
new DjbECPrivateKey(keyPair.getPrivateKey()));
|
||||||
|
@ -66,7 +65,8 @@ public class Curve {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicKey.getType() == DJB_TYPE) {
|
if (publicKey.getType() == DJB_TYPE) {
|
||||||
return Curve25519.calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
|
return Curve25519.getInstance(BEST)
|
||||||
|
.calculateAgreement(((DjbECPublicKey) publicKey).getPublicKey(),
|
||||||
((DjbECPrivateKey) privateKey).getPrivateKey());
|
((DjbECPrivateKey) privateKey).getPrivateKey());
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidKeyException("Unknown type: " + publicKey.getType());
|
throw new InvalidKeyException("Unknown type: " + publicKey.getType());
|
||||||
|
@ -77,7 +77,8 @@ public class Curve {
|
||||||
throws InvalidKeyException
|
throws InvalidKeyException
|
||||||
{
|
{
|
||||||
if (signingKey.getType() == DJB_TYPE) {
|
if (signingKey.getType() == DJB_TYPE) {
|
||||||
return Curve25519.verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature);
|
return Curve25519.getInstance(BEST)
|
||||||
|
.verifySignature(((DjbECPublicKey) signingKey).getPublicKey(), message, signature);
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
|
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
|
||||||
}
|
}
|
||||||
|
@ -87,17 +88,10 @@ public class Curve {
|
||||||
throws InvalidKeyException
|
throws InvalidKeyException
|
||||||
{
|
{
|
||||||
if (signingKey.getType() == DJB_TYPE) {
|
if (signingKey.getType() == DJB_TYPE) {
|
||||||
return Curve25519.calculateSignature(getSecureRandom(), ((DjbECPrivateKey)signingKey).getPrivateKey(), message);
|
return Curve25519.getInstance(BEST)
|
||||||
|
.calculateSignature(((DjbECPrivateKey) signingKey).getPrivateKey(), message);
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
|
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.
Loading…
Reference in New Issue