diff options
author | Barry Mead <barrymead@cox.net> | 2010-02-23 23:17:16 -0700 |
---|---|---|
committer | Barry Mead <barrymead@cox.net> | 2010-02-23 23:17:16 -0700 |
commit | b834cb936a8933ccd67ef099c625521a7a2fcfc0 (patch) | |
tree | ea12c7621d50d72be5714f08ce35933f9fb7a55d | |
parent | f6679448c2fc8d5dd72ff6090f21a1d88d1e19ab (diff) | |
download | rsa-b834cb936a8933ccd67ef099c625521a7a2fcfc0.tar.gz |
replaced b^2 with b*b in jacobi,& fixed a comment in jacobi-witness
-rw-r--r-- | rsa/__init__.py | 4 | ||||
-rw-r--r-- | rsa/fastrsa.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/rsa/__init__.py b/rsa/__init__.py index eef217f..306a569 100644 --- a/rsa/__init__.py +++ b/rsa/__init__.py @@ -208,7 +208,7 @@ def jacobi(a, b): result = -result a, b = b % a, a else: - if (((b ** 2) - 1) >> 3) & 1: + if (((b * b) - 1) >> 3) & 1: result = -result a >>= 1 if a == 0: return 0 @@ -229,7 +229,7 @@ def randomized_primality_testing(n, k): """Calculates whether n is composite (which is always correct) or prime (which is incorrect with error probability 2**-k) - Returns False if the number if composite, and True if it's + Returns False if the number is composite, and True if it's probably prime. """ diff --git a/rsa/fastrsa.py b/rsa/fastrsa.py index 4fd5db6..6e32e8f 100644 --- a/rsa/fastrsa.py +++ b/rsa/fastrsa.py @@ -208,7 +208,7 @@ def jacobi(a, b): result = -result a, b = b % a, a else: - if (((b ** 2) - 1) >> 3) & 1: + if (((b * b) - 1) >> 3) & 1: result = -result a >>= 1 if a == 0: return 0 @@ -229,7 +229,7 @@ def randomized_primality_testing(n, k): """Calculates whether n is composite (which is always correct) or prime (which is incorrect with error probability 2**-k) - Returns False if the number if composite, and True if it's + Returns False if the number is composite, and True if it's probably prime. """ @@ -512,7 +512,7 @@ def chopstring(message, key, funcref): msglen = len(message) mbits = msglen * 8 - # floor of log deducts 1 bit of n and the - 1, deducts the second bit. + #Set aside 2-bits so setting of safebit won't overflow modulo n nbits = bit_size(n) - 2 # leave room for safebit nbytes = nbits / 8 blocks = msglen / nbytes |