Package java.security.spec

Examples of java.security.spec.ECParameterSpec


                );
            } catch (PrivilegedActionException pae) {
                throw new MarshalException("ECKeyValue not supported",
                                           pae.getException());
            }
            ECParameterSpec ecParams = null;
            Element curElem = DOMUtils.getFirstChildElement(kvtElem);
            if (curElem.getLocalName().equals("ECParameters")) {
                throw new UnsupportedOperationException
                    ("ECParameters not supported");
            } else if (curElem.getLocalName().equals("NamedCurve")) {
                String uri = DOMUtils.getAttributeValue(curElem, "URI");
                // strip off "urn:oid"
                if (uri.startsWith("urn:oid:")) {
                    String oid = uri.substring(8);
                    try {
                        Object[] args = new Object[] { oid };
                        ecParams = (ECParameterSpec)
                                    getECParameterSpec.invoke(null, args);
                    } catch (IllegalAccessException iae) {
                        throw new MarshalException(iae);
                    } catch (InvocationTargetException ite) {
                        throw new MarshalException(ite);
                    }
                } else {
                    throw new MarshalException("Invalid NamedCurve URI");
                }
            } else {
                throw new MarshalException("Invalid ECKeyValue");
            }
            curElem = DOMUtils.getNextSiblingElement(curElem, "PublicKey");
            ECPoint ecPoint = null;
            try {
                Object[] args = new Object[] { Base64.decode(curElem),
                                               ecParams.getCurve() };
                ecPoint = (ECPoint)decodePoint.invoke(null, args);
            } catch (Base64DecodingException bde) {
                throw new MarshalException("Invalid EC PublicKey", bde);
            } catch (IllegalAccessException iae) {
                throw new MarshalException(iae);
View Full Code Here


        EllipticCurve c =
            new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);       
    }
View Full Code Here

        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        BigInteger order = BigInteger.valueOf(5L);

        // Test case 1: curve is null
        try {
            new ECParameterSpec(null, generator, order, 10);
            fail("#1: Expected NPE not thrown");
        } catch (NullPointerException ok) {
        }


        // Test case 2: generator is null
        try {
            new ECParameterSpec(curve, null, order, 10);
            fail("#2: Expected NPE not thrown");
        } catch (NullPointerException ok) {
        }


        // Test case 3: order is null
        try {
            new ECParameterSpec(curve, generator, null, 10);
            fail("#3: Expected NPE not thrown");
        } catch (NullPointerException ok) {
        }


        // Test case 4: all above are null
        try {
            new ECParameterSpec(null, null, null, 10);
            fail("#4: Expected NPE not thrown");
        } catch (NullPointerException ok) {
        }
    }
View Full Code Here

        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));


        // Test case 1: order is negative
        try {
            new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 10);
            fail("#1: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {
        }


        // Test case 2: order == 0
        try {
            new ECParameterSpec(curve, generator, BigInteger.ZERO, 10);
            fail("#2: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {
        }


        // Test case 3: cofactor is negative
        try {
            new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), -10);
            fail("#3: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {
        }


        // Test case 4: cofactor == 0
        try {
            new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), 0);
            fail("#4: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {
        }


        // Test case 5: both order and cofactor are not positive
        try {
            new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 0);
            fail("#5: Expected IAE not thrown");
        } catch (IllegalArgumentException ok) {
        }
    }
View Full Code Here

                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        BigInteger order = BigInteger.valueOf(5L);
        int cofactor = 10;
        ECParameterSpec ps =
            new ECParameterSpec(curve, generator, order, cofactor);
        assertEquals(cofactor, ps.getCofactor());
    }
View Full Code Here

                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        BigInteger order = BigInteger.valueOf(5L);
        int cofactor = 10;
        ECParameterSpec ps =
            new ECParameterSpec(curve, generator, order, cofactor);
        EllipticCurve curveRet = ps.getCurve();
        assertEquals(curve, curveRet);
        assertSame(curve, curveRet);
    }
View Full Code Here

                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        BigInteger order = BigInteger.valueOf(5L);
        int cofactor = 10;
        ECParameterSpec ps =
            new ECParameterSpec(curve, generator, order, cofactor);
        ECPoint generatorRet = ps.getGenerator();
        assertEquals(generator, generatorRet);
        assertSame(generator, generatorRet);
    }
View Full Code Here

                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        BigInteger order = BigInteger.valueOf(5L);
        int cofactor = 10;
        ECParameterSpec ps =
            new ECParameterSpec(curve, generator, order, cofactor);
        BigInteger orderRet = ps.getOrder();
        assertEquals(order, orderRet);
        assertSame(order, orderRet);
    }
View Full Code Here

            new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
                              BigInteger.ZERO,
                              BigInteger.valueOf(4L));
        ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
        new ECPrivateKeySpec(BigInteger.ZERO,
                new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
       
    }
View Full Code Here

        ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));

        // Test case 1: s is null
        try {
            new ECPrivateKeySpec(null,
                new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
            fail("#1: Expected NPE not thrown");
        } catch (NullPointerException ok) {
        }

View Full Code Here

TOP

Related Classes of java.security.spec.ECParameterSpec

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.