Examples of ECFieldFp


Examples of java.security.spec.ECFieldFp

     * Test for <code>getFieldSize()()</code> method.<br>
     *
     * Assertion: returns field size in bits which is prime size
     */
    public final void testGetFieldSize() {
        assertEquals(5, new ECFieldFp(BigInteger.valueOf(23L)).getFieldSize());
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     *
     * Assertion: returns prime
     */
    public final void testGetP() {
        BigInteger p = BigInteger.valueOf(23L);
        assertTrue(p.equals(new ECFieldFp(p).getP()));
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Test #1 for <code>equals()</code> method.<br>
     *
     * Assertion: object equals to itself.
     */
    public final void testEqualsObject01() {
        ECFieldFp obj = new ECFieldFp(BigInteger.valueOf(23L));
        assertTrue(obj.equals(obj));
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Test #2 for <code>equals(Object obj)</code> method.<br>
     *
     * Assertion: returns false if <code>obj</code> is <code>null</code>
     */
    public final void testEqualsObject02() {
        assertFalse(new ECFieldFp(BigInteger.valueOf(23L)).equals(null));
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     *
     * Assertion: returns false if <code>obj</code>
     * is not instance of <code>ECFieldFp</code>
     */
    public final void testEqualsObject03() {
        assertFalse(new ECFieldFp(BigInteger.valueOf(23L)).equals(new Object()));
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Test #4 for <code>equals()</code> method.<br>
     *
     * Assertion: true if prime values match.
     */
    public final void testEqualsObject04() {
        assertTrue(new ECFieldFp(BigInteger.valueOf(23L)).equals(
                   new ECFieldFp(BigInteger.valueOf(23L))));
    }
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Test preconditions: valid parameters passed<br>
     * Expected: must pass without any exceptions
     */
    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01() {
        // test case 1 parameters set
        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
        BigInteger a = BigInteger.ONE;
        BigInteger b = BigInteger.valueOf(19L);
        byte[] seed = new byte[24];
        // perform test case 1
        new EllipticCurve(f, a, b, seed);

        // test case 2 parameters set
        ECFieldF2m f1 = new ECFieldF2m(5);
        a = BigInteger.ZERO;
        b = BigInteger.valueOf(23L);
        // perform test case 2
        new EllipticCurve(f1, a, b, seed);

        // test case 3 parameters set,
        // the seed parameter may be null
        f = new ECFieldFp(BigInteger.valueOf(23L));
        a = BigInteger.ONE;
        b = BigInteger.valueOf(19L);
        seed = null;
        // perform test case 3
        new EllipticCurve(f, a, b, seed);
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * 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 {
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Expected: must throw <code>IllegalArgumentException</code>
     */
    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray03() {
        // test case 1 parameters set,
        // a is not in field
        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
        BigInteger a = BigInteger.valueOf(24L);
        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 1.1 parameters set,
        // b is not in field
        f = new ECFieldFp(BigInteger.valueOf(23L));
        a = BigInteger.valueOf(1L);
        b = BigInteger.valueOf(23L);
        seed = new byte[24];
        // perform test case 1.1
        try {
            new EllipticCurve(f, a, b, seed);
            fail("#1.1: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {}

        // test case 2 parameters set,
        // b is not in field
        f = new ECFieldFp(BigInteger.valueOf(23L));
        a = BigInteger.valueOf(19L);
        b = BigInteger.valueOf(24L);
        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 ECFieldFp(BigInteger.valueOf(23L));
        a = BigInteger.valueOf(25L);
        b = BigInteger.valueOf(240L);
        seed = new byte[24];
        // perform test case 3
        try {
View Full Code Here

Examples of java.security.spec.ECFieldFp

     * Test preconditions: valid parameters passed, field type is ECFieldFp<br>
     * Expected: must pass without any exceptions
     */
    public final void testEllipticCurveECFieldBigIntegerBigInteger01() {
        // test case 1 parameters set
        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
        BigInteger a = BigInteger.ONE;
        BigInteger b = BigInteger.valueOf(19L);
        // perform test case 1
        new EllipticCurve(f, a, b);

        // test case 2 parameters set
        ECFieldF2m f1 = new ECFieldF2m(5);
        a = BigInteger.ZERO;
        b = BigInteger.valueOf(23L);
        // perform test case 2
        new EllipticCurve(f1, a, b);

        // test case 3 parameters set,
        // the seed parameter may be null
        f = new ECFieldFp(BigInteger.valueOf(23L));
        a = BigInteger.ONE;
        b = BigInteger.valueOf(19L);
        // perform test case 3
        new EllipticCurve(f, a, b);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.