summaryrefslogtreecommitdiff
path: root/src/OpenSSL/crypto.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/OpenSSL/crypto.py')
-rw-r--r--src/OpenSSL/crypto.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index adf03b4..d40f23c 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -288,15 +288,15 @@ class PKey(object):
if not isinstance(bits, int):
raise TypeError("bits must be an integer")
- # TODO Check error return
- exponent = _lib.BN_new()
- exponent = _ffi.gc(exponent, _lib.BN_free)
- _lib.BN_set_word(exponent, _lib.RSA_F4)
-
if type == TYPE_RSA:
if bits <= 0:
raise ValueError("Invalid number of bits")
+ # TODO Check error return
+ exponent = _lib.BN_new()
+ exponent = _ffi.gc(exponent, _lib.BN_free)
+ _lib.BN_set_word(exponent, _lib.RSA_F4)
+
rsa = _lib.RSA_new()
result = _lib.RSA_generate_key_ex(rsa, bits, exponent, _ffi.NULL)