mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
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:
parent
b4f7deaba5
commit
57b3649e55
1 changed files with 2 additions and 3 deletions
|
@ -50,9 +50,8 @@ public class PBKDF2SHA512 {
|
||||||
Preconditions.checkArgument(dkLen > 0, () -> "derived key length must be greater than zero");
|
Preconditions.checkArgument(dkLen > 0, () -> "derived key length must be greater than zero");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
if (dkLen > ((Math.pow(2, 32)) - 1) * H_LEN) {
|
// The algorithm in RFC 2898 section 5.2, says to check `dkLen` is not greater than (2^32 - 1) * `H_LEN`
|
||||||
throw new IllegalArgumentException("derived key too long");
|
// But that is not possible given `dkLen` is an `int` argument, so we omit the check.
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
int l = (dkLen + H_LEN - 1) / H_LEN; // Divide by H_LEN with rounding up
|
int l = (dkLen + H_LEN - 1) / H_LEN; // Divide by H_LEN with rounding up
|
||||||
// int r = dkLen - (l-1)*hLen;
|
// int r = dkLen - (l-1)*hLen;
|
||||||
|
|
Loading…
Add table
Reference in a new issue