# Path: jose/constants.py
# ALGORITHMS = Algorithms()
# 
# Path: tests/algorithms/test_EC.py
# TOO_SHORT_PRIVATE_KEY = b"""\
# -----BEGIN EC PRIVATE KEY-----
# MHcCAQEEIMlUyYGOpjV4bbW0C9FKS2zkspD0L/5vJLnr6sJoLdc+oAoGCCqGSM49
# AwEHoUQDQgAE6TDUNj5QXl+RKdZvBV+cg7Td6cJRB+Ta8XAhIuCAzonq0Ix//1+C
# pNSsy11sIKmMl61YJzxvZ6WkNluBmkDPCQ==
# -----END EC PRIVATE KEY-----
# """
# DER_SIGNATURE = (
#     b"0F\x02!\x00\x89yG\x81W\x01\x11\x9b0\x08\xa4\xd0\xe3g([\x07\xb5\x01\xb3"
#     b"\x9d\xdf \xd1\xbc\xedK\x01\x87:}\xf2\x02!\x00\xb2shTA\x00\x1a\x13~\xba"
#     b"J\xdb\xeem\x12\x1e\xfeMO\x04\xb2[\x86A\xbd\xc6hu\x953X\x1e"
# )
# RAW_SIGNATURE = (
#     b"\x89yG\x81W\x01\x11\x9b0\x08\xa4\xd0\xe3g([\x07\xb5\x01\xb3\x9d\xdf "
#     b"\xd1\xbc\xedK\x01\x87:}\xf2\xb2shTA\x00\x1a\x13~\xbaJ\xdb\xeem\x12\x1e"
#     b"\xfeMO\x04\xb2[\x86A\xbd\xc6hu\x953X\x1e"
# )
# def _backend_exception_types():
# def test_key_from_ecdsa():
# def test_cryptography_sig_component_length(algorithm, expected_length):
# def test_cryptograhy_der_to_raw():
# def test_cryptograhy_raw_to_der():
#     def test_key_from_pem(self):
#     def test_to_pem(self):
#     def test_key_too_short(self, Backend, ExceptionType):
#     def test_get_public_key(self):
#     def test_string_secret(self):
#     def test_object(self):
#     def test_invalid_algorithm(self):
#     def test_EC_jwk(self):
#     def test_verify(self):
#     def assert_parameters(self, as_dict, private):
#     def test_to_dict(self):
# class TestECAlgorithm:


import pytest
    from jose.backends.cryptography_backend import CryptographyECKey
    from jose.backends.ecdsa_backend import ECDSAECKey
from jose.constants import ALGORITHMS
from .test_EC import private_key
except ImportError:
    ECDSAECKey = CryptographyECKey = None



@pytest.mark.backend_compatibility
@pytest.mark.skipif(
    None in (ECDSAECKey, CryptographyECKey),
    reason="Multiple crypto backends not available for backend compatibility tests",
)
class TestBackendEcdsaCompatibility:
    @pytest.mark.parametrize("BackendSign", [ECDSAECKey, CryptographyECKey])
    @pytest.mark.parametrize("BackendVerify", [ECDSAECKey, CryptographyECKey])
    def test_signing_parity(self, BackendSign, BackendVerify):
        key_sign = BackendSign(private_key, ALGORITHMS.ES256)
        key_verify = BackendVerify(private_key, ALGORITHMS.ES256).public_key()

        msg = b"test"
        sig = key_sign.sign(msg)

        # valid signature
        assert key_verify.verify(msg, sig)

        # invalid signature
        assert not key_verify.verify(msg, b"n" * 64)

    @pytest.mark.parametrize("BackendFrom", [ECDSAECKey, CryptographyECKey])
    @pytest.mark.parametrize("BackendTo", [ECDSAECKey, CryptographyECKey])
    def test_public_key_to_pem(self, BackendFrom, BackendTo):
        key = BackendFrom(private_key, ALGORITHMS.ES256)

