diff options
| author | Alex Stapleton <alexs@prol.etari.at> | 2014-06-25 18:41:44 +0100 |
|---|---|---|
| committer | Alex Stapleton <alexs@prol.etari.at> | 2014-06-25 18:41:44 +0100 |
| commit | 1d1855cec99f65bf32e1c52bb0b8aa5d06bcc78b (patch) | |
| tree | b8bec6f11f39147bf687f1b5a8858ca5b29fcf3f /cryptography | |
| parent | 0690f91e01472f0b233a74ddd0c5d4211e14ea68 (diff) | |
| parent | beb1f0c6fe2a4b64d78ed9e84d887cf372929276 (diff) | |
| download | cryptography-1d1855cec99f65bf32e1c52bb0b8aa5d06bcc78b.tar.gz cryptography-1d1855cec99f65bf32e1c52bb0b8aa5d06bcc78b.tar.bz2 cryptography-1d1855cec99f65bf32e1c52bb0b8aa5d06bcc78b.zip | |
Merge pull request #1173 from Ayrx/ecc-fix
Fixed Fedora 20 ECC error
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 047ea8b2..81f944e5 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -995,19 +995,25 @@ class Backend(object): Generate a new private key on the named curve. """ - curve_nid = self._elliptic_curve_to_nid(curve) + if backend.elliptic_curve_supported(curve): + curve_nid = self._elliptic_curve_to_nid(curve) - ctx = self._lib.EC_KEY_new_by_curve_name(curve_nid) - assert ctx != self._ffi.NULL - ctx = self._ffi.gc(ctx, self._lib.EC_KEY_free) + ctx = self._lib.EC_KEY_new_by_curve_name(curve_nid) + assert ctx != self._ffi.NULL + ctx = self._ffi.gc(ctx, self._lib.EC_KEY_free) - res = self._lib.EC_KEY_generate_key(ctx) - assert res == 1 + res = self._lib.EC_KEY_generate_key(ctx) + assert res == 1 - res = self._lib.EC_KEY_check_key(ctx) - assert res == 1 + res = self._lib.EC_KEY_check_key(ctx) + assert res == 1 - return _EllipticCurvePrivateKey(self, ctx, curve) + return _EllipticCurvePrivateKey(self, ctx, curve) + else: + raise UnsupportedAlgorithm( + "Backend object does not support {0}.".format(curve.name), + _Reasons.UNSUPPORTED_ELLIPTIC_CURVE + ) def elliptic_curve_private_key_from_numbers(self, numbers): ec_key = self._ec_key_cdata_from_private_numbers(numbers) |
