Search in sources :

Example 16 with ECFieldF2m

use of java.security.spec.ECFieldF2m in project robovm by robovm.

the class ECPrivateKeySpecTest 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));
    s = BigInteger.valueOf(1);
    ecparams = new ECParameterSpec(curve, ecpoint, BigInteger.valueOf(1), 1);
    ecpks = new ECPrivateKeySpec(s, ecparams);
}
Also used : ECPrivateKeySpec(java.security.spec.ECPrivateKeySpec) EllipticCurve(java.security.spec.EllipticCurve) ECParameterSpec(java.security.spec.ECParameterSpec) ECFieldF2m(java.security.spec.ECFieldF2m) ECPoint(java.security.spec.ECPoint)

Example 17 with ECFieldF2m

use of java.security.spec.ECFieldF2m in project robovm by robovm.

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()));
}
Also used : EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Example 18 with ECFieldF2m

use of java.security.spec.ECFieldF2m in project robovm by robovm.

the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigInteger01.

/**
     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
     * constructor<br>
     * Assertion: creates instance of EllipticCurve<br>
     * Test preconditions: valid parameters passed, field type is ECFieldFp<br>
     * Expected: must pass without any exceptions
     */
public final void testEllipticCurveECFieldBigIntegerBigInteger01() {
    // test case 1 parameters set
    ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
    BigInteger a = BigInteger.ONE;
    BigInteger b = BigInteger.valueOf(19L);
    // perform test case 1
    new EllipticCurve(f, a, b);
    // test case 2 parameters set
    ECFieldF2m f1 = new ECFieldF2m(5);
    a = BigInteger.ZERO;
    b = BigInteger.valueOf(23L);
    // perform test case 2
    new EllipticCurve(f1, a, b);
    // test case 3 parameters set,
    // the seed parameter may be null
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = BigInteger.ONE;
    b = BigInteger.valueOf(19L);
    // perform test case 3
    new EllipticCurve(f, a, b);
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Example 19 with ECFieldF2m

use of java.security.spec.ECFieldF2m in project robovm by robovm.

the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01.

/**
     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
     * constructor<br>
     * Assertion: creates instance of EllipticCurve<br>
     * Test preconditions: valid parameters passed<br>
     * Expected: must pass without any exceptions
     */
public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01() {
    // test case 1 parameters set
    ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
    BigInteger a = BigInteger.ONE;
    BigInteger b = BigInteger.valueOf(19L);
    byte[] seed = new byte[24];
    // perform test case 1
    new EllipticCurve(f, a, b, seed);
    // test case 2 parameters set
    ECFieldF2m f1 = new ECFieldF2m(5);
    a = BigInteger.ZERO;
    b = BigInteger.valueOf(23L);
    // perform test case 2
    new EllipticCurve(f1, a, b, seed);
    // test case 3 parameters set,
    // the seed parameter may be null
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = BigInteger.ONE;
    b = BigInteger.valueOf(19L);
    seed = null;
    // perform test case 3
    new EllipticCurve(f, a, b, seed);
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Example 20 with ECFieldF2m

use of java.security.spec.ECFieldF2m in project robovm by robovm.

the class EllipticCurveTest method testGetField.

/**
     * Test for <code>getField()</code> method<br>
     * Assertion: returns <code>field</code><br>
     * Test preconditions: <code>ECFieldF2m</code> instance
     * created using valid parameters<br>
     * Expected: must return <code>field</code> which is equal
     * to the one passed to the constructor; (both must refer
     * the same object)
     */
public final void testGetField() {
    ECFieldF2m f = new ECFieldF2m(5);
    BigInteger a = BigInteger.valueOf(5L);
    BigInteger b = BigInteger.valueOf(19L);
    EllipticCurve c = new EllipticCurve(f, a, b);
    assertEquals(f, c.getField());
    assertSame(f, c.getField());
}
Also used : EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Aggregations

ECFieldF2m (java.security.spec.ECFieldF2m)50 EllipticCurve (java.security.spec.EllipticCurve)28 BigInteger (java.math.BigInteger)22 ECFieldFp (java.security.spec.ECFieldFp)12 ECPoint (java.security.spec.ECPoint)10 ECParameterSpec (java.security.spec.ECParameterSpec)7 ECField (java.security.spec.ECField)4 ECCurve (org.bouncycastle.math.ec.ECCurve)4 ECPrivateKeySpec (java.security.spec.ECPrivateKeySpec)2 ECPublicKeySpec (java.security.spec.ECPublicKeySpec)2 InvalidParameterException (java.security.InvalidParameterException)1