Search in sources :

Example 36 with ECFieldFp

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

the class EllipticCurveTest method testGetSeed04.

/**
     * java.security.spec.EllipticCurve#getSeed()
     * Assertion: null if not specified
     */
public final void testGetSeed04() {
    //Regression for HARMONY-732
    ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
    BigInteger a = BigInteger.ONE;
    assertNull(new EllipticCurve(f, a, a).getSeed());
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger)

Example 37 with ECFieldFp

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

the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigInteger02.

/**
     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
     * constructor<br>
     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
     * <code>a</code> or <code>b</code> is <code>null</code><br>
     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
     * Expected: must throw <code>NullPointerException</code>
     */
public final void testEllipticCurveECFieldBigIntegerBigInteger02() {
    // test case 1 parameters set
    ECFieldFp f = null;
    BigInteger a = BigInteger.ONE;
    BigInteger b = BigInteger.valueOf(19L);
    // perform test case 1
    try {
        new EllipticCurve(f, a, b);
        fail("#1: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
    // test case 2 parameters set,
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = null;
    b = BigInteger.valueOf(19L);
    // perform test case 2
    try {
        new EllipticCurve(f, a, b);
        fail("#2: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
    // test case 3 parameters set,
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = BigInteger.ONE;
    b = null;
    // perform test case 3
    try {
        new EllipticCurve(f, a, b);
        fail("#3: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger)

Example 38 with ECFieldFp

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

the class EllipticCurveTest method testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02.

/**
     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
     * constructor<br>
     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
     * <code>a</code> or <code>b</code> is <code>null</code><br>
     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
     * Expected: must throw <code>NullPointerException</code>
     */
public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02() {
    // test case 1 parameters set
    ECFieldFp f = null;
    BigInteger a = BigInteger.ONE;
    BigInteger b = BigInteger.valueOf(19L);
    byte[] seed = new byte[24];
    // perform test case 1
    try {
        new EllipticCurve(f, a, b, seed);
        fail("#1: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
    // test case 2 parameters set,
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = null;
    b = BigInteger.valueOf(19L);
    seed = new byte[24];
    // perform test case 2
    try {
        new EllipticCurve(f, a, b, seed);
        fail("#2: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
    // test case 3 parameters set,
    f = new ECFieldFp(BigInteger.valueOf(23L));
    a = BigInteger.ONE;
    b = null;
    seed = new byte[24];
    // perform test case 2
    try {
        new EllipticCurve(f, a, b, seed);
        fail("#3: Expected NPE not thrown");
    } catch (NullPointerException ok) {
    }
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger)

Example 39 with ECFieldFp

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

the class EllipticCurveTest method testGetSeed02.

/**
     * Test #2 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; <code>getSeed()</code>
     * called and then returned array modified<br>
     * Expected: internal state must not be affected by the modification
     */
public final void testGetSeed02() {
    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.clone());
    byte[] seedRet = c.getSeed();
    // modify returned array
    seedRet[0] = (byte) 1;
    // check that above modification did not changed
    // internal state of test object
    assertTrue(Arrays.equals(seed, c.getSeed()));
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) EllipticCurve(java.security.spec.EllipticCurve) BigInteger(java.math.BigInteger)

Example 40 with ECFieldFp

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

the class ECFieldFpTest method testGetP.

/**
     * Test for <code>getP()</code> method.<br>
     *
     * Assertion: returns prime
     */
public final void testGetP() {
    BigInteger p = BigInteger.valueOf(23L);
    assertTrue(p.equals(new ECFieldFp(p).getP()));
}
Also used : ECFieldFp(java.security.spec.ECFieldFp) BigInteger(java.math.BigInteger)

Aggregations

ECFieldFp (java.security.spec.ECFieldFp)43 EllipticCurve (java.security.spec.EllipticCurve)35 BigInteger (java.math.BigInteger)31 ECFieldF2m (java.security.spec.ECFieldF2m)12 ECPoint (java.security.spec.ECPoint)8 ECField (java.security.spec.ECField)6 ECCurve (org.bouncycastle.math.ec.ECCurve)4 ECParameterSpec (java.security.spec.ECParameterSpec)3 GeneralSecurityException (java.security.GeneralSecurityException)2 InvalidParameterException (java.security.InvalidParameterException)1