Java 8 ECKey - 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 ECKey class.

This code example shows how to use the following methods:getAlgorithm, getParams, getW
    } 
     
    public JCEECPublicKey( 
        ECPublicKey     key)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    JCEECPublicKey( 
        SubjectPublicKeyInfo    info)
    { 
        populateFromPubKeyInfo(info);
    } 
 
    private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
    { 
        // BEGIN android-removed 
        // if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001)) 
8
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getW
    } 
 
    public BCECGOST3410PublicKey( 
        ECPublicKey key)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    BCECGOST3410PublicKey( 
        SubjectPublicKeyInfo info)
    { 
        populateFromPubKeyInfo(info);
    } 
 
    private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
    { 
        DERBitString bits = info.getPublicKeyData();
        ASN1OctetString key;
6
CodeRank
This code example shows how to use the following methods:getParams, getW
            return new RSAPublicKey(usage, pubKey.getModulus(), pubKey.getPublicExponent());
        } 
        else 
        { 
            ECPublicKey pubKey = (ECPublicKey)publicKey;
            java.security.spec.ECParameterSpec params = pubKey.getParams();
 
            return new ECDSAPublicKey( 
                usage,
                ((ECFieldFp)params.getCurve().getField()).getP(),
                params.getCurve().getA(), params.getCurve().getB(),
                convertPoint(convertCurve(params.getCurve()), params.getGenerator(), false).getEncoded(),
                params.getOrder(),
                convertPoint(convertCurve(params.getCurve()), pubKey.getW(), false).getEncoded(),
                params.getCofactor());
        } 
    } 
 
    private static org.bouncycastle.math.ec.ECPoint convertPoint( 
        ECCurve curve,
6
CodeRank
This code example shows how to use the following methods:getParams, getW
            final byte[] encoded = key.getEncoded();
            if (!"X.509".equals(key.getFormat()) || encoded == null) {
                throw new InvalidKeySpecException("Not a valid X.509 encoding");
            } 
            ECPublicKey ecKey = (ECPublicKey) engineGeneratePublic(new X509EncodedKeySpec(encoded));
            return (T) new ECPublicKeySpec(ecKey.getW(), ecKey.getParams());
        } else if (key instanceof ECPrivateKey
                && ECPrivateKeySpec.class.isAssignableFrom(keySpec)) {
            ECPrivateKey ecKey = (ECPrivateKey) key;
            return (T) new ECPrivateKeySpec(ecKey.getS(), ecKey.getParams());
        } else if (key instanceof PrivateKey && ECPrivateKeySpec.class.isAssignableFrom(keySpec)) {
            final byte[] encoded = key.getEncoded();
            if (!"PKCS#8".equals(key.getFormat()) || encoded == null) {
                throw new InvalidKeySpecException("Not a valid PKCS#8 encoding");
            } 
            ECPrivateKey ecKey =
                    (ECPrivateKey) engineGeneratePrivate(new PKCS8EncodedKeySpec(encoded));
            return (T) new ECPrivateKeySpec(ecKey.getS(), ecKey.getParams());
        } else if (key instanceof PrivateKey
                && PKCS8EncodedKeySpec.class.isAssignableFrom(keySpec)) {
6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getW
    } 
 
    public BCDSTU4145PublicKey( 
        ECPublicKey key)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    BCDSTU4145PublicKey( 
        SubjectPublicKeyInfo info)
    { 
        populateFromPubKeyInfo(info);
    } 
 
    private void reverseBytes(byte[] bytes)
    { 
        byte tmp;
 
6
CodeRank
This code example shows how to use the following methods:getParams, getW
        throws InvalidKeySpecException 
    { 
       if (spec.isAssignableFrom(java.security.spec.ECPublicKeySpec.class) && key instanceof ECPublicKey)
       { 
           ECPublicKey k = (ECPublicKey)key;
           if (k.getParams() != null)
           { 
               return new java.security.spec.ECPublicKeySpec(k.getW(), k.getParams());
           } 
           else 
           { 
               ECParameterSpec implicitSpec = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
 
               return new java.security.spec.ECPublicKeySpec(k.getW(), EC5Util.convertSpec(EC5Util.convertCurve(implicitSpec.getCurve(), implicitSpec.getSeed()), implicitSpec));
           } 
       } 
       else if (spec.isAssignableFrom(java.security.spec.ECPrivateKeySpec.class) && key instanceof ECPrivateKey)
       { 
           ECPrivateKey k = (ECPrivateKey)key;
 

6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getW
 
    public BCECPublicKey( 
        ECPublicKey key,
        ProviderConfiguration configuration)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    BCECPublicKey( 
        String algorithm,
        SubjectPublicKeyInfo info,
        ProviderConfiguration configuration)
    { 
        this.algorithm = algorithm;
        this.configuration = configuration;
        populateFromPubKeyInfo(info);
    } 
 
6
CodeRank
This code example shows how to use the following methods:getParams, getW
        throws InvalidKeySpecException 
    { 
        if (spec.isAssignableFrom(java.security.spec.ECPublicKeySpec.class) && key instanceof ECPublicKey)
        { 
            ECPublicKey k = (ECPublicKey)key;
            if (k.getParams() != null)
            { 
                return new java.security.spec.ECPublicKeySpec(k.getW(), k.getParams());
            } 
            else 
            { 
                ECParameterSpec implicitSpec = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
 
                return new java.security.spec.ECPublicKeySpec(k.getW(), EC5Util.convertSpec(EC5Util.convertCurve(implicitSpec.getCurve(), implicitSpec.getSeed()), implicitSpec));
            } 
        } 
        else if (spec.isAssignableFrom(java.security.spec.ECPrivateKeySpec.class) && key instanceof ECPrivateKey)
        { 
            ECPrivateKey k = (ECPrivateKey)key;
 

6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getW
    } 
 
    public BCECGOST3410PublicKey( 
        ECPublicKey key)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    BCECGOST3410PublicKey( 
        SubjectPublicKeyInfo info)
    { 
        populateFromPubKeyInfo(info);
    } 
 
    private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
    { 
        DERBitString bits = info.getPublicKeyData();
        ASN1OctetString key;
6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getS
 
    public BCECPrivateKey( 
        ECPrivateKey key,
        ProviderConfiguration configuration)
    { 
        this.d = key.getS();
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.configuration = configuration;
    } 
 
    public BCECPrivateKey( 
        String algorithm,
        org.bouncycastle.jce.spec.ECPrivateKeySpec spec,
        ProviderConfiguration configuration)
    { 
        this.algorithm = algorithm;
        this.d = spec.getD();
 
        if (spec.getParams() != null) // can be null if implicitlyCA
6
CodeRank
See Code Examples for Java 8 ECKey Methods: