Search in sources :

Example 6 with ECPoint

use of java.security.spec.ECPoint in project j2objc by google.

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)

Example 7 with ECPoint

use of java.security.spec.ECPoint in project j2objc by google.

the class ECPointTest 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() {
    ECPoint f = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
    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());
    // the same for POINT_INFINITY
    hc = ECPoint.POINT_INFINITY.hashCode();
    assertTrue(hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode());
}
Also used : ECPoint(java.security.spec.ECPoint) ECPoint(java.security.spec.ECPoint)

Example 8 with ECPoint

use of java.security.spec.ECPoint in project j2objc by google.

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 9 with ECPoint

use of java.security.spec.ECPoint in project j2objc by google.

the class ECPointTest method testHashCode02.

/**
     * Test #2 for <code>hashCode()</code> method.<br>
     *
     * Assertion: must return the same value if invoked
     * on equal (according to the <code>equals(Object)</code> method) objects.
     */
public final void testHashCode02() {
    ECPoint p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
    ECPoint p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
    assertEquals(p1.hashCode(), p2.hashCode());
}
Also used : ECPoint(java.security.spec.ECPoint)

Example 10 with ECPoint

use of java.security.spec.ECPoint in project j2objc by google.

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)

Aggregations

ECPoint (java.security.spec.ECPoint)38 ECParameterSpec (java.security.spec.ECParameterSpec)20 EllipticCurve (java.security.spec.EllipticCurve)20 BigInteger (java.math.BigInteger)15 ECFieldF2m (java.security.spec.ECFieldF2m)8 ECFieldFp (java.security.spec.ECFieldFp)6 ECPublicKeySpec (java.security.spec.ECPublicKeySpec)6 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)6 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)6 ECNamedCurveSpec (org.bouncycastle.jce.spec.ECNamedCurveSpec)6 ECField (java.security.spec.ECField)4 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)4 IOException (java.io.IOException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 ECPublicKey (java.security.interfaces.ECPublicKey)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