mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Upgraded to BouncyCastle 1.50. Added bouncy -> spongy conversion script.
This commit is contained in:
@@ -4,7 +4,6 @@ import java.math.BigInteger;
|
||||
|
||||
import org.spongycastle.crypto.params.ECDomainParameters;
|
||||
import org.spongycastle.math.ec.ECCurve;
|
||||
import org.spongycastle.math.ec.ECFieldElement;
|
||||
import org.spongycastle.math.ec.ECPoint;
|
||||
|
||||
/** Parameters for curve brainpoolP384r1 - see RFC 5639. */
|
||||
@@ -63,8 +62,6 @@ interface EllipticCurveConstants {
|
||||
|
||||
// Static parameter objects derived from the above parameters
|
||||
ECCurve CURVE = new ECCurve.Fp(P, A, B);
|
||||
ECPoint G = new ECPoint.Fp(CURVE,
|
||||
new ECFieldElement.Fp(P, X),
|
||||
new ECFieldElement.Fp(P, Y));
|
||||
ECPoint G = CURVE.createPoint(X, Y);
|
||||
ECDomainParameters PARAMETERS = new ECDomainParameters(CURVE, G, Q, H);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ import java.security.GeneralSecurityException;
|
||||
import org.briarproject.api.crypto.KeyParser;
|
||||
import org.briarproject.api.crypto.PrivateKey;
|
||||
import org.briarproject.api.crypto.PublicKey;
|
||||
|
||||
import org.spongycastle.crypto.params.ECDomainParameters;
|
||||
import org.spongycastle.crypto.params.ECPrivateKeyParameters;
|
||||
import org.spongycastle.crypto.params.ECPublicKeyParameters;
|
||||
import org.spongycastle.math.ec.ECFieldElement;
|
||||
import org.spongycastle.math.ec.ECPoint;
|
||||
|
||||
/**
|
||||
@@ -58,9 +56,7 @@ class Sec1KeyParser implements KeyParser {
|
||||
BigInteger rhs = x.multiply(x).add(a).multiply(x).add(b).mod(modulus);
|
||||
if(!lhs.equals(rhs)) throw new GeneralSecurityException();
|
||||
// We know the point (x, y) is on the curve, so we can create the point
|
||||
ECFieldElement elementX = new ECFieldElement.Fp(modulus, x);
|
||||
ECFieldElement elementY = new ECFieldElement.Fp(modulus, y);
|
||||
ECPoint pub = new ECPoint.Fp(params.getCurve(), elementX, elementY);
|
||||
ECPoint pub = params.getCurve().createPoint(x, y);
|
||||
// Verify that the point (x, y) is not the point at infinity
|
||||
if(pub.isInfinity()) throw new GeneralSecurityException();
|
||||
// Verify that the point (x, y) times n is the point at infinity
|
||||
|
||||
@@ -23,9 +23,9 @@ class Sec1PublicKey implements PublicKey {
|
||||
public byte[] getEncoded() {
|
||||
byte[] encodedKey = new byte[publicKeyBytes];
|
||||
encodedKey[0] = 4;
|
||||
byte[] x = key.getQ().getX().toBigInteger().toByteArray();
|
||||
byte[] x = key.getQ().getAffineXCoord().toBigInteger().toByteArray();
|
||||
Sec1Utils.convertToFixedLength(x, encodedKey, 1, bytesPerInt);
|
||||
byte[] y = key.getQ().getY().toBigInteger().toByteArray();
|
||||
byte[] y = key.getQ().getAffineYCoord().toBigInteger().toByteArray();
|
||||
Sec1Utils.convertToFixedLength(y, encodedKey, 1 + bytesPerInt,
|
||||
bytesPerInt);
|
||||
return encodedKey;
|
||||
|
||||
Reference in New Issue
Block a user