Skip to content

Commit

Permalink
ELY-2426: Update UnixMD5CryptPassworldImpl to make use of MessageDige…
Browse files Browse the repository at this point in the history
…st#isEqual to avoid a potential timing attack
  • Loading branch information
mbhardwaj09 authored and ivassile committed Oct 18, 2022
1 parent 06d5219 commit 4abb472
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ boolean verify(final char[] guess) throws InvalidKeyException {
} catch (NoSuchAlgorithmException e) {
throw log.invalidKeyCannotVerifyPassword(e);
}
return Arrays.equals(getHash(), test);
return MessageDigest.isEqual(getHash(), test);
}

@Override
Expand Down Expand Up @@ -238,7 +238,7 @@ public boolean equals(final Object obj) {
return false;
}
UnixMD5CryptPasswordImpl other = (UnixMD5CryptPasswordImpl) obj;
return Arrays.equals(hash, other.hash) && Arrays.equals(salt, other.salt);
return MessageDigest.isEqual(hash, other.hash) && Arrays.equals(salt, other.salt);
}

private void readObject(ObjectInputStream ignored) throws NotSerializableException {
Expand Down

0 comments on commit 4abb472

Please sign in to comment.