bugfix in openpgp_crypto_getRandomBigIntegerInRange() using compareTo() from BigInteger library

This commit is contained in:
Carsten Wentzlow 2011-12-12 16:34:11 +01:00
parent 08cb01e932
commit 1c9aa9b781

View File

@ -447,12 +447,12 @@ function openpgp_crypto_getRandomBigInteger(bits) {
}
function openpgp_crypto_getRandomBigIntegerInRange(min, max) {
if (max < min)
if (max.compareTo(min) <= 0)
return;
var range = max.subtract(min);
var r = openpgp_crypto_getRandomBigInteger(range.bitLength());
while (r > range) {
r = openpgp_crypto_getRandomBigInteger(range.bitLength());
}
return min.add(r);
return min.add(r);
}