Package java.security

Examples of java.security.KeyPairGenerator.generateKeyPair()


  public byte[] createPublicKey() throws CryptoException {
    try {
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM);
      keyGen.initialize(DH_SPEC);
      KeyPair keypair = keyGen.generateKeyPair();

      privateKey = keypair.getPrivate();
      PublicKey publicKey = keypair.getPublic();

      return publicKey.getEncoded();
View Full Code Here


  {
    KeyPairGenerator  kg = KeyPairGenerator.getInstance( "RSA" );
   
    kg.initialize(strength, RandomUtils.SECURE_RANDOM );

    KeyPair pair = kg.generateKeyPair();
         
    X509V3CertificateGenerator certificateGenerator =
      new X509V3CertificateGenerator();
   
    certificateGenerator.setSignatureAlgorithm( "MD5WithRSAEncryption" );
View Full Code Here

        try {
            // Initialize the generator
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
            keyGen.initialize(bits, Utils.getRND());

            KeyPair pair = keyGen.generateKeyPair();

            // Get the keys and set
            setPrivateKey(new SshRsaPrivateKey(
                    (RSAPrivateKey) pair.getPrivate(),
                    (RSAPublicKey) pair.getPublic()));
View Full Code Here

        try {
            // Initialize the generator
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
            keyGen.initialize(bits, Utils.getRND());

            KeyPair pair = keyGen.generateKeyPair();

            // Get the keys
            DSAPrivateKey prvKey = (DSAPrivateKey) pair.getPrivate();
            DSAPublicKey pubKey = (DSAPublicKey) pair.getPublic();
View Full Code Here

    }
   
    public KeyPair genKeyPair() throws NoSuchAlgorithmException {
  KeyPairGenerator kpg = KeyPairGenerator.getInstance(algorithm);
  kpg.initialize(bitkey);
  return kpg.generateKeyPair()
    }

   
    public static void main(String[] args) {
  try {
View Full Code Here

            //initialize(int keysize, SecureRandom random)

            generator.initialize(SOSKeyGenerator.keyLenght, new SecureRandom());
            //generator.initialize(this.keyLenght);

            KeyPair keys = generator.generateKeyPair();

            return keys;
        } catch (NoClassDefFoundError e) {
            throw new Exception("no such Definition : " + e);
        } catch (java.security.NoSuchProviderException e) {
View Full Code Here

    KeyPair keyPair = null;
    DHParameterSpec keySpec = new DHParameterSpec(DH_MODULUS, DH_BASE);
    try {
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
      keyGen.initialize(keySpec);
      keyPair = keyGen.generateKeyPair();
      keyAgreement = KeyAgreement.getInstance("DH");
      keyAgreement.init(keyPair.getPrivate());
    } catch (Exception e) {
      JFLog.log("Error generating keypair", e);
    }
View Full Code Here

        DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
        Document document = builder.parse(sourceDocument);
       
        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
View Full Code Here

        DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
        Document document = builder.parse(sourceDocument);
       
        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
View Full Code Here

        DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
        Document document = builder.parse(sourceDocument);

        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
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.