From 4a4252938be752b185d352cf85357d4d12e01df7 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Thu, 15 Jul 2010 13:26:57 +0000 Subject: [PATCH] Fixing storing passwords and fixing build. --- .../impl/credentialsstorage/AESCrypto.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); } /**