From 7bd0df4f60a9fb919985e1375ddf289ccb42fbe8 Mon Sep 17 00:00:00 2001 From: whiteowl3 <71030468+whiteowl3@users.noreply.github.com> Date: Sat, 26 Feb 2022 17:45:36 -0500 Subject: don't block ec/ed keys from_cryptography_key() (#1096) * don't block ec/ed keys from_cryptography_key() * clean up test comments * properly describe test --- src/OpenSSL/crypto.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/OpenSSL') diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 5a54bc9..79f7f4b 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -5,7 +5,13 @@ import functools from functools import partial from cryptography import utils, x509 -from cryptography.hazmat.primitives.asymmetric import dsa, rsa +from cryptography.hazmat.primitives.asymmetric import ( + dsa, + ec, + ed25519, + ed448, + rsa, +) from OpenSSL._util import ( ffi as _ffi, @@ -254,6 +260,9 @@ class PKey: rsa.RSAPrivateKey, dsa.DSAPublicKey, dsa.DSAPrivateKey, + ec.EllipticCurvePrivateKey, + ed25519.Ed25519PrivateKey, + ed448.Ed448PrivateKey, ), ): raise TypeError("Unsupported key type") @@ -351,7 +360,7 @@ class PKey: raise TypeError("public key only") if _lib.EVP_PKEY_type(self.type()) != _lib.EVP_PKEY_RSA: - raise TypeError("key type unsupported") + raise TypeError("Only RSA keys can currently be checked.") rsa = _lib.EVP_PKEY_get1_RSA(self._pkey) rsa = _ffi.gc(rsa, _lib.RSA_free) -- cgit v1.2.1