From 179eb1d0917ddc1067d056127e08e952206e0e91 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 5 Jun 2018 17:56:07 -0400 Subject: Only allocate exponent in the TYPE_RSA path. (#767) Not much point in making it otherwise. --- src/OpenSSL/crypto.py | 10 +++++----- 1 file 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) -- cgit v1.2.1