Skip to content

Commit

Permalink
compatibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Dec 29, 2015
1 parent e2b9c51 commit e8705b5
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 1,766 deletions.
3 changes: 3 additions & 0 deletions build1-1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm -rf org/bouncycastle/jce/provider/test/CRL5Test.java
rm -rf org/bouncycastle/jce/provider/test/X509LDAP*.java
rm -rf org/bouncycastle/jce/provider/test/MQVTest*.java
rm -rf org/bouncycastle/jce/provider/test/AlgorithmParametersTest.java
rm -rf org/bouncycastle/jce/spec/ECNamedCurveSpec.java
rm -rf org/bouncycastle/util/encoders/test/*.java
rm -rf org/bouncycastle/x509/PKIXCertPathReviewer.java
Expand All @@ -103,6 +104,8 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm -rf org/bouncycastle/jce/provider/test/rsa3
rm -rf org/bouncycastle/jce/provider/test/DSTU4145Test.java
rm -rf org/bouncycastle/jce/provider/test/JceTestUtil.java
rm -f org/bouncycastle/math/ec/tools/F2mSqrtOptimizer.java
rm -f org/bouncycastle/math/ec/tools/TraceOptimizer.java
rm -rf org/bouncycastle/x509/PKIXAttrCert*.java
rm -rf org/bouncycastle/jce/provider/RFC3281*.java
rm -rf org/bouncycastle/jcajce/PKCS12StoreParameter.java
Expand Down
1 change: 1 addition & 0 deletions build1-2
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ find $jdk12src -name "*.java" -exec scripts/usejcecert.sh \{\} \;
rm -rf org/bouncycastle/jce/provider/test/CRL5Test.java
rm -rf org/bouncycastle/jce/provider/test/X509LDAP*.java
rm -rf org/bouncycastle/jce/provider/test/MQVTest*.java
rm -rf org/bouncycastle/jce/provider/test/AlgorithmParametersTest.java
rm -rf org/bouncycastle/jce/spec/ECNamedCurveSpec.java
rm -rf org/bouncycastle/util/encoders/test/*.java
rm -rf org/bouncycastle/x509/PKIXCertPathReviewer.java
Expand Down
62 changes: 31 additions & 31 deletions core/src/main/java/org/bouncycastle/math/ec/ECCurve.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,13 @@ protected AbstractFp(BigInteger q)

public boolean isValidFieldElement(BigInteger x)
{
return x != null && x.signum() >= 0 && x.compareTo(getField().getCharacteristic()) < 0;
return x != null && x.signum() >= 0 && x.compareTo(this.getField().getCharacteristic()) < 0;
}

protected ECPoint decompressPoint(int yTilde, BigInteger X1)
{
ECFieldElement x = this.fromBigInteger(X1);
ECFieldElement rhs = x.square().add(a).multiply(x).add(b);
ECFieldElement rhs = x.square().add(this.a).multiply(x).add(this.b);
ECFieldElement y = rhs.sqrt();

/*
Expand All @@ -537,7 +537,7 @@ protected ECPoint decompressPoint(int yTilde, BigInteger X1)
*/
public static class Fp extends AbstractFp
{
private static final int FP_DEFAULT_COORDS = COORD_JACOBIAN_MODIFIED;
private static final int FP_DEFAULT_COORDS = ECCurve.COORD_JACOBIAN_MODIFIED;

BigInteger q, r;
ECPoint.Fp infinity;
Expand Down Expand Up @@ -584,17 +584,17 @@ protected Fp(BigInteger q, BigInteger r, ECFieldElement a, ECFieldElement b, Big

protected ECCurve cloneCurve()
{
return new Fp(q, r, a, b, order, cofactor);
return new Fp(this.q, this.r, this.a, this.b, this.order, this.cofactor);
}

public boolean supportsCoordinateSystem(int coord)
{
switch (coord)
{
case COORD_AFFINE:
case COORD_HOMOGENEOUS:
case COORD_JACOBIAN:
case COORD_JACOBIAN_MODIFIED:
case ECCurve.COORD_AFFINE:
case ECCurve.COORD_HOMOGENEOUS:
case ECCurve.COORD_JACOBIAN:
case ECCurve.COORD_JACOBIAN_MODIFIED:
return true;
default:
return false;
Expand Down Expand Up @@ -628,13 +628,13 @@ protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElem

public ECPoint importPoint(ECPoint p)
{
if (this != p.getCurve() && this.getCoordinateSystem() == COORD_JACOBIAN && !p.isInfinity())
if (this != p.getCurve() && this.getCoordinateSystem() == ECCurve.COORD_JACOBIAN && !p.isInfinity())
{
switch (p.getCurve().getCoordinateSystem())
{
case COORD_JACOBIAN:
case COORD_JACOBIAN_CHUDNOVSKY:
case COORD_JACOBIAN_MODIFIED:
case ECCurve.COORD_JACOBIAN:
case ECCurve.COORD_JACOBIAN_CHUDNOVSKY:
case ECCurve.COORD_JACOBIAN_MODIFIED:
return new ECPoint.Fp(this,
fromBigInteger(p.x.toBigInteger()),
fromBigInteger(p.y.toBigInteger()),
Expand Down Expand Up @@ -705,7 +705,7 @@ protected AbstractF2m(int m, int k1, int k2, int k3)

public boolean isValidFieldElement(BigInteger x)
{
return x != null && x.signum() >= 0 && x.bitLength() <= getFieldSize();
return x != null && x.signum() >= 0 && x.bitLength() <= this.getFieldSize();
}

public ECPoint createPoint(BigInteger x, BigInteger y, boolean withCompression)
Expand All @@ -716,8 +716,8 @@ public ECPoint createPoint(BigInteger x, BigInteger y, boolean withCompression)

switch (coord)
{
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
case ECCurve.COORD_LAMBDA_AFFINE:
case ECCurve.COORD_LAMBDA_PROJECTIVE:
{
if (X.isZero())
{
Expand Down Expand Up @@ -764,14 +764,14 @@ public ECPoint createPoint(BigInteger x, BigInteger y, boolean withCompression)
*/
protected ECPoint decompressPoint(int yTilde, BigInteger X1)
{
ECFieldElement x = fromBigInteger(X1), y = null;
ECFieldElement x = this.fromBigInteger(X1), y = null;
if (x.isZero())
{
y = getB().sqrt();
y = this.getB().sqrt();
}
else
{
ECFieldElement beta = x.square().invert().multiply(getB()).add(getA()).add(x);
ECFieldElement beta = x.square().invert().multiply(this.getB()).add(this.getA()).add(x);
ECFieldElement z = solveQuadraticEquation(beta);
if (z != null)
{
Expand All @@ -782,8 +782,8 @@ protected ECPoint decompressPoint(int yTilde, BigInteger X1)

switch (this.getCoordinateSystem())
{
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
case ECCurve.COORD_LAMBDA_AFFINE:
case ECCurve.COORD_LAMBDA_PROJECTIVE:
{
y = z.add(x);
break;
Expand Down Expand Up @@ -821,13 +821,13 @@ private ECFieldElement solveQuadraticEquation(ECFieldElement beta)
return beta;
}

ECFieldElement gamma, z, zeroElement = fromBigInteger(ECConstants.ZERO);
ECFieldElement gamma, z, zeroElement = this.fromBigInteger(ECConstants.ZERO);

int m = getFieldSize();
int m = this.getFieldSize();
Random rand = new Random();
do
{
ECFieldElement t = fromBigInteger(new BigInteger(m, rand));
ECFieldElement t = this.fromBigInteger(new BigInteger(m, rand));
z = zeroElement;
ECFieldElement w = beta;
for (int i = 1; i < m; i++)
Expand Down Expand Up @@ -867,7 +867,7 @@ synchronized BigInteger[] getSi()
*/
public boolean isKoblitz()
{
return order != null && cofactor != null && b.isOne() && (a.isZero() || a.isOne());
return this.order != null && this.cofactor != null && this.b.isOne() && (this.a.isZero() || this.a.isOne());
}
}

Expand All @@ -877,7 +877,7 @@ public boolean isKoblitz()
*/
public static class F2m extends AbstractF2m
{
private static final int F2M_DEFAULT_COORDS = COORD_LAMBDA_PROJECTIVE;
private static final int F2M_DEFAULT_COORDS = ECCurve.COORD_LAMBDA_PROJECTIVE;

/**
* The exponent <code>m</code> of <code>F<sub>2<sup>m</sup></sub></code>.
Expand Down Expand Up @@ -1064,16 +1064,16 @@ protected F2m(int m, int k1, int k2, int k3, ECFieldElement a, ECFieldElement b,

protected ECCurve cloneCurve()
{
return new F2m(m, k1, k2, k3, a, b, order, cofactor);
return new F2m(this.m, this.k1, this.k2, this.k3, this.a, this.b, this.order, this.cofactor);
}

public boolean supportsCoordinateSystem(int coord)
{
switch (coord)
{
case COORD_AFFINE:
case COORD_HOMOGENEOUS:
case COORD_LAMBDA_PROJECTIVE:
case ECCurve.COORD_AFFINE:
case ECCurve.COORD_HOMOGENEOUS:
case ECCurve.COORD_LAMBDA_PROJECTIVE:
return true;
default:
return false;
Expand Down Expand Up @@ -1150,15 +1150,15 @@ public int getK3()
*/
public BigInteger getN()
{
return order;
return this.order;
}

/**
* @deprecated use {@link #getCofactor()} instead
*/
public BigInteger getH()
{
return cofactor;
return this.cofactor;
}
}
}
Loading

0 comments on commit e8705b5

Please sign in to comment.