Skip to content

Commit

Permalink
Security recommendation according to https://heise.de/-4211551
Browse files Browse the repository at this point in the history
  • Loading branch information
uwe authored and uwe committed Apr 21, 2019
1 parent ea92b73 commit 7af20ac
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ public EncryptionHelper(final char[] passphrase, final String saltAsHexString,
try {
salt = EncryptionHelper.toByteArray(saltAsHexString);
initializer = EncryptionHelper.toByteArray(initializerAsHexString);
KeySpec keySpec = new PBEKeySpec(passphrase, salt, KEY_ITERATION_COUNT, KEY_LENGTH);
PBEKeySpec keySpec = new PBEKeySpec(passphrase, salt, KEY_ITERATION_COUNT, KEY_LENGTH);
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(SECRET_KEY_FACTORY_ALGORITHM);
SecretKey secretKey = secretKeyFactory.generateSecret(keySpec);
keySpec.clearPassword(); // see https://heise.de/-4211551
cipher = Cipher.getInstance(CIPHER_TRANSFORMATION);
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getEncoded(), CIPHER_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(initializer));
Expand Down

0 comments on commit 7af20ac

Please sign in to comment.