OLD | NEW |
1 """PyCrypto RSA implementation.""" | 1 """PyCrypto RSA implementation.""" |
2 | 2 |
3 from cryptomath import * | 3 from cryptomath import * |
4 | 4 |
5 from RSAKey import * | 5 from rsakey import * |
6 from Python_RSAKey import Python_RSAKey | 6 from python_rsakey import Python_RSAKey |
7 | 7 |
8 if pycryptoLoaded: | 8 if pycryptoLoaded: |
9 | 9 |
10 from Crypto.PublicKey import RSA | 10 from Crypto.PublicKey import RSA |
11 | 11 |
12 class PyCrypto_RSAKey(RSAKey): | 12 class PyCrypto_RSAKey(RSAKey): |
13 def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): | 13 def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): |
14 if not d: | 14 if not d: |
15 self.rsa = RSA.construct( (n, e) ) | 15 self.rsa = RSA.construct( (n, e) ) |
16 else: | 16 else: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 def writeXMLPublicKey(self, indent=''): | 52 def writeXMLPublicKey(self, indent=''): |
53 return Python_RSAKey(self.n, self.e).write(indent) | 53 return Python_RSAKey(self.n, self.e).write(indent) |
54 | 54 |
55 def generate(bits): | 55 def generate(bits): |
56 key = PyCrypto_RSAKey() | 56 key = PyCrypto_RSAKey() |
57 def f(numBytes): | 57 def f(numBytes): |
58 return bytesToString(getRandomBytes(numBytes)) | 58 return bytesToString(getRandomBytes(numBytes)) |
59 key.rsa = RSA.generate(bits, f) | 59 key.rsa = RSA.generate(bits, f) |
60 return key | 60 return key |
61 generate = staticmethod(generate) | 61 generate = staticmethod(generate) |
OLD | NEW |