From 1c9aa9b781e35d515df0644cd2c2d92e9696e813 Mon Sep 17 00:00:00 2001 From: Carsten Wentzlow Date: Mon, 12 Dec 2011 16:34:11 +0100 Subject: [PATCH] bugfix in openpgp_crypto_getRandomBigIntegerInRange() using compareTo() from BigInteger library --- src/ciphers/openpgp.crypto.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ciphers/openpgp.crypto.js b/src/ciphers/openpgp.crypto.js index b18cd0a9..b9619d03 100644 --- a/src/ciphers/openpgp.crypto.js +++ b/src/ciphers/openpgp.crypto.js @@ -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); }