summaryrefslogtreecommitdiff
path: root/rsa/prime.py
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-01-27 18:29:43 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2016-01-27 18:29:43 +0100
commit282069092d41c67fbda10cb5ffa06a58cd9c5baf (patch)
tree33e8acb3d09346b35340f7bdfb9795281292913a /rsa/prime.py
parentd9dbf6e1bf84466363b90a8c0928149841b70f67 (diff)
downloadrsa-git-282069092d41c67fbda10cb5ffa06a58cd9c5baf.tar.gz
Fixed PEP8 style issues
Diffstat (limited to 'rsa/prime.py')
-rw-r--r--rsa/prime.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/rsa/prime.py b/rsa/prime.py
index 4763d16..2ac1ffe 100644
--- a/rsa/prime.py
+++ b/rsa/prime.py
@@ -20,10 +20,10 @@ Implementation based on the book Algorithm Design by Michael T. Goodrich and
Roberto Tamassia, 2002.
"""
-__all__ = ['getprime', 'are_relatively_prime']
-
import rsa.randnum
+__all__ = ['getprime', 'are_relatively_prime']
+
def gcd(p, q):
"""Returns the greatest common divisor of p and q
@@ -47,7 +47,8 @@ def jacobi(a, b):
assert a > 0
assert b > 0
- if a == 0: return 0
+ if a == 0:
+ return 0
result = 1
while a > 1:
if a & 1:
@@ -58,7 +59,8 @@ def jacobi(a, b):
if (((b * b) - 1) >> 3) & 1:
result = -result
a >>= 1
- if a == 0: return 0
+ if a == 0:
+ return 0
return result
@@ -69,7 +71,8 @@ def jacobi_witness(x, n):
f = pow(x, n >> 1, n)
- if j == f: return False
+ if j == f:
+ return False
return True
@@ -93,7 +96,8 @@ def randomized_primality_testing(n, k):
for _ in range(k):
x = rsa.randnum.randint(n - 1)
- if jacobi_witness(x, n): return False
+ if jacobi_witness(x, n):
+ return False
return True