summaryrefslogtreecommitdiff
path: root/paramiko/primes.py
diff options
context:
space:
mode:
authorRobey Pointer <robey@master-shake.local>2006-01-14 22:30:08 -0800
committerRobey Pointer <robey@master-shake.local>2006-01-14 22:30:08 -0800
commitcb3008b402a6a411204d0dc060c2f85a548c1c7e (patch)
tree5c02d2f311bee41547f4fa91f706b7d0dce16382 /paramiko/primes.py
parent26397bff47bc1005a7d4b42a95bfb72f213cf26e (diff)
downloadparamiko-cb3008b402a6a411204d0dc060c2f85a548c1c7e.tar.gz
[project @ robey@master-shake.local-20060115063008-4f68552398868788]
fix a bunch of pychecker warnings, some of which were actual (but unlikely) bugs
Diffstat (limited to 'paramiko/primes.py')
-rw-r--r--paramiko/primes.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/paramiko/primes.py b/paramiko/primes.py
index 36773944..fa0175d8 100644
--- a/paramiko/primes.py
+++ b/paramiko/primes.py
@@ -23,6 +23,7 @@ Utility functions for dealing with primes.
from Crypto.Util import number
from paramiko import util
+from paramiko.ssh_exception import SSHException
def _generate_prime(bits, randpool):
@@ -39,7 +40,8 @@ def _generate_prime(bits, randpool):
while not number.isPrime(n):
n += 2
if util.bit_length(n) == bits:
- return n
+ break
+ return n
def _roll_random(rpool, n):
"returns a random # from 0 to N-1"
@@ -59,7 +61,8 @@ def _roll_random(rpool, n):
x = chr(ord(x[0]) & hbyte_mask) + x[1:]
num = util.inflate_long(x, 1)
if num < n:
- return num
+ break
+ return num
class ModulusPack (object):
@@ -75,8 +78,8 @@ class ModulusPack (object):
self.randpool = rpool
def _parse_modulus(self, line):
- timestamp, type, tests, tries, size, generator, modulus = line.split()
- type = int(type)
+ timestamp, mod_type, tests, tries, size, generator, modulus = line.split()
+ mod_type = int(mod_type)
tests = int(tests)
tries = int(tries)
size = int(size)
@@ -87,7 +90,7 @@ class ModulusPack (object):
# type 2 (meets basic structural requirements)
# test 4 (more than just a small-prime sieve)
# tries < 100 if test & 4 (at least 100 tries of miller-rabin)
- if (type < 2) or (tests < 4) or ((tests & 4) and (tests < 8) and (tries < 100)):
+ if (mod_type < 2) or (tests < 4) or ((tests & 4) and (tests < 8) and (tries < 100)):
self.discarded.append((modulus, 'does not meet basic requirements'))
return
if generator == 0: