diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 3ef0e9b6e..02a0301f8 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -10,7 +10,7 @@ text_type as _text_type, PY3 as _PY3) -from cryptography.hazmat.primitives.asymmetric import dsa, rsa +from cryptography.hazmat.primitives.asymmetric import ec, dsa, rsa from OpenSSL._util import ( ffi as _ffi, @@ -212,11 +212,14 @@ def from_cryptography_key(cls, crypto_key): """ pkey = cls() if not isinstance(crypto_key, (rsa.RSAPublicKey, rsa.RSAPrivateKey, - dsa.DSAPublicKey, dsa.DSAPrivateKey)): + dsa.DSAPublicKey, dsa.DSAPrivateKey, + ec.EllipticCurvePublicKey, + ec.EllipticCurvePrivateKey)): raise TypeError("Unsupported key type") pkey._pkey = crypto_key._evp_pkey - if isinstance(crypto_key, (rsa.RSAPublicKey, dsa.DSAPublicKey)): + if isinstance(crypto_key, (rsa.RSAPublicKey, dsa.DSAPublicKey, + ec.EllipticCurvePublicKey)): pkey._only_public = True pkey._initialized = True return pkey diff --git a/tests/test_crypto.py b/tests/test_crypto.py index 10f471800..cc7065927 100644 --- a/tests/test_crypto.py +++ b/tests/test_crypto.py @@ -772,6 +772,7 @@ def test_convert_from_cryptography_public_key(self): assert pkey._only_public is True assert pkey._initialized is True + @pytest.mark.skip(reason="EC Pkeys are allowed to enable SCT verification") def test_convert_from_cryptography_unsupported_type(self): """ PKey.from_cryptography_key raises TypeError with an unsupported type.