Examples of ECGenParameterSpec


Examples of java.security.spec.ECGenParameterSpec

    public KeyPair(String algorithm, String curveName) {

        java.security.KeyPair keyPair = null;
        try {
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm, AeroGearCrypto.PROVIDER);
            ECGenParameterSpec ecSpec = new ECGenParameterSpec(curveName);
            keyGen.initialize(ecSpec, new SecureRandom());
            keyPair = keyGen.generateKeyPair();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (NoSuchProviderException e) {
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

            throw new SecurityException(ex);
        }   
    }
    private static ECParameterSpec getECParameterSpec() throws Exception {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
        ECGenParameterSpec kpgparams = new ECGenParameterSpec("secp256r1");
        kpg.initialize(kpgparams);
        return ((ECPublicKey) kpg.generateKeyPair().getPublic()).getParams();
    }
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

    static final KeyPair generateSigningKeyPair() {
        try {
            KeyPairGenerator kpg;
            // kpg = KeyPairGenerator.getInstance("EC", "BC");
            kpg = new org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi.EC();
            kpg.initialize(new ECGenParameterSpec(CURVE_NAME));
            KeyPair kp = kpg.generateKeyPair();
            return kp;
            // } catch (NoSuchAlgorithmException e) {
            // log.error("Error while generating key: " + e.getMessage(), e);
            // } catch (NoSuchProviderException e) {
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

    static final KeyPair generateEncryptionKeyPair() {
        try {
            KeyPairGenerator kpg;
            // kpg = KeyPairGenerator.getInstance("EC", "BC");
            kpg = new org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi.EC();
            kpg.initialize(new ECGenParameterSpec(CURVE_NAME));
            KeyPair kp = kpg.generateKeyPair();
            return kp;
            // } catch (NoSuchAlgorithmException e) {
            // log.error("Error while generating key: " + e.getMessage(), e);
            // } catch (NoSuchProviderException e) {
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

    public KeyPair() {

        KeyPairGenerator keyGen = null;
        try {
            keyGen = KeyPairGenerator.getInstance("ECDH", AeroGearCrypto.PROVIDER);
            ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1");
            keyGen.initialize(ecSpec, new SecureRandom());
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (NoSuchProviderException e) {
            e.printStackTrace();
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

    public CreateInteropXMLDSig11Test() throws Exception {
        // Create KeyPairs
        try {
            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
            kpg.initialize(new ECGenParameterSpec("1.2.840.10045.3.1.7"));
            p256 = kpg.generateKeyPair();
            kpg.initialize(new ECGenParameterSpec("1.3.132.0.34"));
            p384 = kpg.generateKeyPair();
            kpg.initialize(new ECGenParameterSpec("1.3.132.0.35"));
            p521 = kpg.generateKeyPair();
        } catch (NoSuchAlgorithmException nsae) {
            // EC not supported on this platform
            ecSupport = false;
        }
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

        names.put("secp384r1", EllipticCurves.P_384);
        names.put("secp521r1", EllipticCurves.P_521);

        for (Map.Entry<String,String> e : names.entrySet())
        {
            ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec(e.getKey());
            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
            kpg.initialize(ecGenParameterSpec);
            KeyPair keyPair = kpg.generateKeyPair();
            ECPublicKey ecpub = (ECPublicKey) keyPair.getPublic();
            ECParameterSpec params = ecpub.getParams();
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

    public CreateInteropXMLDSig11Test() throws Exception {
        // Create KeyPairs
        try {
            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
            kpg.initialize(new ECGenParameterSpec("1.2.840.10045.3.1.7"));
            p256 = kpg.generateKeyPair();
            kpg.initialize(new ECGenParameterSpec("1.3.132.0.34"));
            p384 = kpg.generateKeyPair();
            kpg.initialize(new ECGenParameterSpec("1.3.132.0.35"));
            p521 = kpg.generateKeyPair();
        } catch (NoSuchAlgorithmException nsae) {
            // EC not supported on this platform
            ecSupport = false;
        }
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

      String namedCurve = ECDHServerKeyExchange.NAMED_CURVE_TABLE[namedCurveId];

      // initialize the key pair generator
      KeyPairGenerator kpg;
      kpg = KeyPairGenerator.getInstance(KEYPAIR_GENERATOR_INSTANCE);
      ECGenParameterSpec params = new ECGenParameterSpec(namedCurve);
      kpg.initialize(params, new SecureRandom());

      KeyPair kp = kpg.generateKeyPair();

      privateKey = (ECPrivateKey) kp.getPrivate();
View Full Code Here

Examples of java.security.spec.ECGenParameterSpec

   
    public void testCurve(
        String name)
        throws Exception
    {
        ECGenParameterSpec     ecSpec = new ECGenParameterSpec(name);

        if (ecSpec == null)
        {
            fail("no curve for " + name + " found.");
        }
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.