aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-06 17:43:49 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-06 17:43:49 -0500
commitd50c1e92ac789d8912f257350fe3861fce9d1095 (patch)
treebceb31f10d132516c09bc3a12514118a3f9a57cd /cryptography
parentf1de2f78cfd2b19eb4e2485ff36008581b088292 (diff)
downloadcryptography-d50c1e92ac789d8912f257350fe3861fce9d1095.tar.gz
cryptography-d50c1e92ac789d8912f257350fe3861fce9d1095.tar.bz2
cryptography-d50c1e92ac789d8912f257350fe3861fce9d1095.zip
add rsa_generate_private_key function to replace RSAPrivateKey.generate
refs #1026. #1101 is dependent on this
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/primitives/asymmetric/rsa.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py
index 481797fe..94f07902 100644
--- a/cryptography/hazmat/primitives/asymmetric/rsa.py
+++ b/cryptography/hazmat/primitives/asymmetric/rsa.py
@@ -21,6 +21,17 @@ from cryptography.hazmat.backends.interfaces import RSABackend
from cryptography.hazmat.primitives import interfaces
+def generate_rsa_private_key(public_exponent, key_size, backend):
+ if not isinstance(backend, RSABackend):
+ raise UnsupportedAlgorithm(
+ "Backend object does not implement RSABackend.",
+ _Reasons.BACKEND_MISSING_INTERFACE
+ )
+
+ _verify_rsa_parameters(public_exponent, key_size)
+ return backend.generate_rsa_private_key(public_exponent, key_size)
+
+
def _verify_rsa_parameters(public_exponent, key_size):
if public_exponent < 3:
raise ValueError("public_exponent must be >= 3.")