Java 8 ECGenParameterSpec - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ECGenParameterSpec class.

This code example shows how to use the following methods:getName
     * 
     * Assertion: returns the <code>name</code>   
     */ 
    public final void testGetName() { 
        String name = "someName";
        ECGenParameterSpec ps = new ECGenParameterSpec(name);
        assertEquals(name, ps.getName());
    } 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getName
     * 
     * Assertion: returns the <code>name</code> 
     */ 
    public final void testGetName() { 
        String name = "someName";
        ECGenParameterSpec ps = new ECGenParameterSpec(name);
        assertEquals(name, ps.getName());
    } 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     
    public void testCurve( 
        String name)
        throws Exception 
    { 
        ECGenParameterSpec     ecSpec = new ECGenParameterSpec(name);
 
        KeyPairGenerator    g = KeyPairGenerator.getInstance("ECDH", "BC");
 
        g.initialize(ecSpec, new SecureRandom());
 
        // 
        // a side 
        // 
        KeyPair aKeyPair = g.generateKeyPair();
 
        KeyAgreement aKeyAgree = KeyAgreement.getInstance("ECDHC", "BC");
 
        aKeyAgree.init(aKeyPair.getPrivate());
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getName
 
            group = OpenSSLECGroupContext.getInstance(ecParam);
        } else if (param instanceof ECGenParameterSpec) {
            ECGenParameterSpec ecParam = (ECGenParameterSpec) param;
 
            final String curveName = ecParam.getName();
 
            /* 
             * Store the group in a temporary variable until we know this is a 
             * valid group. 
             */ 
            final OpenSSLECGroupContext possibleGroup = OpenSSLECGroupContext
                    .getCurveByName(curveName);
            if (possibleGroup == null) {
                throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
            } 
 
            group = possibleGroup;
        } else { 
            throw new InvalidAlgorithmParameterException(
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     
    public void testCurve( 
        String name)
        throws ExceptionECGenParameterSpec     ecSpec = new ECGenParameterSpec(name);
 
        KeyPairGenerator    g = KeyPairGenerator.getInstance("ECDH", "BC");
 
        g.initialize(ecSpec, new SecureRandom());
 
        // 
        // a side 
        // 
        KeyPair aKeyPair = g.generateKeyPair();
 
        KeyAgreement aKeyAgree = KeyAgreement.getInstance("ECDHC", "BC");
 
        aKeyAgree.init(aKeyPair.getPrivate());
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
        static { 
            ecParameters = new Hashtable();
 
            // BEGIN android-changed 
            ecParameters.put(Integer.valueOf(192), new ECGenParameterSpec("prime192v1")); // a.k.a P-192
            ecParameters.put(Integer.valueOf(239), new ECGenParameterSpec("prime239v1"));
            ecParameters.put(Integer.valueOf(256), new ECGenParameterSpec("prime256v1")); // a.k.a P-256
 
            ecParameters.put(Integer.valueOf(224), new ECGenParameterSpec("P-224"));
            ecParameters.put(Integer.valueOf(384), new ECGenParameterSpec("P-384"));
            ecParameters.put(Integer.valueOf(521), new ECGenParameterSpec("P-521"));
            // END android-changed 
        } 
 
        public EC() 
        { 
            super("EC"); 
            this.algorithm = "EC";
        } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        }     
    } 
    private static ECParameterSpec getECParameterSpec(String curve, boolean isPrivate) 
        throws Exception {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
        ECGenParameterSpec kpgparams = new ECGenParameterSpec("sec"
                                                              + curve.toLowerCase().replace("-", "")
                                                              + "r1"); 
        kpg.initialize(kpgparams);
        KeyPair pair = kpg.generateKeyPair();
        return isPrivate ? ((ECPublicKey) pair.getPublic()).getParams()
            : ((ECPrivateKey) pair.getPrivate()).getParams();
    } 
     
    public static ECPublicKey getECPublicKey(String curve, String encodedXPoint, String encodedYPoint) {
        try { 
            return getECPublicKey(curve,
                                  CryptoUtils.decodeSequence(encodedXPoint),
                                  CryptoUtils.decodeSequence(encodedYPoint));
        } catch (Exception ex) { 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                    log("Fallback to BC worked for named curve " + name);
                } else { 
                    throw e;
                } 
            } 
            ECGenParameterSpec ecgps = new ECGenParameterSpec(name);
            ap.init(ecgps);
            ECParameterSpec rv = ap.getParameterSpec(ECParameterSpec.class);
            log("Named curve " + name + " loaded");
            return rv;
        } catch (Exception e) {
            log("Named curve " + name + " is not available", e);
            return null; 
        } 
    } 
 
    /** 
     *  Tries curve name1, then name2, then creates new from parms. 
     *  @param name2 null to skip 
     *  @param parms null to skip 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  private KeyPair initializeEC25Keys() {
    try { 
      KeyPairGenerator kg       = KeyPairGenerator.getInstance("ECDH", "SC");
      ECGenParameterSpec ecSpec = new ECGenParameterSpec("secp256r1");
      kg.initialize(ecSpec);
 
      return kg.generateKeyPair();
    } catch (InvalidAlgorithmParameterException e) {
      throw new AssertionError(e);
    } catch (NoSuchAlgorithmException nsae) {
      throw new AssertionError(nsae);
    } catch (NoSuchProviderException e) {
      throw new AssertionError(e);
    } 
  } 
 
  private boolean isRetransmitTime() { 
    return (System.currentTimeMillis() - transmitStartTime >= retransmitInterval);
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    public static void main( 
        String[]    args)
    	throws Exception 
    { 
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "BC");
        ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1");
         
        keyGen.initialize(ecSpec, new SecureRandom());
         
        KeyPair             keyPair = keyGen.generateKeyPair();
        Signature           signature = Signature.getInstance("ECDSA", "BC");
 
        // generate a signature 
         
        signature.initSign(keyPair.getPrivate(), Utils.createFixedRandom());
 
        byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
 
        signature.update(message);
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 ECGenParameterSpec Questions & Answers:

See Code Examples for Java 8 ECGenParameterSpec Methods: