Search in sources :

Example 26 with ECPoint

use of java.security.spec.ECPoint 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 27 with ECPoint

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

the class ECParameterSpecTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    curve = new EllipticCurve(new ECFieldF2m(2), BigInteger.valueOf(1), BigInteger.valueOf(1));
    ecpoint = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
    ecps = new ECParameterSpec(curve, ecpoint, BigInteger.valueOf(1), 1);
}
Also used : EllipticCurve(java.security.spec.EllipticCurve) ECParameterSpec(java.security.spec.ECParameterSpec) ECFieldF2m(java.security.spec.ECFieldF2m) ECPoint(java.security.spec.ECPoint)

Example 28 with ECPoint

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

the class ECPointTest method testEqualsObject02.

/**
     * Test #2 for <code>equals(Object other)</code> method<br>
     * Assertion: return false if this and other objects are not equal<br>
     * Test preconditions: see test comments<br>
     * Expected: all objects in this test must be not equal
     */
public final void testEqualsObject02() {
    // test case 1: must be not equal to null
    ECPoint p2 = null, p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
    assertFalse(p1.equals(p2));
    // test case 2: not equal objects - x
    p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
    p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
    assertFalse(p1.equals(p2) || p2.equals(p1));
    // test case 3: not equal objects - y
    p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
    p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
    assertFalse(p1.equals(p2) || p2.equals(p1));
    // test case 4: not equal - some point and POINT_INFINITY
    p1 = ECPoint.POINT_INFINITY;
    p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
    assertFalse(p1.equals(p2) || p2.equals(p1));
}
Also used : ECPoint(java.security.spec.ECPoint)

Example 29 with ECPoint

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

the class ECPointTest method testGetAffineX01.

/**
     * Test #1 for <code>getAffineX()</code> method<br>
     * Assertion: returns affine <code>x</code> coordinate<br>
     * Test preconditions: <code>ECPoint</code> instance
     * created using valid parameters<br>
     * Expected: must return affine <code>x</code> coordinate
     * which is equal to the one passed to the constructor;
     * (both must refer the same object)
     */
public final void testGetAffineX01() {
    BigInteger x = BigInteger.valueOf(-23456L);
    ECPoint p = new ECPoint(x, BigInteger.valueOf(23456L));
    BigInteger xRet = p.getAffineX();
    assertEquals(x, xRet);
    assertSame(x, xRet);
}
Also used : BigInteger(java.math.BigInteger) ECPoint(java.security.spec.ECPoint)

Example 30 with ECPoint

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

the class ECPointTest method testEqualsObject01.

/**
     * Test #1 for <code>equals(Object other)</code> method<br>
     * Assertion: return true if this and other objects are equal<br>
     * Test preconditions: see test comments<br>
     * Expected: all objects in this test must be equal
     */
public final void testEqualsObject01() {
    // test case 1: must be equal to itself
    ECPoint p2 = null, p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
    assertTrue(p1.equals(p1));
    // test case 2: equal objects
    p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
    p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
    assertTrue(p1.equals(p2) && p2.equals(p1));
    // test case 3: equal POINT_INFINITY object(s)
    p1 = ECPoint.POINT_INFINITY;
    p2 = ECPoint.POINT_INFINITY;
    assertTrue(p1.equals(p2) && p2.equals(p1));
}
Also used : ECPoint(java.security.spec.ECPoint)

Aggregations

ECPoint (java.security.spec.ECPoint)39 ECParameterSpec (java.security.spec.ECParameterSpec)21 EllipticCurve (java.security.spec.EllipticCurve)20 BigInteger (java.math.BigInteger)15 ECFieldF2m (java.security.spec.ECFieldF2m)8 ECPublicKeySpec (java.security.spec.ECPublicKeySpec)7 ECFieldFp (java.security.spec.ECFieldFp)6 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)6 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)6 ECNamedCurveSpec (org.bouncycastle.jce.spec.ECNamedCurveSpec)6 ECPublicKey (java.security.interfaces.ECPublicKey)4 ECField (java.security.spec.ECField)4 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)4 IOException (java.io.IOException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 ECPrivateKeySpec (java.security.spec.ECPrivateKeySpec)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)3 DERBitString (org.bouncycastle.asn1.DERBitString)3 DERInteger (org.bouncycastle.asn1.DERInteger)3 DEROctetString (org.bouncycastle.asn1.DEROctetString)3