use of java.security.spec.EllipticCurve in project j2objc by google.
the class EllipticCurveTest method testHashCode01.
/**
* Test #1 for <code>hashCode()</code> method.<br>
*
* Assertion: must return the same value if invoked
* repeatedly on the same object.
*/
public final void testHashCode01() {
int hc = 0;
EllipticCurve f = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)), BigInteger.ONE, BigInteger.valueOf(19L), new byte[24]);
hc = f.hashCode();
assertTrue(hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode());
}
use of java.security.spec.EllipticCurve in project robovm by robovm.
the class ECNamedCurveSpec method convertCurve.
private static EllipticCurve convertCurve(ECCurve curve, byte[] seed) {
if (curve instanceof ECCurve.Fp) {
return new EllipticCurve(new ECFieldFp(((ECCurve.Fp) curve).getQ()), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
} else {
ECCurve.F2m curveF2m = (ECCurve.F2m) curve;
int[] ks;
if (curveF2m.isTrinomial()) {
ks = new int[] { curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
} else {
ks = new int[] { curveF2m.getK3(), curveF2m.getK2(), curveF2m.getK1() };
return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
}
}
}
use of java.security.spec.EllipticCurve in project robovm by robovm.
the class EllipticCurveTest method testGetB.
/**
* Test for <code>getB()</code> method<br>
* Assertion: returns coefficient <code>b</code><br>
* Test preconditions: <code>ECFieldF2m</code> instance
* created using valid parameters<br>
* Expected: must return coefficient <code>b</code> which is equal
* to the one passed to the constructor; (both must refer
* the same object)
*/
public final void testGetB() {
ECFieldF2m f = new ECFieldF2m(5);
BigInteger a = BigInteger.valueOf(5L);
BigInteger b = BigInteger.valueOf(19L);
EllipticCurve c = new EllipticCurve(f, a, b);
assertEquals(b, c.getB());
assertSame(b, c.getB());
}
use of java.security.spec.EllipticCurve in project robovm by robovm.
the class EllipticCurveTest method testGetSeed01.
/**
* Test #1 for <code>getSeed()</code> method<br>
* Assertion: returns <code>seed</code><br>
* Test preconditions: <code>ECFieldF2m</code> instance
* created using valid parameters<br>
* Expected: must return <code>seed</code> which is equal
* to the one passed to the constructor
*/
public final void testGetSeed01() {
ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
BigInteger a = BigInteger.ONE;
BigInteger b = BigInteger.valueOf(19L);
byte[] seed = new byte[24];
EllipticCurve c = new EllipticCurve(f, a, b, seed);
byte[] seedRet = c.getSeed();
assertNotNull(seedRet);
assertTrue(Arrays.equals(seed, seedRet));
}
use of java.security.spec.EllipticCurve in project robovm by robovm.
the class ECPublicKeySpecTest method setUp.
protected void setUp() throws Exception {
super.setUp();
ECPoint ecpoint = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
EllipticCurve curve = new EllipticCurve(new ECFieldF2m(2), BigInteger.valueOf(1), BigInteger.valueOf(1));
w = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
params = new ECParameterSpec(curve, ecpoint, BigInteger.valueOf(1), 1);
ecpks = new ECPublicKeySpec(w, params);
}
Aggregations