Search in sources :

Example 36 with ECFieldF2m

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

Example 37 with ECFieldF2m

use of java.security.spec.ECFieldF2m 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);
}
Also used : EllipticCurve(java.security.spec.EllipticCurve) ECParameterSpec(java.security.spec.ECParameterSpec) ECFieldF2m(java.security.spec.ECFieldF2m) ECPoint(java.security.spec.ECPoint) ECPublicKeySpec(java.security.spec.ECPublicKeySpec)

Example 38 with ECFieldF2m

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

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

Example 39 with ECFieldF2m

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

the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04.

/**
     * 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 testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04() {
    // 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);
    byte[] seed = new byte[24];
    // perform test case 1
    try {
        new EllipticCurve(f, a, b, seed);
        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);
    seed = new byte[24];
    // perform test case 2
    try {
        new EllipticCurve(f, a, b, seed);
        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);
    seed = new byte[24];
    // perform test case 3
    try {
        new EllipticCurve(f, a, b, seed);
        fail("#3: Expected IAE not thrown");
    } catch (IllegalArgumentException ok) {
    }
}
Also used : EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Example 40 with ECFieldF2m

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

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) {
    }
}
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