PBKDF2SHA512: calculate l with integer math

This commit is contained in:
Sean Gilligan 2023-09-14 11:47:38 -07:00 committed by Andreas Schildbach
parent 5a11957eb3
commit b4f7deaba5

View File

@ -54,7 +54,7 @@ public class PBKDF2SHA512 {
throw new IllegalArgumentException("derived key too long"); throw new IllegalArgumentException("derived key too long");
} }
try { try {
int l = (int) Math.ceil((double) dkLen / (double) H_LEN); 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;
for (int i = 1; i <= l; i++) { for (int i = 1; i <= l; i++) {