Examples of DHPublicKeySpec


Examples of javax.crypto.spec.DHPublicKeySpec

    }

    public ByteBuf computeSecret(ByteBuf publicKeyBytes) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException, NoSuchProviderException {
        BigInteger y = BigIntegerUtils.fromBuf(publicKeyBytes);

        DHPublicKeySpec keySpec = new DHPublicKeySpec(y, this.desc.getP(), this.desc.getG());

        KeyFactory keyFactory = KeyFactory.getInstance("DH", "BC");
        PublicKey publicKey = keyFactory.generatePublic(keySpec);

        KeyAgreement agreement = KeyAgreement.getInstance("DH");
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

       }
       else if (spec.isAssignableFrom(DHPublicKeySpec.class) && key instanceof DHPublicKey)
       {
           DHPublicKey k = (DHPublicKey)key;

           return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG());
       }

        throw new RuntimeException("not implemented yet " + key + " " + spec);
    }
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

    return bytes;
  }
 
  public static DHPublicKey bytesToPublicKey(DHParameterSpec parameterSpec, byte[] bytes){
    /* Set Y (public key), P and G values. */
    KeySpec keySpec = new DHPublicKeySpec(
      bytesToBigInteger(bytes),
      parameterSpec.getP(),
      parameterSpec.getG()
    );
   
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the valuelink public key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger publicKeyInt = new BigInteger(publicKeyBytes);
        DHPublicKeySpec dhPublicSpec = new DHPublicKeySpec(publicKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PublicKey vlPublic = keyFactory.generatePublic(dhPublicSpec);

        return vlPublic;
    }
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

       }
       else if (spec.isAssignableFrom(DHPublicKeySpec.class) && key instanceof DHPublicKey)
       {
           DHPublicKey k = (DHPublicKey)key;
          
           return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG());
       }

        throw new RuntimeException("not implemented yet " + key + " " + spec);
    }
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

       }
       else if (spec.isAssignableFrom(DHPublicKeySpec.class) && key instanceof DHPublicKey)
       {
           DHPublicKey k = (DHPublicKey)key;

           return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG());
       }

        throw new RuntimeException("not implemented yet " + key + " " + spec);
    }
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the valuelink public key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger publicKeyInt = new BigInteger(publicKeyBytes);
        DHPublicKeySpec dhPublicSpec = new DHPublicKeySpec(publicKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PublicKey vlPublic = keyFactory.generatePublic(dhPublicSpec);

        return vlPublic;
    }
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

            KeyFactory keyFac = KeyFactory.getInstance("DH", provider);

            //Use server's public key to initiate a DHPublicKeySpec and then use
            //this DHPublicKeySpec to initiate a publicKey object
            BigInteger publicKey = new BigInteger(1, targetPublicKey);
            DHPublicKeySpec dhKeySpec =
                    new DHPublicKeySpec(publicKey, modulus__, base__);
            PublicKey pubKey = keyFac.generatePublic(dhKeySpec);

            //Execute the first phase of DH keyagreement protocal.
            keyAgreement_.doPhase(pubKey, true);
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

      KeyFactory keyFac = KeyFactory.getInstance ("DH", "IBMJCE");

      //Use server's public key to initiate a DHPublicKeySpec and then use
      //this DHPublicKeySpec to initiate a publicKey object
      BigInteger publicKey = new BigInteger (1, sourcePublicKey);
      DHPublicKeySpec dhKeySpec = new DHPublicKeySpec (publicKey, modulus__, base__);
      PublicKey pubKey = keyFac.generatePublic (dhKeySpec);

      //Execute the first phase of DH keyagreement protocal.
      keyAgreement_.doPhase (pubKey, true);
View Full Code Here

Examples of javax.crypto.spec.DHPublicKeySpec

        DHParameterSpec dhParamSpec = this.getDHParameterSpec();

        // load the valuelink public key
        KeyFactory keyFactory = KeyFactory.getInstance("DH");
        BigInteger publicKeyInt = new BigInteger(publicKeyBytes);
        DHPublicKeySpec dhPublicSpec = new DHPublicKeySpec(publicKeyInt, dhParamSpec.getP(), dhParamSpec.getG());
        PublicKey vlPublic = keyFactory.generatePublic(dhPublicSpec);

        return vlPublic;
    }
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.