from typing import ClassVar, Protocol, Self, TypeVar, overload

__all__ = ['AsciiArmored', 'Certificate', 'ECPrivateKey', 'Pkcs8EncryptedPrivateKey', 'Pkcs8PrivateKey', 'Pkcs12', 'PrivateKey', 'RSAPrivateKey']

PrivateKeyT = TypeVar('PrivateKeyT', bound=PrivateKey)

class Encoding(Protocol):
    format: ClassVar[str]
    @classmethod
    def from_bytes(cls, source: bytes, /) -> Self: ...
    def to_bytes(self) -> bytes: ...
    def certificate(self) -> Certificate | None: ...
    def private_key(self) -> PrivateKey | None: ...

class Certificate(bytes):
    format: ClassVar
    label: ClassVar
    @classmethod
    def from_bytes(cls, source: bytes, /) -> Self: ...
    def to_bytes(self) -> Self: ...
    def fingerprint(self) -> str: ...
    def certificate(self) -> Self: ...
    def private_key(self) -> None: ...

class PrivateKey(bytes):
    format: ClassVar[str]
    label: ClassVar[str]
    def __new__(cls, source: bytes, /) -> Self: ...
    def __init_subclass__(cls, label: str) -> None: ...
    @classmethod
    def from_bytes(cls, source: bytes, /) -> Self: ...
    def to_bytes(self) -> Self: ...
    def certificate(self) -> None: ...
    def private_key(self) -> Self: ...

class RSAPrivateKey(PrivateKey, label='RSA PRIVATE KEY'): ...
class Pkcs8PrivateKey(PrivateKey, label='PRIVATE KEY'): ...
class Pkcs8EncryptedPrivateKey(PrivateKey, label='ENCRYPTED PRIVATE KEY'): ...
class ECPrivateKey(PrivateKey, label='EC PRIVATE KEY'): ...

class AsciiArmored(bytes):
    format: ClassVar
    @classmethod
    def new(cls, certificate: Certificate | None = None, private_key: PrivateKey | None = None) -> Self: ...
    @classmethod
    def from_bytes(cls, source: bytes, /) -> Self: ...
    def to_bytes(self) -> Self: ...
    def certificate(self) -> Certificate | None: ...
    def private_key(self) -> PrivateKey | None: ...
    @overload
    def find_first(self, kind: type[Certificate], /) -> Certificate: ...
    @overload
    def find_first(self, kind: type[PrivateKeyT], /) -> PrivateKeyT: ...

class Pkcs12(bytes):
    format: ClassVar
    @classmethod
    def new(cls, certificate: Certificate | None = None, private_key: PrivateKey | None = None) -> Self: ...
    @classmethod
    def from_bytes(cls, source: bytes, /) -> Self: ...
    def to_bytes(self) -> Self: ...
    def certificate(self) -> Certificate | None: ...
    def private_key(self) -> PrivateKey | None: ...
