Remove unused function

This commit is contained in:
Alex Gaynor 2014-03-29 17:17:20 -07:00
parent 5a430def22
commit 23528069ec
1 changed files with 0 additions and 20 deletions

View File

@ -20,31 +20,11 @@
Utility functions for dealing with primes. Utility functions for dealing with primes.
""" """
from Crypto.Util import number
from paramiko import util from paramiko import util
from paramiko.py3compat import byte_mask, long from paramiko.py3compat import byte_mask, long
from paramiko.ssh_exception import SSHException from paramiko.ssh_exception import SSHException
def _generate_prime(bits, rng):
"""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 = rng.read((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(rng, n): def _roll_random(rng, n):
"""returns a random # from 0 to N-1""" """returns a random # from 0 to N-1"""
bits = util.bit_length(n - 1) bits = util.bit_length(n - 1)