diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-14 10:56:05 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-14 10:56:05 -0400 |
commit | 191fd465f166588922ccbf08b65d4479d8520d6a (patch) | |
tree | 673a3ad36d919009d2621b6e1d3b102cf7988aa9 /paramiko/primes.py | |
parent | 6c6969c1882e62d6249264d2df46ff452eb53e7e (diff) | |
parent | fa86d655dc8f08eb9171930c41b508e2bee08b08 (diff) | |
download | paramiko-191fd465f166588922ccbf08b65d4479d8520d6a.tar.gz |
Merge branch 'master' into use-urandom
Conflicts:
paramiko/dsskey.py
paramiko/ecdsakey.py
paramiko/hostkeys.py
paramiko/kex_gex.py
paramiko/kex_group1.py
paramiko/pkey.py
paramiko/primes.py
paramiko/rsakey.py
tests/test_pkey.py
Diffstat (limited to 'paramiko/primes.py')
-rw-r--r-- | paramiko/primes.py | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/paramiko/primes.py b/paramiko/primes.py index 33cd6510..8e02e80c 100644 --- a/paramiko/primes.py +++ b/paramiko/primes.py @@ -22,31 +22,11 @@ Utility functions for dealing with primes. import os -from Crypto.Util import number - from paramiko import util from paramiko.py3compat import byte_mask, long from paramiko.ssh_exception import SSHException -def _generate_prime(bits): - """primtive attempt at prime generation""" - hbyte_mask = pow(2, bits % 8) - 1 - while True: - # loop catches the case where we increment n into a higher bit-range - x = os.urandom((bits + 7) // 8) - if hbyte_mask > 0: - x = byte_mask(x[0], hbyte_mask) + x[1:] - n = util.inflate_long(x, 1) - n |= 1 - n |= (1 << (bits - 1)) - while not number.isPrime(n): - n += 2 - if util.bit_length(n) == bits: - break - return n - - def _roll_random(n): """returns a random # from 0 to N-1""" bits = util.bit_length(n - 1) |