Package java.security.spec

Examples of java.security.spec.ECPoint


     * which is equal to the one passed to the constructor;
     * (both must refer the same object)
     */
    public final void testGetAffineY01() {
        BigInteger y =  BigInteger.valueOf(23456L);
        ECPoint p = new ECPoint(BigInteger.valueOf(-23456L), y);
        BigInteger yRet = p.getAffineY();
        assertEquals(y, yRet);
        assertSame(y, yRet);
    }
View Full Code Here


     * 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));
    }
View Full Code Here

     * 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));
    }
View Full Code Here

     *
     * 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() &&
View Full Code Here

     *
     * 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());
    }
View Full Code Here

    private ECParameterSpec createSpec(EllipticCurve ellipticCurve, ECDomainParameters dp)
    {
        return new ECParameterSpec(
                ellipticCurve,
                new ECPoint(
                        dp.getG().getX().toBigInteger(),
                        dp.getG().getY().toBigInteger()),
                        dp.getN(),
                        dp.getH().intValue());
    }
View Full Code Here

            }

            ecSpec = new ECNamedCurveSpec(
                    ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()),
                    ellipticCurve,
                    new ECPoint(
                            spec.getG().getX().toBigInteger(),
                            spec.getG().getY().toBigInteger()),
                            spec.getN(), spec.getH());

        }
        else
        {
            X962Parameters          params = new X962Parameters((DERObject)info.getAlgorithmId().getParameters());
            ECCurve                 curve;
            EllipticCurve           ellipticCurve;
           
            if (params.isNamedCurve())
            {
                DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
                X9ECParameters      ecP = ECUtil.getNamedCurveByOid(oid);

                curve = ecP.getCurve();
                ellipticCurve = EC5Util.convertCurve(curve, ecP.getSeed());

                ecSpec = new ECNamedCurveSpec(
                        ECUtil.getCurveName(oid),
                        ellipticCurve,
                        new ECPoint(
                                ecP.getG().getX().toBigInteger(),
                                ecP.getG().getY().toBigInteger()),
                        ecP.getN(),
                        ecP.getH());
            }
            else if (params.isImplicitlyCA())
            {
                ecSpec = null;
                curve = ProviderUtil.getEcImplicitlyCa().getCurve();
            }
            else
            {
                X9ECParameters          ecP = new X9ECParameters((ASN1Sequence)params.getParameters());
               
                curve = ecP.getCurve();
                ellipticCurve = EC5Util.convertCurve(curve, ecP.getSeed());

                this.ecSpec = new ECParameterSpec(
                        ellipticCurve,
                        new ECPoint(
                                ecP.getG().getX().toBigInteger(),
                                ecP.getG().getY().toBigInteger()),
                        ecP.getN(),
                        ecP.getH().intValue());
            }
View Full Code Here

        return EC5Util.convertSpec(ecSpec, withCompression);
    }

    public ECPoint getW()
    {
        return new ECPoint(q.getX().toBigInteger(), q.getY().toBigInteger());
    }
View Full Code Here

        ECCurve curve = spec.getParams().getCurve();
        EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
       
        this.ecSpec = new ECParameterSpec(
                                ellipticCurve,
                                new ECPoint(
                                        spec.getParams().getG().getX().toBigInteger(),
                                        spec.getParams().getG().getY().toBigInteger()),
                                spec.getParams().getN(),
                                spec.getParams().getH().intValue());
    }
View Full Code Here

        {
            EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

            this.ecSpec = new ECParameterSpec(
                            ellipticCurve,
                            new ECPoint(
                                    dp.getG().getX().toBigInteger(),
                                    dp.getG().getY().toBigInteger()),
                            dp.getN(),
                            dp.getH().intValue());
        }
View Full Code Here

TOP

Related Classes of java.security.spec.ECPoint

Copyright © 2018 www.massapicom. 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.