diff options
author | tailor <cygnus@janrain.com> | 2006-01-06 22:42:25 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-01-06 22:42:25 +0000 |
commit | 3a3850a8e96494c07ab9f60875db683384e246a6 (patch) | |
tree | b69cd04dc280a7022a22b789de299e251d8986d2 | |
parent | 059c05572c93a3d67608f012db4ddcc43b4bbd86 (diff) | |
download | php-openid-3a3850a8e96494c07ab9f60875db683384e246a6.zip php-openid-3a3850a8e96494c07ab9f60875db683384e246a6.tar.gz php-openid-3a3850a8e96494c07ab9f60875db683384e246a6.tar.bz2 |
[project @ Fixed some minor bugs in randrange]
-rw-r--r-- | Net/OpenID/CryptUtil.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Net/OpenID/CryptUtil.php b/Net/OpenID/CryptUtil.php index 0ce8f60..4364cda 100644 --- a/Net/OpenID/CryptUtil.php +++ b/Net/OpenID/CryptUtil.php @@ -302,7 +302,7 @@ class Net_OpenID_CryptUtil { $start = 0; } - $r = $lib->sub($stop, $start); + $r = $lib->div($lib->sub($stop, $start), $step); // DO NOT MODIFY THIS VALUE. $rbytes = Net_OpenID_CryptUtil::longToBinary($r); @@ -311,7 +311,7 @@ class Net_OpenID_CryptUtil { list($duplicate, $nbytes) = $Net_OpenID_CryptUtil_duplicate_cache[$rbytes]; } else { - if ($rbytes[0] == '\x00') { + if ($rbytes[0] == "\x00") { $nbytes = strlen($rbytes) - 1; } else { $nbytes = strlen($rbytes); @@ -332,13 +332,15 @@ class Net_OpenID_CryptUtil { } while (1) { - $bytes = '\x00' . Net_OpenID_CryptUtil::getBytes($nbytes); + $bytes = "\x00" . Net_OpenID_CryptUtil::getBytes($nbytes); $n = Net_OpenID_CryptUtil::binaryToLong($bytes); - // Keep looping if this value is in the low duplicated range + // Keep looping if this value is in the low duplicated + // range if ($lib->cmp($n, $duplicate) >= 0) { break; } } + return $lib->add($start, $lib->mul($lib->mod($n, $r), $step)); } |