PBKDF2SHA512: replace unneeded check for max dkLen with comment

Since the check for `dkLen > (2^32 - 1) * H_LEN` is effectively a no-op,
replace it with a comment.
This commit is contained in:
Sean Gilligan 2023-09-15 13:00:17 -07:00 committed by Andreas Schildbach
parent b4f7deaba5
commit 57b3649e55

View file

@ -50,9 +50,8 @@ public class PBKDF2SHA512 {
Preconditions.checkArgument(dkLen > 0, () -> "derived key length must be greater than zero");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (dkLen > ((Math.pow(2, 32)) - 1) * H_LEN) {
throw new IllegalArgumentException("derived key too long");
}
// The algorithm in RFC 2898 section 5.2, says to check `dkLen` is not greater than (2^32 - 1) * `H_LEN`
// But that is not possible given `dkLen` is an `int` argument, so we omit the check.
try {
int l = (dkLen + H_LEN - 1) / H_LEN; // Divide by H_LEN with rounding up
// int r = dkLen - (l-1)*hLen;