# Path: jose/constants.py
# ALGORITHMS = Algorithms()
# 
# Path: tests/algorithms/test_EC.py
# TOO_SHORT_PRIVATE_KEY = b"""\
# -----BEGIN EC PRIVATE KEY-----
# MHcCAQEEIMlUyYGOpjV4bbW0C9FKS2zkspD0L/5vJLnr6sJoLdc+oAoGCCqGSM49
# AwEHoUQDQgAE6TDUNj5QXl+RKdZvBV+cg7Td6cJRB+Ta8XAhIuCAzonq0Ix//1+C
# pNSsy11sIKmMl61YJzxvZ6WkNluBmkDPCQ==
# -----END EC PRIVATE KEY-----
# """
# DER_SIGNATURE = (
#     b"0F\x02!\x00\x89yG\x81W\x01\x11\x9b0\x08\xa4\xd0\xe3g([\x07\xb5\x01\xb3"
#     b"\x9d\xdf \xd1\xbc\xedK\x01\x87:}\xf2\x02!\x00\xb2shTA\x00\x1a\x13~\xba"
#     b"J\xdb\xeem\x12\x1e\xfeMO\x04\xb2[\x86A\xbd\xc6hu\x953X\x1e"
# )
# RAW_SIGNATURE = (
#     b"\x89yG\x81W\x01\x11\x9b0\x08\xa4\xd0\xe3g([\x07\xb5\x01\xb3\x9d\xdf "
#     b"\xd1\xbc\xedK\x01\x87:}\xf2\xb2shTA\x00\x1a\x13~\xbaJ\xdb\xeem\x12\x1e"
#     b"\xfeMO\x04\xb2[\x86A\xbd\xc6hu\x953X\x1e"
# )
# def _backend_exception_types():
# def test_key_from_ecdsa():
# def test_cryptography_sig_component_length(algorithm, expected_length):
# def test_cryptograhy_der_to_raw():
# def test_cryptograhy_raw_to_der():
#     def test_key_from_pem(self):
#     def test_to_pem(self):
#     def test_key_too_short(self, Backend, ExceptionType):
#     def test_get_public_key(self):
#     def test_string_secret(self):
#     def test_object(self):
#     def test_invalid_algorithm(self):
#     def test_EC_jwk(self):
#     def test_verify(self):
#     def assert_parameters(self, as_dict, private):
#     def test_to_dict(self):
# class TestECAlgorithm:


# Path: tests/algorithms/test_EC_compat.py
import pytest
    from jose.backends.cryptography_backend import CryptographyECKey
    from jose.backends.ecdsa_backend import ECDSAECKey
from jose.constants import ALGORITHMS
from .test_EC import private_key

except ImportError:
    ECDSAECKey = CryptographyECKey = None



@pytest.mark.backend_compatibility
@pytest.mark.skipif(
    None in (ECDSAECKey, CryptographyECKey),
    reason="Multiple crypto backends not available for backend compatibility tests",
)
class TestBackendEcdsaCompatibility:
    @pytest.mark.parametrize("BackendSign", [ECDSAECKey, CryptographyECKey])
    @pytest.mark.parametrize("BackendVerify", [ECDSAECKey, CryptographyECKey])
    def test_signing_parity(self, BackendSign, BackendVerify):
        key_sign = BackendSign(private_key, ALGORITHMS.ES256)
        key_verify = BackendVerify(private_key, ALGORITHMS.ES256).public_key()

        msg = b"test"
        sig = key_sign.sign(msg)

        # valid signature
        assert key_verify.verify(msg, sig)

        # invalid signature
        assert not key_verify.verify(msg, b"n" * 64)

    @pytest.mark.parametrize("BackendFrom", [ECDSAECKey, CryptographyECKey])
    @pytest.mark.parametrize("BackendTo", [ECDSAECKey, CryptographyECKey])
    def test_public_key_to_pem(self, BackendFrom, BackendTo):
        key = BackendFrom(private_key, ALGORITHMS.ES256)

        key2 = BackendTo(private_key, ALGORITHMS.ES256)