summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Mead <barrymead@cox.net>2010-02-19 17:11:10 -0700
committerBarry Mead <barrymead@cox.net>2010-02-19 17:11:10 -0700
commit92f8c7eab8fd581dbfd3d8cf190cae71ac9ba59b (patch)
treeb2cfa161a4d8a5ff922d65fbbf3f16118e744e05
parent945aeebafd384fd87c55e6b0ecba4b64b3cddd81 (diff)
downloadrsa-92f8c7eab8fd581dbfd3d8cf190cae71ac9ba59b.tar.gz
Removed unnecessary prime qualification per RSA website
-rw-r--r--rsa/__init__.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/rsa/__init__.py b/rsa/__init__.py
index de29ec9..d7fddd5 100644
--- a/rsa/__init__.py
+++ b/rsa/__init__.py
@@ -314,12 +314,11 @@ def find_p_q(nbits):
"""Returns a tuple of two different primes of nbits bits"""
pbits = nbits + (nbits/16) #Make sure that p and q aren't too close
qbits = nbits - (nbits/16) #or the factoring programs can factor n
+ p = getprime(pbits)
while True:
- p = getprime(pbits)
q = getprime(qbits)
- phi_n = (p-1)*(q-1)
- #Make sure p and q are different and phi_n is not divisible by 256
- if not (q == p or phi_n & 255 == 0): break
+ #Make sure p and q are different.
+ if not q == p: break
return (p, q)
def extended_gcd(a, b):