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

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
This code example shows how to use the following methods:getParams, getS
            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)) {
            final byte[] encoded = key.getEncoded();
            if (!"PKCS#8".equals(key.getFormat())) {
                throw new InvalidKeySpecException("Encoding type must be PKCS#8; was "
                        + key.getFormat());
            } else if (encoded == null) {
                throw new InvalidKeySpecException("Key is not encodable");
            } 
            return (T) new PKCS8EncodedKeySpec(encoded);
        } else if (key instanceof PublicKey && X509EncodedKeySpec.class.isAssignableFrom(keySpec)) {
            final byte[] encoded = key.getEncoded();
            if (!"X.509".equals(key.getFormat())) {
                throw new InvalidKeySpecException("Encoding type must be X.509; was "
6
CodeRank
This code example shows how to use the following methods:getParams, getS
       } 
       else if (spec.isAssignableFrom(java.security.spec.ECPrivateKeySpec.class) && key instanceof ECPrivateKey)
       { 
           ECPrivateKey k = (ECPrivateKey)key;
 
           if (k.getParams() != null)
           { 
               return new java.security.spec.ECPrivateKeySpec(k.getS(), k.getParams());
           } 
           else 
           { 
               ECParameterSpec implicitSpec = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
 
               return new java.security.spec.ECPrivateKeySpec(k.getS(), EC5Util.convertSpec(EC5Util.convertCurve(implicitSpec.getCurve(), implicitSpec.getSeed()), implicitSpec));
           } 
       } 
       else if (spec.isAssignableFrom(org.bouncycastle.jce.spec.ECPublicKeySpec.class) && key instanceof ECPublicKey)
       { 
           ECPublicKey k = (ECPublicKey)key;
           if (k.getParams() != null)

6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getS
    } 
 
    public BCDSTU4145PrivateKey( 
        ECPrivateKey key)
    { 
        this.d = key.getS();
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
    } 
 
    public BCDSTU4145PrivateKey( 
        org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
    { 
        this.d = spec.getD();
 
        if (spec.getParams() != null) // can be null if implicitlyCA
        { 
            ECCurve curve = spec.getParams().getCurve();
            EllipticCurve ellipticCurve;
 
6
CodeRank
This code example shows how to use the following methods:getParams, getS
        } 
        else if (spec.isAssignableFrom(java.security.spec.ECPrivateKeySpec.class) && key instanceof ECPrivateKey)
        { 
            ECPrivateKey k = (ECPrivateKey)key;
 
            if (k.getParams() != null)
            { 
                return new java.security.spec.ECPrivateKeySpec(k.getS(), k.getParams());
            } 
            else 
            { 
                ECParameterSpec implicitSpec = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
 
                return new java.security.spec.ECPrivateKeySpec(k.getS(), EC5Util.convertSpec(EC5Util.convertCurve(implicitSpec.getCurve(), implicitSpec.getSeed()), implicitSpec));
            } 
        } 
        else if (spec.isAssignableFrom(org.bouncycastle.jce.spec.ECPublicKeySpec.class) && key instanceof ECPublicKey)
        { 
            ECPublicKey k = (ECPublicKey)key;
            if (k.getParams() != null)

6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getS
    } 
 
    public JCEECPrivateKey( 
        ECPrivateKey    key)
    { 
        this.d = key.getS();
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
    } 
 
    public JCEECPrivateKey( 
        String              algorithm,
        org.bouncycastle.jce.spec.ECPrivateKeySpec     spec)
    { 
        this.algorithm = algorithm;
        this.d = spec.getD();
 
        if (spec.getParams() != null) // can be null if implicitlyCA
        { 
            ECCurve curve = spec.getParams().getCurve();
6
CodeRank
This code example shows how to use the following methods:getParams, getS
            } 
        } 
    } 
 
    private static void assertECPrivateKeyEquals(ECPrivateKey expected, ECPrivateKey actual) {
        assertEquals(expected.getS(), actual.getS());
        assertECParametersEquals(expected.getParams(), actual.getParams());
    } 
 
    private static void assertECParametersEquals(ECParameterSpec expected, ECParameterSpec actual) {
        assertEquals(expected.getCurve(), actual.getCurve());
        assertEquals(expected.getGenerator(), actual.getGenerator());
        assertEquals(expected.getOrder(), actual.getOrder());
        assertEquals(expected.getCofactor(), actual.getCofactor());
    } 
 
    /** 
     * DH parameters pre-generated so that the test doesn't take too long. 
     * These parameters were generated with: 
     * 
6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getParams, getS
    } 
 
    public BCECGOST3410PrivateKey( 
        ECPrivateKey key)
    { 
        this.d = key.getS();
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
    } 
 
    public BCECGOST3410PrivateKey( 
        org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
    { 
        this.d = spec.getD();
 
        if (spec.getParams() != null) // can be null if implicitlyCA
        { 
            ECCurve curve = spec.getParams().getCurve();
            EllipticCurve ellipticCurve;
 
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
This code example shows how to use the following methods:getAlgorithm, getParams, getS
    } 
 
    public BCDSTU4145PrivateKey( 
        ECPrivateKey key)
    { 
        this.d = key.getS();
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
    } 
 
    public BCDSTU4145PrivateKey( 
        org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
    { 
        this.d = spec.getD();
 
        if (spec.getParams() != null) // can be null if implicitlyCA
        { 
            ECCurve curve = spec.getParams().getCurve();
            EllipticCurve ellipticCurve;
 
6
CodeRank
See Code Examples for Java 8 ECPrivateKey Methods: