Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SecretKeyFactory, Cipher Blocking threads, degrading performance

843811Aug 22 2009 — edited Aug 23 2009
Hi all,

I need urgent help. PLease send your suggestions. I have written following code snippet for AES encry/decry for PBE.

Class AES {

SecretKeyFactory factory = null;
static {
factory = SecretKeyFactory.getInstance("AES");
}

public static String encryt(String pass, String text) {
SecureRandom ran = ....;
bytes[] salt = ran.nextBytes();

PBESpecKey key factory.generateSecret(.....) ;

Cipher ciper = Cipher.getInstance("AES");
ciper.init(ENCRYPT);

bytes = ciper.doFinal(....);
return encryptedString;
}

public static String decryt(String salt, String encText) {

PBESpecKey key factory.generateSecret(salt, ......) ;

Cipher ciper = Cipher.getInstance("AES");
ciper.init(DECRYPT);

bytes = ciper.doFinal(....);
return decryptedString;
}


}

Please note that above syntax may not be correct. But in essence, I am using JCE classes for AES encryption decryption.

Problem

Since i started using above code, my all web applications threads are blocking in JCE classes. Application performance has gone down signifacntly. PLease suggest if above is the correct use of JCE classes. What alternative approach I can use?

Is it safe to use JCE classes in multi threaded applications? Memory usage was also extremely high.

Thanks and Regards
Chetan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2009
Added on Aug 22 2009
6 comments
1,013 views