Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Fix KEY_LENGTH for PBKDF2 by specifying it in bits rather than bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilkl committed Jan 20, 2025
1 parent b3b97f5 commit 8226b6d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/no/uio/ifi/crypt4gh/pojo/key/KDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public byte[] derive(int rounds, char[] password, byte[] salt) throws GeneralSec
case BCRYPT:
return BKDF.createKdf().derive(salt, password, (int) (Math.log(rounds) / Math.log(2)), null, KEY_LENGTH);
case PBKDF2_HMAC_SHA256:
KeySpec spec = new PBEKeySpec(password, salt, rounds, KEY_LENGTH);
KeySpec spec = new PBEKeySpec(password, salt, rounds, KEY_LENGTH*8);
SecretKeyFactory factory = SecretKeyFactory.getInstance(PBKDF_2_WITH_HMAC_SHA_256);
return factory.generateSecret(spec).getEncoded();
case NONE:
Expand Down

0 comments on commit 8226b6d

Please sign in to comment.