Search in sources :

Example 41 with ECFieldF2m

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

the class ECFieldF2mTest 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() {
    ECFieldF2m f = new ECFieldF2m(2000);
    int 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());
}
Also used : ECFieldF2m(java.security.spec.ECFieldF2m)

Example 42 with ECFieldF2m

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

the class ECFieldF2mTest method testHashCode02.

/**
     * Test #2 for <code>hashCode()</code> method.<br>
     *
     * Assertion: must return the same value if invoked
     * repeatedly on the same object.
     */
public final void testHashCode02() {
    ECFieldF2m f = new ECFieldF2m(2000, new int[] { 981, 2, 1 });
    int 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());
}
Also used : ECFieldF2m(java.security.spec.ECFieldF2m)

Example 43 with ECFieldF2m

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

the class ECFieldF2mTest method testIsStatePreserved01.

/**
     * Tests that object state is preserved against modifications
     * through array reference passed to the constructor.
     */
public final void testIsStatePreserved01() {
    // reference array
    int[] a = new int[] { 367 };
    // reference array copy
    int[] aCopy = a.clone();
    // create obj using copy
    ECFieldF2m f = new ECFieldF2m(1999, aCopy);
    // modify copy
    aCopy[0] = 5;
    // compare reference with returned array
    assertTrue(Arrays.equals(a, f.getMidTermsOfReductionPolynomial()));
}
Also used : ECFieldF2m(java.security.spec.ECFieldF2m)

Example 44 with ECFieldF2m

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

the class ECFieldF2mTest method testGetReductionPolynomial01.

/**
     * Test #1 for <code>getReductionPolynomial()</code> method.<br>
     *
     * Assertion: returns reduction polynomial
     */
public final void testGetReductionPolynomial01() {
    BigInteger rp = BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000);
    assertTrue(new ECFieldF2m(2000, rp).getReductionPolynomial().equals(rp));
}
Also used : BigInteger(java.math.BigInteger) ECFieldF2m(java.security.spec.ECFieldF2m)

Example 45 with ECFieldF2m

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

the class ECFieldF2mTest method testGetMidTermsOfReductionPolynomial01.

/**
     * Test #1 for <code>getMidTermsOfReductionPolynomial()</code> method.<br>
     *
     * Assertion: returns mid terms of reduction polynomial
     */
public final void testGetMidTermsOfReductionPolynomial01() {
    int[] a = new int[] { 981, 2, 1 };
    int[] b = new ECFieldF2m(2000, BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000)).getMidTermsOfReductionPolynomial();
    assertTrue(Arrays.equals(a, b));
}
Also used : 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