Package java.security

Examples of java.security.KeyPairGenerator.initialize()


  private int keySize = SymmetricCryptor.DEFAULT_KEY_BITS;

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


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

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

  {
    try
    {
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "BC");
     
      keyGen.initialize(ECCparam);

      return keyGen.genKeyPair();
     
    }catch(Throwable e){
     
View Full Code Here

     */
    public void generate(int bits) {
        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(
View Full Code Here

     */
    public void generate(int bits) {
        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();
View Full Code Here

   @Test
   public void testManualFail() throws Exception
   {
      KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
      kpg.initialize(1024);
      KeyPair keyPair = kpg.genKeyPair();

      Verifier verifier = new Verifier();
      Verification verification = verifier.addNew();
      verification.setKey(keyPair.getPublic());
View Full Code Here

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

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

          
            //SecureRandom random = SecureRandom.getInstance("SHA1PRNG",
            // "SUN");
            //initialize(int keysize, SecureRandom random)

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

            KeyPair keys = generator.generateKeyPair();

            return keys;
View Full Code Here

  protected KeyPair generateKeyPair() {
    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

        return cipher.doFinal(inpBytes);
    }

    public static KeyPair generateKeyPair() throws NoSuchAlgorithmException {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance(algorithm);
        kpg.initialize(2048, new SecureRandom());

        return kpg.generateKeyPair();
    }

    public static byte[] serializeKeyPair(KeyPair keyPair) throws IOException {
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.