OLD | NEW |
1 """Factory functions for asymmetric cryptography. | 1 """Factory functions for asymmetric cryptography. |
2 @sort: generateRSAKey, parseXMLKey, parsePEMKey, parseAsPublicKey, | 2 @sort: generateRSAKey, parseXMLKey, parsePEMKey, parseAsPublicKey, |
3 parseAsPrivateKey | 3 parseAsPrivateKey |
4 """ | 4 """ |
5 | 5 |
6 from compat import * | 6 from compat import * |
7 | 7 |
8 from RSAKey import RSAKey | 8 from rsakey import RSAKey |
9 from Python_RSAKey import Python_RSAKey | 9 from python_rsakey import Python_RSAKey |
10 import cryptomath | 10 import cryptomath |
11 | 11 |
12 if cryptomath.m2cryptoLoaded: | 12 if cryptomath.m2cryptoLoaded: |
13 from OpenSSL_RSAKey import OpenSSL_RSAKey | 13 from openssl_rsakey import OpenSSL_RSAKey |
14 | 14 |
15 if cryptomath.pycryptoLoaded: | 15 if cryptomath.pycryptoLoaded: |
16 from PyCrypto_RSAKey import PyCrypto_RSAKey | 16 from pycrypto_rsakey import PyCrypto_RSAKey |
17 | 17 |
18 # ************************************************************************** | 18 # ************************************************************************** |
19 # Factory Functions for RSA Keys | 19 # Factory Functions for RSA Keys |
20 # ************************************************************************** | 20 # ************************************************************************** |
21 | 21 |
22 def generateRSAKey(bits, implementations=["openssl", "python"]): | 22 def generateRSAKey(bits, implementations=["openssl", "python"]): |
23 """Generate an RSA key with the specified bit length. | 23 """Generate an RSA key with the specified bit length. |
24 | 24 |
25 @type bits: int | 25 @type bits: int |
26 @param bits: Desired bit length of the new key's modulus. | 26 @param bits: Desired bit length of the new key's modulus. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 raise ValueError("No acceptable implementations") | 234 raise ValueError("No acceptable implementations") |
235 | 235 |
236 def _createPrivateRSAKey(n, e, d, p, q, dP, dQ, qInv, | 236 def _createPrivateRSAKey(n, e, d, p, q, dP, dQ, qInv, |
237 implementations = ["pycrypto", "python"]): | 237 implementations = ["pycrypto", "python"]): |
238 for implementation in implementations: | 238 for implementation in implementations: |
239 if implementation == "pycrypto" and cryptomath.pycryptoLoaded: | 239 if implementation == "pycrypto" and cryptomath.pycryptoLoaded: |
240 return PyCrypto_RSAKey(n, e, d, p, q, dP, dQ, qInv) | 240 return PyCrypto_RSAKey(n, e, d, p, q, dP, dQ, qInv) |
241 elif implementation == "python": | 241 elif implementation == "python": |
242 return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) | 242 return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) |
243 raise ValueError("No acceptable implementations") | 243 raise ValueError("No acceptable implementations") |
OLD | NEW |