use of java.security.spec.EllipticCurve in project j2objc by google.
the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigInteger04.
/**
* Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
* constructor<br>
* Assertion: throws <code>IllegalArgumentException</code> if
* <code>a</code> or <code>b</code> is not <code>null</code> and not in
* the <code>field</code><br>
* Test preconditions: pass <code>a</code>, <code>b</code> which are
* not in the <code>field</code> of type <code>ECFieldF2m</code><br>
* Expected: must throw <code>IllegalArgumentException</code>
*/
public final void testEllipticCurveECFieldBigIntegerBigInteger04() {
// test case 1 parameters set,
// a is not in field
ECFieldF2m f = new ECFieldF2m(5);
BigInteger a = BigInteger.valueOf(32L);
BigInteger b = BigInteger.valueOf(19L);
// perform test case 1
try {
new EllipticCurve(f, a, b);
fail("#1: Expected IAE not thrown");
} catch (IllegalArgumentException ok) {
}
// test case 2 parameters set,
// b is not in field
f = new ECFieldF2m(5);
a = BigInteger.valueOf(19L);
b = BigInteger.valueOf(32L);
// perform test case 2
try {
new EllipticCurve(f, a, b);
fail("#2: Expected IAE not thrown");
} catch (IllegalArgumentException ok) {
}
// test case 3 parameters set,
// both a and b are not in field
f = new ECFieldF2m(5);
a = BigInteger.valueOf(32L);
b = BigInteger.valueOf(43L);
// perform test case 3
try {
new EllipticCurve(f, a, b);
fail("#3: Expected IAE not thrown");
} catch (IllegalArgumentException ok) {
}
}
use of java.security.spec.EllipticCurve in project j2objc by google.
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);
}
use of java.security.spec.EllipticCurve in project j2objc by google.
the class EllipticCurveTest method testGetSeed03.
/**
* Test #3 for <code>getSeed()</code> method<br>
* Assertion: returned array is copied to prevent subsequent modification<br>
* Test preconditions: <code>ECFieldF2m</code> instance
* created using valid parameters<br>
* Expected: repeated method calls must return different refs
*/
public final void testGetSeed03() {
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);
c.getSeed();
assertNotSame(c.getSeed(), c.getSeed());
}
use of java.security.spec.EllipticCurve in project j2objc by google.
the class EllipticCurveTest method testGetA.
/**
* Test for <code>getA()</code> method<br>
* Assertion: returns coefficient <code>a</code><br>
* Test preconditions: <code>ECFieldF2m</code> instance
* created using valid parameters<br>
* Expected: must return coefficient <code>a</code> which is equal
* to the one passed to the constructor; (both must refer
* the same object)
*/
public final void testGetA() {
ECFieldF2m f = new ECFieldF2m(5);
BigInteger a = BigInteger.valueOf(5L);
BigInteger b = BigInteger.valueOf(19L);
EllipticCurve c = new EllipticCurve(f, a, b);
assertEquals(a, c.getA());
assertSame(a, c.getA());
}
use of java.security.spec.EllipticCurve in project j2objc by google.
the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigIntegerbyteArray05.
/**
* Test #5 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
* constructor<br>
* Assertion: array <code>seed</code> is copied to prevent subsequent modification<br>
* Test preconditions: pass <code>seed</code> to the ctor then modify it<br>
* Expected: getSeed() must return unmodified array
*/
public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray05() {
ECFieldF2m f = new ECFieldF2m(5);
BigInteger a = BigInteger.valueOf(0L);
BigInteger b = BigInteger.valueOf(19L);
byte[] seed = new byte[24];
byte[] seedCopy = seed.clone();
EllipticCurve c = new EllipticCurve(f, a, b, seedCopy);
// modify array passed
seedCopy[0] = (byte) 1;
// check that above modification did not changed
// internal state of test object
assertTrue(Arrays.equals(seed, c.getSeed()));
}
Aggregations