diff options
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 25 | ||||
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/dsa.py | 14 |
2 files changed, 4 insertions, 35 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index 9c0af350..948584ff 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -603,29 +603,10 @@ class Backend(object): return _DSAParameters(self, ctx) - def _dup_dsa_params(self, dsa_cdata): - dsa_cdata_dup = self._lib.DSA_new() - self.openssl_assert(dsa_cdata_dup != self._ffi.NULL) - dsa_cdata_dup = self._ffi.gc(dsa_cdata_dup, self._lib.DSA_free) - p = self._ffi.new("BIGNUM **") - q = self._ffi.new("BIGNUM **") - g = self._ffi.new("BIGNUM **") - self._lib.DSA_get0_pqg(dsa_cdata, p, q, g) - self.openssl_assert(p[0] != self._ffi.NULL) - self.openssl_assert(q[0] != self._ffi.NULL) - self.openssl_assert(g[0] != self._ffi.NULL) - p_dup = self._lib.BN_dup(p[0]) - q_dup = self._lib.BN_dup(q[0]) - g_dup = self._lib.BN_dup(g[0]) - self.openssl_assert(p_dup != self._ffi.NULL) - self.openssl_assert(q_dup != self._ffi.NULL) - self.openssl_assert(g_dup != self._ffi.NULL) - res = self._lib.DSA_set0_pqg(dsa_cdata_dup, p_dup, q_dup, g_dup) - self.openssl_assert(res == 1) - return dsa_cdata_dup - def generate_dsa_private_key(self, parameters): - ctx = self._dup_dsa_params(parameters._dsa_cdata) + ctx = self._lib.DSAparams_dup(parameters._dsa_cdata) + self.openssl_assert(ctx != self._ffi.NULL) + ctx = self._ffi.gc(ctx, self._lib.DSA_free) self._lib.DSA_generate_key(ctx) evp_pkey = self._dsa_cdata_to_evp_pkey(ctx) diff --git a/src/cryptography/hazmat/backends/openssl/dsa.py b/src/cryptography/hazmat/backends/openssl/dsa.py index 20b5f408..1e75dff9 100644 --- a/src/cryptography/hazmat/backends/openssl/dsa.py +++ b/src/cryptography/hazmat/backends/openssl/dsa.py @@ -162,23 +162,11 @@ class _DSAPrivateKey(object): ) def public_key(self): - dsa_cdata = self._backend._lib.DSA_new() + dsa_cdata = self._backend._lib.DSAparams_dup(self._dsa_cdata) self._backend.openssl_assert(dsa_cdata != self._backend._ffi.NULL) dsa_cdata = self._backend._ffi.gc( dsa_cdata, self._backend._lib.DSA_free ) - p = self._backend._ffi.new("BIGNUM **") - q = self._backend._ffi.new("BIGNUM **") - g = self._backend._ffi.new("BIGNUM **") - self._backend._lib.DSA_get0_pqg(self._dsa_cdata, p, q, g) - self._backend.openssl_assert(p[0] != self._backend._ffi.NULL) - self._backend.openssl_assert(q[0] != self._backend._ffi.NULL) - self._backend.openssl_assert(g[0] != self._backend._ffi.NULL) - p_dup = self._backend._lib.BN_dup(p[0]) - q_dup = self._backend._lib.BN_dup(q[0]) - g_dup = self._backend._lib.BN_dup(g[0]) - res = self._backend._lib.DSA_set0_pqg(dsa_cdata, p_dup, q_dup, g_dup) - self._backend.openssl_assert(res == 1) pub_key = self._backend._ffi.new("BIGNUM **") self._backend._lib.DSA_get0_key( self._dsa_cdata, pub_key, self._backend._ffi.NULL |