diff --git a/src/net/java/sip/communicator/impl/credentialsstorage/AESCrypto.java b/src/net/java/sip/communicator/impl/credentialsstorage/AESCrypto.java index f1f83b1ad..5f1d3fdfe 100644 --- a/src/net/java/sip/communicator/impl/credentialsstorage/AESCrypto.java +++ b/src/net/java/sip/communicator/impl/credentialsstorage/AESCrypto.java @@ -73,13 +73,13 @@ public AESCrypto(String masterPassword) { try { - decryptCipher = Cipher.getInstance(CIPHER_ALGORITHM); - encryptCipher = Cipher.getInstance(CIPHER_ALGORITHM); - // we try init of key with suupplied lengths // we stop after the first successful attempt for (int i = 0; i < KEY_LENGTHS.length; i++) { + decryptCipher = Cipher.getInstance(CIPHER_ALGORITHM); + encryptCipher = Cipher.getInstance(CIPHER_ALGORITHM); + try { initKey(masterPassword, KEY_LENGTHS[i]); @@ -145,6 +145,10 @@ private void initKey(String masterPassword, int keyLength) SecretKey tmp = factory.generateSecret(spec); // Make an algorithm specific key key = new SecretKeySpec(tmp.getEncoded(), KEY_ALGORITHM); + + // just a check whether the key size is wrong + encryptCipher.init(Cipher.ENCRYPT_MODE, key); + decryptCipher.init(Cipher.DECRYPT_MODE, key); } /**