diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-11 19:06:17 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-12 09:41:21 -0500 |
commit | 6e3b6b18b26b05122cf43001dbddd2f65220fe21 (patch) | |
tree | fc6caa8259f2a70c8195512009749b9456c4abde | |
parent | b4f638a6f89365658a13b41f78cbd59fbc352fd8 (diff) | |
download | cryptography-6e3b6b18b26b05122cf43001dbddd2f65220fe21.tar.gz cryptography-6e3b6b18b26b05122cf43001dbddd2f65220fe21.tar.bz2 cryptography-6e3b6b18b26b05122cf43001dbddd2f65220fe21.zip |
inline a single use function
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 6613a07c..2036093e 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -382,7 +382,20 @@ class Backend(object): key_size >= 512) def load_rsa_private_numbers(self, numbers): - rsa_cdata = self._rsa_cdata_from_private_numbers(numbers) + rsa_cdata = self._lib.RSA_new() + assert rsa_cdata != self._ffi.NULL + rsa_cdata = self._ffi.gc(rsa_cdata, self._lib.RSA_free) + rsa_cdata.p = self._int_to_bn(numbers.p) + rsa_cdata.q = self._int_to_bn(numbers.q) + rsa_cdata.d = self._int_to_bn(numbers.d) + rsa_cdata.dmp1 = self._int_to_bn(numbers.dmp1) + rsa_cdata.dmq1 = self._int_to_bn(numbers.dmq1) + rsa_cdata.iqmp = self._int_to_bn(numbers.iqmp) + rsa_cdata.e = self._int_to_bn(numbers.public_numbers.e) + rsa_cdata.n = self._int_to_bn(numbers.public_numbers.n) + res = self._lib.RSA_blinding_on(rsa_cdata, self._ffi.NULL) + assert res == 1 + return _RSAPrivateKey(self, rsa_cdata) def load_rsa_public_numbers(self, numbers): @@ -519,23 +532,6 @@ class Backend(object): return ctx - def _rsa_cdata_from_private_numbers(self, private_numbers): - ctx = self._lib.RSA_new() - assert ctx != self._ffi.NULL - ctx = self._ffi.gc(ctx, self._lib.RSA_free) - ctx.p = self._int_to_bn(private_numbers.p) - ctx.q = self._int_to_bn(private_numbers.q) - ctx.d = self._int_to_bn(private_numbers.d) - ctx.dmp1 = self._int_to_bn(private_numbers.dmp1) - ctx.dmq1 = self._int_to_bn(private_numbers.dmq1) - ctx.iqmp = self._int_to_bn(private_numbers.iqmp) - ctx.e = self._int_to_bn(private_numbers.public_numbers.e) - ctx.n = self._int_to_bn(private_numbers.public_numbers.n) - res = self._lib.RSA_blinding_on(ctx, self._ffi.NULL) - assert res == 1 - - return ctx - def _rsa_cdata_from_public_numbers(self, public_numbers): # Does not GC the RSA cdata. You *must* make sure it's freed # correctly yourself! |