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

This code example shows how to use the following methods:getG, getP, getX
{ 
    // BEGIN android-removed 
    // protected boolean elGamalFactory = false; 
    // END android-removed 
     
    public JDKKeyFactory() 
    { 
    } 
 
    protected PrivateKey engineGeneratePrivate(
        KeySpec keySpec)
        throws InvalidKeySpecException 
    { 
        if (keySpec instanceof PKCS8EncodedKeySpec)
        { 
            try 
            { 
                return JDKKeyFactory.createPrivateKeyFromDERStream( 
                    ((PKCS8EncodedKeySpec)keySpec).getEncoded());
            } 
8
CodeRank
This code example shows how to use the following methods:getG, getP, getX
 
    protected Key engineTranslateKey(
        Key key)
        throws InvalidKeyException 
    { 
        if (key instanceof DHPublicKey)
        { 
            return new BCDHPublicKey((DHPublicKey)key);
        } 
        else if (key instanceof DHPrivateKey)
        { 
            return new BCDHPrivateKey((DHPrivateKey)key);
        } 
 
        throw new InvalidKeyException("key type unknown");
    } 
 
    protected PrivateKey engineGeneratePrivate(
        KeySpec keySpec)
        throws InvalidKeySpecException 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
        return super.engineGeneratePublic(keySpec);
    } 
 
    protected KeySpec engineGetKeySpec(
        Key key,
        Class spec)
        throws InvalidKeySpecException 
    { 
        if (spec.isAssignableFrom(DHPrivateKeySpec.class) && key instanceof DHPrivateKey)
        { 
            DHPrivateKey k = (DHPrivateKey)key;
 
            return new DHPrivateKeySpec(k.getX(), k.getParams().getP(), k.getParams().getG());
        } 
        else if (spec.isAssignableFrom(DHPublicKeySpec.class) && key instanceof DHPublicKey)
        { 
            DHPublicKey k = (DHPublicKey)key;
 
            return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG());
        } 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
    } 
 
    JCEElGamalPrivateKey( 
        DHPrivateKeySpec    spec)
    { 
        this.x = spec.getX();
        this.elSpec = new ElGamalParameterSpec(spec.getP(), spec.getG());
    } 
     
    JCEElGamalPrivateKey( 
        PrivateKeyInfo  info)
        throws IOException 
    { 
        ElGamalParameter     params = new ElGamalParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());
 
        this.x = derX.getValue();
        this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
    } 
 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
// import org.bouncycastle.jce.spec.ElGamalPublicKeySpec; 
// import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec; 
// import org.bouncycastle.jce.spec.GOST3410PublicKeySpec; 
// END android-removed 
 
public abstract class JDKKeyFactory 
    extends KeyFactorySpi
{ 
    // BEGIN android-removed 
    // protected boolean elGamalFactory = false; 
    // END android-removed 
     
    public JDKKeyFactory() 
    { 
    } 
 
    protected PrivateKey engineGeneratePrivate(
        KeySpec keySpec)
        throws InvalidKeySpecException 
    { 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
    } 
 
    JCEDHPrivateKey( 
        DHPrivateKeySpec    spec)
    { 
        this.x = spec.getX();
        this.dhSpec = new DHParameterSpec(spec.getP(), spec.getG());
    } 
 
    JCEDHPrivateKey( 
        PrivateKeyInfo  info)
        throws IOException 
    { 
        ASN1Sequence    seq = ASN1Sequence.getInstance(info.getAlgorithmId().getParameters());
        DERInteger      derX = DERInteger.getInstance(info.parsePrivateKey());
        DERObjectIdentifier id = info.getAlgorithmId().getAlgorithm();
 
        this.info = info;
        this.x = derX.getValue();
 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
    } 
 
    BCElGamalPrivateKey( 
        DHPrivateKeySpec spec)
    { 
        this.x = spec.getX();
        this.elSpec = new ElGamalParameterSpec(spec.getP(), spec.getG());
    } 
     
    BCElGamalPrivateKey( 
        PrivateKeyInfo info)
        throws IOException 
    { 
        ElGamalParameter     params = new ElGamalParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());
 
        this.x = derX.getValue();
        this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
    } 
 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
    } 
 
    BCDHPrivateKey( 
        DHPrivateKeySpec spec)
    { 
        this.x = spec.getX();
        this.dhSpec = new DHParameterSpec(spec.getP(), spec.getG());
    } 
 
    public BCDHPrivateKey( 
        PrivateKeyInfo info)
        throws IOException 
    { 
        ASN1Sequence    seq = ASN1Sequence.getInstance(info.getPrivateKeyAlgorithm().getParameters());
        ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();
        ASN1ObjectIdentifier id = info.getPrivateKeyAlgorithm().getAlgorithm();
 
        this.info = info;
        this.x = derX.getValue();
 
7
CodeRank
This code example shows how to use the following methods:getG, getP, getX
    } 
 
    JCEDHPrivateKey( 
        DHPrivateKeySpec    spec)
    { 
        this.x = spec.getX();
        this.dhSpec = new DHParameterSpec(spec.getP(), spec.getG());
    } 
 
    JCEDHPrivateKey( 
        PrivateKeyInfo  info)
    { 
        DHParameter     params = new DHParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger      derX = (DERInteger)info.getPrivateKey();
 
        this.x = derX.getValue();
        if (params.getL() != null)
        { 
            this.dhSpec = new DHParameterSpec(params.getP(), params.getG(), params.getL().intValue());
        } 
6
CodeRank
This code example shows how to use the following methods:getG, getP, getX
 
    protected Key engineTranslateKey(
        Key key)
        throws InvalidKeyException 
    { 
        if (key instanceof DHPublicKey)
        { 
            return new BCDHPublicKey((DHPublicKey)key);
        } 
        else if (key instanceof DHPrivateKey)
        { 
            return new BCDHPrivateKey((DHPrivateKey)key);
        } 
 
        throw new InvalidKeyException("key type unknown");
    } 
 
    protected PrivateKey engineGeneratePrivate(
        KeySpec keySpec)
        throws InvalidKeySpecException 
6
CodeRank
See Code Examples for Java 8 DHPrivateKeySpec Methods: