Examples of DHPrivateKeySpec


Examples of javax.crypto.spec.DHPrivateKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the private key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger privateKeyInt = new BigInteger(privateKeyBytes);
        DHPrivateKeySpec dhPrivateSpec = new DHPrivateKeySpec(privateKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PrivateKey privateKey = keyFactory.generatePrivate(dhPrivateSpec);

        return privateKey;
    }
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the private key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger privateKeyInt = new BigInteger(privateKeyBytes);
        DHPrivateKeySpec dhPrivateSpec = new DHPrivateKeySpec(privateKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PrivateKey privateKey = keyFactory.generatePrivate(dhPrivateSpec);

        return privateKey;
    }
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

       }
       else 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;
          
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

       }
       else 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;
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the private key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger privateKeyInt = new BigInteger(privateKeyBytes);
        DHPrivateKeySpec dhPrivateSpec = new DHPrivateKeySpec(privateKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PrivateKey privateKey = keyFactory.generatePrivate(dhPrivateSpec);

        return privateKey;
    }
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

    {
        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;
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

    protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
        throws InvalidKeySpecException
    {
        try {
            if (keySpec instanceof DHPrivateKeySpec) {
                DHPrivateKeySpec dhPrivKeySpec = (DHPrivateKeySpec)keySpec;
                return new DHPrivateKey(dhPrivKeySpec.getX(),
                                        dhPrivKeySpec.getP(),
                                        dhPrivKeySpec.getG());

            } else if (keySpec instanceof PKCS8EncodedKeySpec) {
                return new DHPrivateKey
                    (((PKCS8EncodedKeySpec)keySpec).getEncoded());
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

            if (DHPrivateKeySpec.class.isAssignableFrom(keySpec)) {
                javax.crypto.interfaces.DHPrivateKey dhPrivKey
                    = (javax.crypto.interfaces.DHPrivateKey)key;
                params = dhPrivKey.getParams();
                return new DHPrivateKeySpec(dhPrivKey.getX(),
                                            params.getP(),
                                            params.getG());

            } else if (PKCS8EncodedKeySpec.class.isAssignableFrom(keySpec)) {
                return new PKCS8EncodedKeySpec(key.getEncoded());
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

                // Check if key originates from this factory
                if (key instanceof com.sun.crypto.provider.DHPrivateKey) {
                    return key;
                }
                // Convert key to spec
                DHPrivateKeySpec dhPrivKeySpec
                    = (DHPrivateKeySpec)engineGetKeySpec
                    (key, DHPrivateKeySpec.class);
                // Create key from spec, and return it
                return engineGeneratePrivate(dhPrivKeySpec);
View Full Code Here

Examples of javax.crypto.spec.DHPrivateKeySpec

        Buffer.BufferImpl keyBuf = objArg(args, 0, Buffer.BufferImpl.class, true);
        DHImpl self = (DHImpl)thisObj;
        assert(self.prime != null);

        BigInteger x = self.intFromBuf(keyBuf, cx);
        DHPrivateKeySpec spec = new DHPrivateKeySpec(x, self.prime, DH_GENERATOR);
        try {
            KeyFactory kf = self.getKeyFactory();
            self.privKey = (DHPrivateKey)kf.generatePrivate(spec);
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError(e);
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.