[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] javadocs code problems





    Hi all.

    I'm testing the follow code from  iaik-jce2.6 javadocs where
plain_text is a byte [], In it I want to
cipher a byte [] with a password's hash:

    Random random = new Random();
   // salt
   byte[] salt = new byte[16];
   random.nextBytes(salt);
   //iteration count
   int count = 1;
   // PBE paramters
   PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count);
   //  PBEKeyBMP from password
   PBEKeyBMP pbeKey = new PBEKeyBMP(pass);
   Cipher pbeCipher =
Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC");
   // initialize for encryption
   pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
   // encrypt data
   byte[] cipher_data = pbeCipher.doFinal(plain_data);
   // initialize for decryption
   pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);
   // decrypt cipher data
   byte[] decrypted_data = pbeCipher.doFinal(cipher_data);
   return(cipher_data);

    When I invoke this code I get the exception:

    Error setting algorithms parameters

    just in:  pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);

    Can anybody tell me where the mistake is?

    Thanks,. Gabi.

--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-jce