y: RSAPrivateKey) -> bytes: ...
    def verify(self, msg: bytes, key: RSAPublicKey, sig: bytes) -> bool: ...

# Only defined if cryptography is installed.
class ECAlgorithm(Algorithm[Any]):
    SHA256: ClassVar[hashes.SHA256]
    SHA384: ClassVar[hashes.SHA384]
    SHA512: ClassVar[hashes.SHA512]
    hash_alg: Union[HashAlgorithm, Prehashed]
    def __init__(self, hash_alg: Union[HashAlgorithm, Prehashed]) -> None: ...
    def prepare_key(
        self, key: Union[bytes, str, EllipticCurvePrivateKey, EllipticCurvePublicKey]
    ) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ...
    @staticmethod
    def to_jwk(key_obj: Union[EllipticCurvePrivateKeyWithSerialization, EllipticCurvePublicKeyWithSerialization]) -> str: ...
    @staticmethod
    def from_jwk(jwk: Union[str, bytes]) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ...
    def sign(self, msg: bytes, key: EllipticCurvePrivateKey) -> bytes: ...
    def verify(self, msg: bytes, key: EllipticCurvePublicKey, sig: bytes) -> bool: ...

# Only defined if cryptography is installed. Types should be tightened when
# cryptography gets type hints.
# See https://github.com/python/typeshed/issues/2542
class RSAPSSAlgorithm(RSAAlgorithm):
    def sign(self, msg: bytes, key: Any) -> bytes: ...
    def verify(self, msg: bytes, key: Any, sig: bytes) -> bool: ...

# Only defined if cryptography is installed.
class Ed25519Algorithm(Algorithm[Any]):
    def __init__(self, **kwargs: Any) -> None: ...
    def prepare_key(self, key: Union[str, bytes, Ed25519PrivateKey, Ed25519PublicKey]) -> Any: ...
    def sign(self, msg: Union[str, bytes], key: Ed25519PrivateKey) -> bytes: ...
    def verify(self, msg: Union[str, bytes], key: Ed25519PublicKey, sig: Union[str, bytes]) -> bool: ...
PK