Delete stubs for cryptography (#9459)

Typeshed's stubs for `paramiko` and `pyOpenSSL` now depend on the `cryptography` package, which now provides inline types at runtime
This commit is contained in:
Alex Waygood
2023-01-10 22:16:11 +00:00
committed by GitHub
parent 622a96b1de
commit e2d67bf703
55 changed files with 7 additions and 2039 deletions

View File

@@ -5,10 +5,6 @@
"stdlib",
"stubs",
],
"exclude": [
// `cryptography` stubs are outdated and to be removed
"stubs/cryptography",
],
"typeCheckingMode": "basic",
"strictListInference": true,
"strictDictionaryInference": true,

View File

@@ -28,7 +28,6 @@
"stubs/caldav",
"stubs/cffi",
"stubs/commonmark",
"stubs/cryptography",
"stubs/dateparser",
"stubs/docutils",
"stubs/Flask-Migrate",

View File

@@ -1,38 +0,0 @@
cryptography.exceptions.UnsupportedAlgorithm.__init__
cryptography.fernet.Fernet.__init__
cryptography.fernet.MultiFernet.decrypt
cryptography.fernet.MultiFernet.decrypt_at_time
cryptography.fernet.MultiFernet.encrypt
cryptography.fernet.MultiFernet.encrypt_at_time
cryptography.hazmat.backends.interfaces.DHBackend.dh_parameters_supported
cryptography.hazmat.backends.interfaces.HMACBackend.cmac_algorithm_supported
cryptography.hazmat.bindings.openssl.binding.Binding.init_static_locks
cryptography.hazmat.primitives.asymmetric.dh.DHParameterNumbers.__init__
cryptography.hazmat.primitives.ciphers.aead.AESCCM.__init__
cryptography.hazmat.primitives.cmac.CMAC.__init__
cryptography.hazmat.primitives.hashes.BLAKE2b.__init__
cryptography.hazmat.primitives.hashes.BLAKE2s.__init__
cryptography.hazmat.primitives.hashes.Hash.__init__
cryptography.hazmat.primitives.hmac.HMAC.__init__
cryptography.hazmat.primitives.hmac.HMAC.update
cryptography.hazmat.primitives.serialization.pkcs7.PKCS7SignatureBuilder.__init__
cryptography.x509.CertificateBuilder.public_key
cryptography.x509.CertificateBuilder.serial_number
cryptography.x509.CertificateRevocationListBuilder.__init__
cryptography.x509.CertificateRevocationListBuilder.issuer_name
cryptography.x509.CertificateRevocationListBuilder.last_update
cryptography.x509.CertificateRevocationListBuilder.next_update
cryptography.x509.CertificateSigningRequestBuilder.__init__
cryptography.x509.Extension.__init__
cryptography.x509.ExtensionType.oid # is a property at runtime, but a different descriptor on subclasses, easier just to pretend it's writeable
cryptography.x509.Extensions.__init__
cryptography.x509.NameAttribute.__init__
cryptography.x509.OCSPExtensionOID
cryptography.x509.RevokedCertificateBuilder.__init__
cryptography.x509.RevokedCertificateBuilder.serial_number
cryptography.x509.extensions.AccessDescription.__init__
cryptography.x509.extensions.AuthorityInformationAccess.__init__
cryptography.x509.extensions.CRLDistributionPoints.__init__
cryptography.x509.extensions.DistributionPoint.__init__
cryptography.x509.extensions.Extension.__init__
cryptography.x509.extensions.GeneralNames.__init__

View File

@@ -1,6 +0,0 @@
version = "3.3.*"
obsolete_since = "3.4.4"
[tool.stubtest]
# See https://github.com/python/typeshed/issues/9127
skip = true

View File

@@ -1,7 +0,0 @@
class AlreadyFinalized(Exception): ...
class AlreadyUpdated(Exception): ...
class InvalidKey(Exception): ...
class InvalidSignature(Exception): ...
class InvalidTag(Exception): ...
class NotYetFinalized(Exception): ...
class UnsupportedAlgorithm(Exception): ...

View File

@@ -1,23 +0,0 @@
class InvalidToken(Exception): ...
class Fernet:
def __init__(self, key: bytes | str) -> None: ...
def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ...
# decrypt_at_time accepts None ttl at runtime but it's an implementtion detail and it doesn't really
# make sense for the client code to use it like that, so the parameter is typed as int as opposed to
# int | None.
def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ...
def encrypt(self, data: bytes) -> bytes: ...
def encrypt_at_time(self, data: bytes, current_time: int) -> bytes: ...
def extract_timestamp(self, token: bytes) -> int: ...
@classmethod
def generate_key(cls) -> bytes: ...
class MultiFernet:
def __init__(self, fernets: list[Fernet]) -> None: ...
def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ...
# See a note above on the typing of the ttl parameter.
def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ...
def encrypt(self, data: bytes) -> bytes: ...
def encrypt_at_time(self, data: bytes, current_time: int) -> bytes: ...
def rotate(self, msg: bytes) -> bytes: ...

View File

@@ -1,3 +0,0 @@
from _typeshed import Incomplete
def __getattr__(name: str) -> Incomplete: ...

View File

@@ -1,7 +0,0 @@
from _typeshed import Incomplete
from typing import Any
def default_backend() -> Any: ...
# TODO: add some backends
def __getattr__(name: str) -> Incomplete: ...

View File

@@ -1,196 +0,0 @@
from abc import ABCMeta, abstractmethod
from typing import Any
from cryptography.hazmat.primitives.asymmetric.dh import (
DHParameterNumbers,
DHParameters,
DHPrivateKey,
DHPrivateNumbers,
DHPublicKey,
DHPublicNumbers,
)
from cryptography.hazmat.primitives.asymmetric.dsa import (
DSAParameterNumbers,
DSAParameters,
DSAPrivateKey,
DSAPrivateNumbers,
DSAPublicKey,
DSAPublicNumbers,
)
from cryptography.hazmat.primitives.asymmetric.ec import (
EllipticCurve,
EllipticCurvePrivateKey,
EllipticCurvePrivateNumbers,
EllipticCurvePublicKey,
EllipticCurvePublicNumbers,
EllipticCurveSignatureAlgorithm,
)
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPrivateNumbers, RSAPublicKey, RSAPublicNumbers
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm, CipherContext
from cryptography.hazmat.primitives.ciphers.modes import Mode
from cryptography.hazmat.primitives.hashes import HashAlgorithm, HashContext
from cryptography.x509 import (
Certificate,
CertificateBuilder,
CertificateRevocationList,
CertificateRevocationListBuilder,
CertificateSigningRequest,
CertificateSigningRequestBuilder,
Name,
RevokedCertificate,
RevokedCertificateBuilder,
)
class CipherBackend(metaclass=ABCMeta):
@abstractmethod
def cipher_supported(self, cipher: CipherAlgorithm, mode: Mode) -> bool: ...
@abstractmethod
def create_symmetric_encryption_ctx(self, cipher: CipherAlgorithm, mode: Mode) -> CipherContext: ...
@abstractmethod
def create_symmetric_decryption_ctx(self, cipher: CipherAlgorithm, mode: Mode) -> CipherContext: ...
class CMACBackend(metaclass=ABCMeta):
@abstractmethod
def cmac_algorithm_supported(self, algorithm: BlockCipherAlgorithm) -> bool: ...
@abstractmethod
def create_cmac_ctx(self, algorithm: BlockCipherAlgorithm) -> Any: ...
class DERSerializationBackend(metaclass=ABCMeta):
@abstractmethod
def load_der_parameters(self, data: bytes) -> Any: ...
@abstractmethod
def load_der_private_key(self, data: bytes, password: bytes | None) -> Any: ...
@abstractmethod
def load_der_public_key(self, data: bytes) -> Any: ...
class DHBackend(metaclass=ABCMeta):
@abstractmethod
def dh_parameters_supported(self, p: int, g: int, q: int | None) -> bool: ...
@abstractmethod
def dh_x942_serialization_supported(self) -> bool: ...
@abstractmethod
def generate_dh_parameters(self, generator: int, key_size: int) -> DHParameters: ...
@abstractmethod
def generate_dh_private_key(self, parameters: DHParameters) -> DHPrivateKey: ...
@abstractmethod
def generate_dh_private_key_and_parameters(self, generator: int, key_size: int) -> DHPrivateKey: ...
@abstractmethod
def load_dh_parameter_numbers(self, numbers: DHParameterNumbers) -> DHParameters: ...
@abstractmethod
def load_dh_private_numbers(self, numbers: DHPrivateNumbers) -> DHPrivateKey: ...
@abstractmethod
def load_dh_public_numbers(self, numbers: DHPublicNumbers) -> DHPublicKey: ...
class DSABackend(metaclass=ABCMeta):
@abstractmethod
def dsa_hash_supported(self, algorithm: HashAlgorithm) -> bool: ...
@abstractmethod
def dsa_parameters_supported(self, p: int, q: int, g: int) -> bool: ...
@abstractmethod
def generate_dsa_parameters(self, key_size: int) -> DSAParameters: ...
@abstractmethod
def generate_dsa_private_key(self, parameters: DSAParameters) -> DSAPrivateKey: ...
@abstractmethod
def generate_dsa_private_key_and_parameters(self, key_size: int) -> DSAPrivateKey: ...
@abstractmethod
def load_dsa_parameter_numbers(self, numbers: DSAParameterNumbers) -> DSAParameters: ...
@abstractmethod
def load_dsa_private_numbers(self, numbers: DSAPrivateNumbers) -> DSAPrivateKey: ...
@abstractmethod
def load_dsa_public_numbers(self, numbers: DSAPublicNumbers) -> DSAPublicKey: ...
class EllipticCurveBackend(metaclass=ABCMeta):
@abstractmethod
def derive_elliptic_curve_private_key(self, private_value: int, curve: EllipticCurve) -> EllipticCurvePrivateKey: ...
@abstractmethod
def elliptic_curve_signature_algorithm_supported(
self, signature_algorithm: EllipticCurveSignatureAlgorithm, curve: EllipticCurve
) -> bool: ...
@abstractmethod
def elliptic_curve_supported(self, curve: EllipticCurve) -> bool: ...
@abstractmethod
def generate_elliptic_curve_private_key(self, curve: EllipticCurve) -> EllipticCurvePrivateKey: ...
@abstractmethod
def load_elliptic_curve_private_numbers(self, numbers: EllipticCurvePrivateNumbers) -> EllipticCurvePrivateKey: ...
@abstractmethod
def load_elliptic_curve_public_numbers(self, numbers: EllipticCurvePublicNumbers) -> EllipticCurvePublicKey: ...
class HMACBackend(metaclass=ABCMeta):
@abstractmethod
def create_hmac_ctx(self, key: bytes, algorithm: HashAlgorithm) -> HashContext: ...
@abstractmethod
def cmac_algorithm_supported(self, algorithm: HashAlgorithm) -> bool: ...
class HashBackend(metaclass=ABCMeta):
@abstractmethod
def create_hash_ctx(self, algorithm: HashAlgorithm) -> HashContext: ...
@abstractmethod
def hash_supported(self, algorithm: HashAlgorithm) -> bool: ...
class PBKDF2HMACBackend(metaclass=ABCMeta):
@abstractmethod
def derive_pbkdf2_hmac(
self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, key_material: bytes
) -> bytes: ...
@abstractmethod
def pbkdf2_hmac_supported(self, algorithm: HashAlgorithm) -> bool: ...
class PEMSerializationBackend(metaclass=ABCMeta):
@abstractmethod
def load_pem_parameters(self, data: bytes) -> Any: ...
@abstractmethod
def load_pem_private_key(self, data: bytes, password: bytes | None) -> Any: ...
@abstractmethod
def load_pem_public_key(self, data: bytes) -> Any: ...
class RSABackend(metaclass=ABCMeta):
@abstractmethod
def generate_rsa_parameters_supported(self, public_exponent: int, key_size: int) -> bool: ...
@abstractmethod
def generate_rsa_private_key(self, public_exponent: int, key_size: int) -> RSAPrivateKey: ...
@abstractmethod
def load_rsa_public_numbers(self, numbers: RSAPublicNumbers) -> RSAPublicKey: ...
@abstractmethod
def load_rsa_private_numbers(self, numbers: RSAPrivateNumbers) -> RSAPrivateKey: ...
@abstractmethod
def rsa_padding_supported(self, padding: AsymmetricPadding) -> bool: ...
class ScryptBackend(metaclass=ABCMeta):
@abstractmethod
def derive_scrypt(self, key_material: bytes, salt: bytes, length: int, n: int, r: int, p: int) -> bytes: ...
class X509Backend(metaclass=ABCMeta):
@abstractmethod
def create_x509_certificate(
self,
builder: CertificateBuilder,
private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm,
) -> Certificate: ...
@abstractmethod
def create_x509_crl(
self,
builder: CertificateRevocationListBuilder,
private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm,
) -> CertificateRevocationList: ...
@abstractmethod
def create_x509_csr(
self,
builder: CertificateSigningRequestBuilder,
private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm,
) -> CertificateSigningRequest: ...
@abstractmethod
def create_x509_revoked_certificate(self, builder: RevokedCertificateBuilder) -> RevokedCertificate: ...
@abstractmethod
def load_der_x509_certificate(self, data: bytes) -> Certificate: ...
@abstractmethod
def load_der_x509_csr(self, data: bytes) -> CertificateSigningRequest: ...
@abstractmethod
def load_pem_x509_certificate(self, data: bytes) -> Certificate: ...
@abstractmethod
def load_pem_x509_csr(self, data: bytes) -> CertificateSigningRequest: ...
@abstractmethod
def x509_name_bytes(self, name: Name) -> bytes: ...

View File

@@ -1,6 +0,0 @@
from typing import Any
class Binding:
ffi: Any | None
lib: Any | None
def init_static_locks(self) -> None: ...

View File

@@ -1,3 +0,0 @@
from _typeshed import Incomplete
def __getattr__(name: str) -> Incomplete: ...

View File

@@ -1,3 +0,0 @@
from _typeshed import Incomplete
def __getattr__(name: str) -> Incomplete: ...

View File

@@ -1,79 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.backends.interfaces import DHBackend
from cryptography.hazmat.primitives.serialization import (
Encoding,
KeySerializationEncryption,
ParameterFormat,
PrivateFormat,
PublicFormat,
)
class DHParameters(metaclass=ABCMeta):
@abstractmethod
def generate_private_key(self) -> DHPrivateKey: ...
@abstractmethod
def parameter_bytes(self, encoding: Encoding, format: ParameterFormat) -> bytes: ...
@abstractmethod
def parameter_numbers(self) -> DHParameterNumbers: ...
DHParametersWithSerialization = DHParameters
class DHParameterNumbers:
@property
def p(self) -> int: ...
@property
def g(self) -> int: ...
@property
def q(self) -> int: ...
def __init__(self, p: int, g: int, q: int | None) -> None: ...
def parameters(self, backend: DHBackend | None = ...) -> DHParameters: ...
class DHPrivateKey(metaclass=ABCMeta):
@property
def key_size(self) -> int: ...
@abstractmethod
def exchange(self, peer_public_key: DHPublicKey) -> bytes: ...
@abstractmethod
def parameters(self) -> DHParameters: ...
@abstractmethod
def public_key(self) -> DHPublicKey: ...
class DHPrivateKeyWithSerialization(DHPrivateKey):
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def private_numbers(self) -> DHPrivateNumbers: ...
class DHPrivateNumbers:
@property
def public_numbers(self) -> DHPublicNumbers: ...
@property
def x(self) -> int: ...
def __init__(self, x: int, public_numbers: DHPublicNumbers) -> None: ...
def private_key(self, backend: DHBackend | None = ...) -> DHPrivateKey: ...
class DHPublicKey(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def parameters(self) -> DHParameters: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def public_numbers(self) -> DHPublicNumbers: ...
DHPublicKeyWithSerialization = DHPublicKey
class DHPublicNumbers:
@property
def parameter_numbers(self) -> DHParameterNumbers: ...
@property
def y(self) -> int: ...
def __init__(self, y: int, parameter_numbers: DHParameterNumbers) -> None: ...
def public_key(self, backend: DHBackend | None = ...) -> DHPublicKey: ...
def generate_parameters(generator: int, key_size: int, backend: DHBackend | None = ...) -> DHParameters: ...

View File

@@ -1,76 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.backends.interfaces import DSABackend
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class DSAParameters(metaclass=ABCMeta):
@abstractmethod
def generate_private_key(self) -> DSAPrivateKey: ...
class DSAParametersWithNumbers(DSAParameters):
@abstractmethod
def parameter_numbers(self) -> DSAParameterNumbers: ...
class DSAParameterNumbers:
@property
def p(self) -> int: ...
@property
def q(self) -> int: ...
@property
def g(self) -> int: ...
def __init__(self, p: int, q: int, g: int) -> None: ...
def parameters(self, backend: DSABackend | None = ...) -> DSAParameters: ...
class DSAPrivateKey(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def parameters(self) -> DSAParameters: ...
@abstractmethod
def public_key(self) -> DSAPublicKey: ...
@abstractmethod
def sign(self, data: bytes, algorithm: HashAlgorithm | Prehashed) -> bytes: ...
class DSAPrivateKeyWithSerialization(DSAPrivateKey):
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def private_numbers(self) -> DSAPrivateNumbers: ...
class DSAPrivateNumbers:
@property
def x(self) -> int: ...
@property
def public_numbers(self) -> DSAPublicNumbers: ...
def __init__(self, x: int, public_numbers: DSAPublicNumbers) -> None: ...
class DSAPublicKey(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def public_numbers(self) -> DSAPublicNumbers: ...
@abstractmethod
def verifier(self, signature: bytes, signature_algorithm: HashAlgorithm | Prehashed) -> AsymmetricVerificationContext: ...
@abstractmethod
def verify(self, signature: bytes, data: bytes, algorithm: HashAlgorithm | Prehashed) -> None: ...
DSAPublicKeyWithSerialization = DSAPublicKey
class DSAPublicNumbers:
@property
def y(self) -> int: ...
@property
def parameter_numbers(self) -> DSAParameterNumbers: ...
def __init__(self, y: int, parameter_numbers: DSAParameterNumbers) -> None: ...
def generate_parameters(key_size: int, backend: DSABackend | None = ...) -> DSAParameters: ...
def generate_private_key(key_size: int, backend: DSABackend | None = ...) -> DSAPrivateKey: ...

View File

@@ -1,197 +0,0 @@
from _typeshed import Self
from abc import ABCMeta, abstractmethod
from typing import ClassVar
from cryptography.hazmat.backends.interfaces import EllipticCurveBackend
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
from cryptography.x509 import ObjectIdentifier
class EllipticCurve(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@property
@abstractmethod
def name(self) -> str: ...
class BrainpoolP256R1(EllipticCurve):
key_size: int = ...
name: str = ...
class BrainpoolP384R1(EllipticCurve):
key_size: int = ...
name: str = ...
class BrainpoolP512R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP192R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP224R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP256K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP256R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP384R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECP521R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT163K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT163R2(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT233K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT233R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT283K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT283R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT409K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT409R1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT571K1(EllipticCurve):
key_size: int = ...
name: str = ...
class SECT571R1(EllipticCurve):
key_size: int = ...
name: str = ...
class EllipticCurveOID:
SECP192R1: ClassVar[ObjectIdentifier]
SECP224R1: ClassVar[ObjectIdentifier]
SECP256K1: ClassVar[ObjectIdentifier]
SECP256R1: ClassVar[ObjectIdentifier]
SECP384R1: ClassVar[ObjectIdentifier]
SECP521R1: ClassVar[ObjectIdentifier]
BRAINPOOLP256R1: ClassVar[ObjectIdentifier]
BRAINPOOLP384R1: ClassVar[ObjectIdentifier]
BRAINPOOLP512R1: ClassVar[ObjectIdentifier]
SECT163K1: ClassVar[ObjectIdentifier]
SECT163R2: ClassVar[ObjectIdentifier]
SECT233K1: ClassVar[ObjectIdentifier]
SECT233R1: ClassVar[ObjectIdentifier]
SECT283K1: ClassVar[ObjectIdentifier]
SECT283R1: ClassVar[ObjectIdentifier]
SECT409K1: ClassVar[ObjectIdentifier]
SECT409R1: ClassVar[ObjectIdentifier]
SECT571K1: ClassVar[ObjectIdentifier]
SECT571R1: ClassVar[ObjectIdentifier]
class EllipticCurvePrivateKey(metaclass=ABCMeta):
@property
@abstractmethod
def curve(self) -> EllipticCurve: ...
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def exchange(self, algorithm: ECDH, peer_public_key: EllipticCurvePublicKey) -> bytes: ...
@abstractmethod
def public_key(self) -> EllipticCurvePublicKey: ...
@abstractmethod
def sign(self, data: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm) -> bytes: ...
class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def private_numbers(self) -> EllipticCurvePrivateNumbers: ...
class EllipticCurvePrivateNumbers:
@property
def private_value(self) -> int: ...
@property
def public_numbers(self) -> EllipticCurvePublicNumbers: ...
def __init__(self, private_value: int, public_numbers: EllipticCurvePublicNumbers) -> None: ...
def private_key(self, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePrivateKey: ...
class EllipticCurvePublicKey(metaclass=ABCMeta):
@property
@abstractmethod
def curve(self) -> EllipticCurve: ...
@property
@abstractmethod
def key_size(self) -> int: ...
@classmethod
def from_encoded_point(cls, curve: EllipticCurve, data: bytes) -> EllipticCurvePublicKey: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def public_numbers(self) -> EllipticCurvePublicNumbers: ...
@abstractmethod
def verifier(
self, signature: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm
) -> AsymmetricVerificationContext: ...
@abstractmethod
def verify(self, signature: bytes, data: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm) -> None: ...
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
class EllipticCurvePublicNumbers:
@property
def curve(self) -> EllipticCurve: ...
@property
def x(self) -> int: ...
@property
def y(self) -> int: ...
def __init__(self, x: int, y: int, curve: EllipticCurve) -> None: ...
@classmethod
def from_encoded_point(cls: type[Self], curve: EllipticCurve, data: bytes) -> Self: ...
def public_key(self, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePublicKey: ...
class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta):
@property
@abstractmethod
def algorithm(self) -> HashAlgorithm | Prehashed: ...
class ECDH: ...
class ECDSA(EllipticCurveSignatureAlgorithm):
def __init__(self, algorithm: HashAlgorithm | Prehashed): ...
@property
def algorithm(self) -> HashAlgorithm | Prehashed: ...
def derive_private_key(
private_value: int, curve: EllipticCurve, backend: EllipticCurveBackend | None = ...
) -> EllipticCurvePrivateKey: ...
def generate_private_key(curve: EllipticCurve, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePrivateKey: ...
def get_curve_for_oid(oid: ObjectIdentifier) -> EllipticCurve: ...

View File

@@ -1,25 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class Ed25519PrivateKey(metaclass=ABCMeta):
@classmethod
def generate(cls) -> Ed25519PrivateKey: ...
@classmethod
def from_private_bytes(cls, data: bytes) -> Ed25519PrivateKey: ...
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def public_key(self) -> Ed25519PublicKey: ...
@abstractmethod
def sign(self, data: bytes) -> bytes: ...
class Ed25519PublicKey(metaclass=ABCMeta):
@classmethod
def from_public_bytes(cls, data: bytes) -> Ed25519PublicKey: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def verify(self, signature: bytes, data: bytes) -> None: ...

View File

@@ -1,25 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class Ed448PrivateKey(metaclass=ABCMeta):
@classmethod
def generate(cls) -> Ed448PrivateKey: ...
@classmethod
def from_private_bytes(cls, data: bytes) -> Ed448PrivateKey: ...
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def public_key(self) -> Ed448PublicKey: ...
@abstractmethod
def sign(self, data: bytes) -> bytes: ...
class Ed448PublicKey(metaclass=ABCMeta):
@classmethod
def from_public_bytes(cls, data: bytes) -> Ed448PublicKey: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def verify(self, signature: bytes, data: bytes) -> None: ...

View File

@@ -1,27 +0,0 @@
from abc import ABCMeta, abstractmethod
from typing import ClassVar
from cryptography.hazmat.primitives.hashes import HashAlgorithm
class AsymmetricPadding(metaclass=ABCMeta):
@property
@abstractmethod
def name(self) -> str: ...
class MGF1:
def __init__(self, algorithm: HashAlgorithm) -> None: ...
class OAEP(AsymmetricPadding):
def __init__(self, mgf: MGF1, algorithm: HashAlgorithm, label: bytes | None) -> None: ...
@property
def name(self) -> str: ...
class PKCS1v15(AsymmetricPadding):
@property
def name(self) -> str: ...
class PSS(AsymmetricPadding):
MAX_LENGTH: ClassVar[object]
def __init__(self, mgf: MGF1, salt_length: int | object) -> None: ...
@property
def name(self) -> str: ...

View File

@@ -1,80 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.backends.interfaces import RSABackend
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class RSAPrivateKey(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def decrypt(self, ciphertext: bytes, padding: AsymmetricPadding) -> bytes: ...
@abstractmethod
def public_key(self) -> RSAPublicKey: ...
@abstractmethod
def sign(self, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> bytes: ...
class RSAPrivateKeyWithSerialization(RSAPrivateKey):
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def private_numbers(self) -> RSAPrivateNumbers: ...
class RSAPublicKey(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@abstractmethod
def encrypt(self, plaintext: bytes, padding: AsymmetricPadding) -> bytes: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
@abstractmethod
def public_numbers(self) -> RSAPublicNumbers: ...
@abstractmethod
def verifier(
self, signature: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed
) -> AsymmetricVerificationContext: ...
@abstractmethod
def verify(self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> None: ...
RSAPublicKeyWithSerialization = RSAPublicKey
def generate_private_key(
public_exponent: int, key_size: int, backend: RSABackend | None = ...
) -> RSAPrivateKeyWithSerialization: ...
def rsa_crt_iqmp(p: int, q: int) -> int: ...
def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ...
def rsa_crt_dmq1(private_exponent: int, q: int) -> int: ...
def rsa_recover_prime_factors(n: int, e: int, d: int) -> tuple[int, int]: ...
class RSAPrivateNumbers:
def __init__(self, p: int, q: int, d: int, dmp1: int, dmq1: int, iqmp: int, public_numbers: RSAPublicNumbers) -> None: ...
@property
def p(self) -> int: ...
@property
def q(self) -> int: ...
@property
def d(self) -> int: ...
@property
def dmp1(self) -> int: ...
@property
def dmq1(self) -> int: ...
@property
def iqmp(self) -> int: ...
@property
def public_numbers(self) -> RSAPublicNumbers: ...
def private_key(self, backend: RSABackend | None = ...) -> RSAPrivateKey: ...
class RSAPublicNumbers:
def __init__(self, e: int, n: int) -> None: ...
@property
def e(self) -> int: ...
@property
def n(self) -> int: ...
def public_key(self, backend: RSABackend | None = ...) -> RSAPublicKey: ...

View File

@@ -1,11 +0,0 @@
from cryptography.hazmat.primitives.hashes import HashAlgorithm
def decode_dss_signature(signature: bytes) -> tuple[int, int]: ...
def encode_dss_signature(r: int, s: int) -> bytes: ...
class Prehashed:
_algorithm: HashAlgorithm # undocumented
_digest_size: int # undocumented
def __init__(self, algorithm: HashAlgorithm) -> None: ...
@property
def digest_size(self) -> int: ...

View File

@@ -1,23 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class X25519PrivateKey(metaclass=ABCMeta):
@classmethod
def from_private_bytes(cls, data: bytes) -> X25519PrivateKey: ...
@classmethod
def generate(cls) -> X25519PrivateKey: ...
@abstractmethod
def exchange(self, peer_public_key: X25519PublicKey) -> bytes: ...
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def public_key(self) -> X25519PublicKey: ...
class X25519PublicKey(metaclass=ABCMeta):
@classmethod
def from_public_bytes(cls, data: bytes) -> X25519PublicKey: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...

View File

@@ -1,23 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
class X448PrivateKey(metaclass=ABCMeta):
@classmethod
def from_private_bytes(cls, data: bytes) -> X448PrivateKey: ...
@classmethod
def generate(cls) -> X448PrivateKey: ...
@abstractmethod
def exchange(self, peer_public_key: X448PublicKey) -> bytes: ...
@abstractmethod
def private_bytes(
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
) -> bytes: ...
@abstractmethod
def public_key(self) -> X448PublicKey: ...
class X448PublicKey(metaclass=ABCMeta):
@classmethod
def from_public_bytes(cls, data: bytes) -> X448PublicKey: ...
@abstractmethod
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...

View File

@@ -1,43 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.backends.interfaces import CipherBackend
from cryptography.hazmat.primitives.ciphers.modes import Mode
class AEADCipherContext(metaclass=ABCMeta):
@abstractmethod
def authenticate_additional_data(self, data: bytes) -> None: ...
class AEADDecryptionContext(metaclass=ABCMeta):
@abstractmethod
def finalize_with_tag(self, tag: bytes) -> bytes: ...
class AEADEncryptionContext(metaclass=ABCMeta):
@property
@abstractmethod
def tag(self) -> bytes: ...
class BlockCipherAlgorithm(metaclass=ABCMeta):
@property
@abstractmethod
def block_size(self) -> int: ...
class Cipher:
def __init__(self, algorithm: CipherAlgorithm, mode: Mode | None, backend: CipherBackend | None = ...) -> None: ...
def decryptor(self) -> CipherContext: ...
def encryptor(self) -> CipherContext: ...
class CipherAlgorithm(metaclass=ABCMeta):
@property
@abstractmethod
def key_size(self) -> int: ...
@property
@abstractmethod
def name(self) -> str: ...
class CipherContext(metaclass=ABCMeta):
@abstractmethod
def finalize(self) -> bytes: ...
@abstractmethod
def update(self, data: bytes) -> bytes: ...
@abstractmethod
def update_into(self, data: bytes, buf: bytearray) -> int: ...

View File

@@ -1,20 +0,0 @@
class AESCCM:
def __init__(self, key: bytes, tag_length: int | None) -> None: ...
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
@classmethod
def generate_key(cls, bit_length: int) -> bytes: ...
class AESGCM:
def __init__(self, key: bytes) -> None: ...
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
@classmethod
def generate_key(cls, bit_length: int) -> bytes: ...
class ChaCha20Poly1305:
def __init__(self, key: bytes) -> None: ...
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
@classmethod
def generate_key(cls) -> bytes: ...

View File

@@ -1,74 +0,0 @@
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm
from cryptography.hazmat.primitives.ciphers.modes import ModeWithNonce
class AES(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
@property
def key_size(self) -> int: ...
class ARC4(CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
name: str = ...
key_sizes: frozenset[int] = ...
class Blowfish(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
class Camellia(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
class CAST5(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
class ChaCha20(CipherAlgorithm, ModeWithNonce):
def __init__(self, key: bytes, nonce: bytes) -> None: ...
@property
def key_size(self) -> int: ...
name: str = ...
key_sizes: frozenset[int] = ...
@property
def nonce(self) -> bytes: ...
class IDEA(CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
class SEED(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...
class TripleDES(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@property
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: frozenset[int] = ...

View File

@@ -1,93 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.primitives.ciphers import CipherAlgorithm
class Mode(metaclass=ABCMeta):
@property
@abstractmethod
def name(self) -> str: ...
@abstractmethod
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class ModeWithAuthenticationTag(metaclass=ABCMeta):
@property
@abstractmethod
def tag(self) -> bytes: ...
class ModeWithInitializationVector(metaclass=ABCMeta):
@property
@abstractmethod
def initialization_vector(self) -> bytes: ...
class ModeWithNonce(metaclass=ABCMeta):
@property
@abstractmethod
def nonce(self) -> bytes: ...
class ModeWithTweak(metaclass=ABCMeta):
@property
@abstractmethod
def tweak(self) -> bytes: ...
class CBC(Mode, ModeWithInitializationVector):
def __init__(self, initialization_vector: bytes) -> None: ...
@property
def initialization_vector(self) -> bytes: ...
@property
def name(self) -> str: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class CTR(Mode, ModeWithNonce):
def __init__(self, nonce: bytes) -> None: ...
@property
def name(self) -> str: ...
@property
def nonce(self) -> bytes: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class CFB(Mode, ModeWithInitializationVector):
def __init__(self, initialization_vector: bytes) -> None: ...
@property
def initialization_vector(self) -> bytes: ...
@property
def name(self) -> str: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class CFB8(Mode, ModeWithInitializationVector):
def __init__(self, initialization_vector: bytes) -> None: ...
@property
def initialization_vector(self) -> bytes: ...
@property
def name(self) -> str: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class ECB(Mode):
@property
def name(self) -> str: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class GCM(Mode, ModeWithInitializationVector, ModeWithAuthenticationTag):
def __init__(self, initialization_vector: bytes, tag: bytes | None = ..., min_tag_length: int | None = ...) -> None: ...
@property
def initialization_vector(self) -> bytes: ...
@property
def name(self) -> str: ...
@property
def tag(self) -> bytes: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class OFB(Mode, ModeWithInitializationVector):
def __init__(self, initialization_vector: bytes) -> None: ...
@property
def initialization_vector(self) -> bytes: ...
@property
def name(self) -> str: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
class XTS(Mode, ModeWithTweak):
def __init__(self, tweak: bytes) -> None: ...
@property
def name(self) -> str: ...
@property
def tweak(self) -> bytes: ...
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...

View File

@@ -1,9 +0,0 @@
from cryptography.hazmat.backends.interfaces import CMACBackend
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm
class CMAC:
def __init__(self, algorithm: BlockCipherAlgorithm, backend: CMACBackend | None = ...) -> None: ...
def copy(self) -> CMAC: ...
def finalize(self) -> bytes: ...
def update(self, data: bytes) -> None: ...
def verify(self, signature: bytes) -> None: ...

View File

@@ -1 +0,0 @@
def bytes_eq(a: bytes, b: bytes) -> bool: ...

View File

@@ -1,48 +0,0 @@
from abc import ABCMeta, abstractmethod
from cryptography.hazmat.backends.interfaces import HashBackend
# These are actually abstractproperties on HashAlgorithm,
# but let's not worry too much about that.
class HashAlgorithm(metaclass=ABCMeta):
@property
def digest_size(self) -> int: ...
@property
def name(self) -> str: ...
class HashContext(metaclass=ABCMeta):
@property
def algorithm(self) -> HashAlgorithm: ...
@abstractmethod
def copy(self) -> HashContext: ...
@abstractmethod
def finalize(self) -> bytes: ...
@abstractmethod
def update(self, data: bytes) -> None: ...
class BLAKE2b(HashAlgorithm): ...
class BLAKE2s(HashAlgorithm): ...
class MD5(HashAlgorithm): ...
class SHA1(HashAlgorithm): ...
class SHA224(HashAlgorithm): ...
class SHA256(HashAlgorithm): ...
class SHA384(HashAlgorithm): ...
class SHA3_224(HashAlgorithm): ...
class SHA3_256(HashAlgorithm): ...
class SHA3_384(HashAlgorithm): ...
class SHA3_512(HashAlgorithm): ...
class SHA512(HashAlgorithm): ...
class SHA512_224(HashAlgorithm): ...
class SHA512_256(HashAlgorithm): ...
class SHAKE128(HashAlgorithm):
def __init__(self, digest_size: int) -> None: ...
class SHAKE256(HashAlgorithm):
def __init__(self, digest_size: int) -> None: ...
class Hash(HashContext):
def __init__(self, algorithm: HashAlgorithm, backend: HashBackend | None = ...): ...
def copy(self) -> Hash: ...
def finalize(self) -> bytes: ...
def update(self, data: bytes) -> None: ...

View File

@@ -1,9 +0,0 @@
from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
class HMAC:
def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: HMACBackend | None = ...) -> None: ...
def copy(self) -> HMAC: ...
def finalize(self) -> bytes: ...
def update(self, msg: bytes) -> None: ...
def verify(self, signature: bytes) -> None: ...

View File

@@ -1,7 +0,0 @@
from abc import ABCMeta, abstractmethod
class KeyDerivationFunction(metaclass=ABCMeta):
@abstractmethod
def derive(self, key_material: bytes) -> bytes: ...
@abstractmethod
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,20 +0,0 @@
from cryptography.hazmat.backends.interfaces import HashBackend, HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class ConcatKDFHash(KeyDerivationFunction):
def __init__(self, algorithm: HashAlgorithm, length: int, otherinfo: bytes | None, backend: HashBackend | None = ...): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
class ConcatKDFHMAC(KeyDerivationFunction):
def __init__(
self,
algorithm: HashAlgorithm,
length: int,
salt: bytes | None,
otherinfo: bytes | None,
backend: HMACBackend | None = ...,
): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,15 +0,0 @@
from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class HKDF(KeyDerivationFunction):
def __init__(
self, algorithm: HashAlgorithm, length: int, salt: bytes | None, info: bytes | None, backend: HMACBackend | None = ...
): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
class HKDFExpand(KeyDerivationFunction):
def __init__(self, algorithm: HashAlgorithm, length: int, info: bytes | None, backend: HMACBackend | None = ...): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,29 +0,0 @@
from enum import Enum
from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class Mode(Enum):
CounterMode: str
class CounterLocation(Enum):
BeforeFixed: str
AfterFixed: str
class KBKDFHMAC(KeyDerivationFunction):
def __init__(
self,
algorithm: HashAlgorithm,
mode: Mode,
length: int,
rlen: int,
llen: int,
location: CounterLocation,
label: bytes | None,
context: bytes | None,
fixed: bytes | None,
backend: HMACBackend | None = ...,
): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,10 +0,0 @@
from cryptography.hazmat.backends.interfaces import PBKDF2HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class PBKDF2HMAC(KeyDerivationFunction):
def __init__(
self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, backend: PBKDF2HMACBackend | None = ...
): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,7 +0,0 @@
from cryptography.hazmat.backends.interfaces import ScryptBackend
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class Scrypt(KeyDerivationFunction):
def __init__(self, salt: bytes, length: int, n: int, r: int, p: int, backend: ScryptBackend | None = ...): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,8 +0,0 @@
from cryptography.hazmat.backends.interfaces import HashBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
class X963KDF(KeyDerivationFunction):
def __init__(self, algorithm: HashAlgorithm, length: int, sharedinfo: bytes | None, backend: HashBackend | None = ...): ...
def derive(self, key_material: bytes) -> bytes: ...
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...

View File

@@ -1,8 +0,0 @@
from cryptography.hazmat.backends.interfaces import CipherBackend
def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend | None = ...) -> bytes: ...
def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend | None = ...) -> bytes: ...
def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend | None = ...) -> bytes: ...
def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend | None = ...) -> bytes: ...
class InvalidUnwrap(Exception): ...

View File

@@ -1,17 +0,0 @@
from abc import ABCMeta, abstractmethod
class PaddingContext(metaclass=ABCMeta):
@abstractmethod
def finalize(self) -> bytes: ...
@abstractmethod
def update(self, data: bytes) -> bytes: ...
class ANSIX923:
def __init__(self, block_size: int) -> None: ...
def padder(self) -> PaddingContext: ...
def unpadder(self) -> PaddingContext: ...
class PKCS7:
def __init__(self, block_size: int) -> None: ...
def padder(self) -> PaddingContext: ...
def unpadder(self) -> PaddingContext: ...

View File

@@ -1,9 +0,0 @@
class Poly1305:
def __init__(self, key: bytes) -> None: ...
def finalize(self) -> bytes: ...
@classmethod
def generate_tag(cls, key: bytes, data: bytes) -> bytes: ...
def update(self, data: bytes) -> None: ...
def verify(self, tag: bytes) -> None: ...
@classmethod
def verify_tag(cls, key: bytes, data: bytes, tag: bytes) -> None: ...

View File

@@ -1,60 +0,0 @@
from abc import ABCMeta
from enum import Enum
from typing import Any
from cryptography.hazmat.backends.interfaces import (
DERSerializationBackend,
DSABackend,
EllipticCurveBackend,
PEMSerializationBackend,
RSABackend,
)
def load_pem_private_key(
data: bytes, password: bytes | None, backend: PEMSerializationBackend | None = ...
) -> Any: ... # actually RSAPrivateKey | DSAPrivateKey | DHPrivateKey | EllipticCurvePrivateKey
def load_pem_public_key(
data: bytes, backend: PEMSerializationBackend | None = ...
) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey
def load_der_private_key(
data: bytes, password: bytes | None, backend: DERSerializationBackend | None = ...
) -> Any: ... # actually RSAPrivateKey | DSAPrivateKey | DHPrivateKey | EllipticCurvePrivateKey
def load_der_public_key(
data: bytes, backend: DERSerializationBackend | None = ...
) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey
def load_ssh_public_key(
data: bytes, backend: RSABackend | DSABackend | EllipticCurveBackend | None = ...
) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey | Ed25519PublicKey
class Encoding(Enum):
PEM: str
DER: str
OpenSSH: str
Raw: str
X962: str
SMIME: str
class PrivateFormat(Enum):
PKCS8: str
TraditionalOpenSSL: str
Raw: str
OpenSSH: str
class PublicFormat(Enum):
SubjectPublicKeyInfo: str
PKCS1: str
OpenSSH: str
Raw: str
CompressedPoint: str
UncompressedPoint: str
class ParameterFormat(Enum):
PKCS3: str
class KeySerializationEncryption(metaclass=ABCMeta): ...
class BestAvailableEncryption(KeySerializationEncryption):
password: bytes
def __init__(self, password: bytes) -> None: ...
class NoEncryption(KeySerializationEncryption): ...

View File

@@ -1,18 +0,0 @@
from typing import Any
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKeyWithSerialization
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKeyWithSerialization
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKeyWithSerialization
from cryptography.hazmat.primitives.serialization import KeySerializationEncryption
from cryptography.x509 import Certificate
def load_key_and_certificates(
data: bytes, password: bytes | None, backend: Any | None = ...
) -> tuple[Any | None, Certificate | None, list[Certificate]]: ...
def serialize_key_and_certificates(
name: bytes,
key: RSAPrivateKeyWithSerialization | EllipticCurvePrivateKeyWithSerialization | DSAPrivateKeyWithSerialization,
cert: Certificate | None,
cas: list[Certificate] | None,
encryption_algorithm: KeySerializationEncryption,
) -> bytes: ...

View File

@@ -1,31 +0,0 @@
from collections.abc import Iterable
from enum import Enum
from typing import Any
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.hashes import SHA1, SHA224, SHA256, SHA384, SHA512
from cryptography.hazmat.primitives.serialization import Encoding
from cryptography.x509 import Certificate
def load_pem_pkcs7_certificates(data: bytes) -> list[Certificate]: ...
def load_der_pkcs7_certificates(data: bytes) -> list[Certificate]: ...
class PKCS7Options(Enum):
Text: str
Binary: str
DetachedSignature: str
NoCapabilities: str
NoAttributes: str
NoCerts: str
class PKCS7SignatureBuilder:
def set_data(self, data: bytes) -> PKCS7SignatureBuilder: ...
def add_signer(
self,
certificate: Certificate,
private_key: RSAPrivateKey | EllipticCurvePrivateKey,
hash_algorithm: SHA1 | SHA224 | SHA256 | SHA384 | SHA512,
) -> PKCS7SignatureBuilder: ...
def add_certificate(self, certificate: Certificate) -> PKCS7SignatureBuilder: ...
def sign(self, encoding: Encoding, options: Iterable[PKCS7Options], backend: Any | None = ...) -> bytes: ...

View File

@@ -1 +0,0 @@
class InvalidToken(Exception): ...

View File

@@ -1,10 +0,0 @@
from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
class HOTP:
def __init__(
self, key: bytes, length: int, algorithm: HashAlgorithm, backend: HMACBackend | None = ..., enforce_key_length: bool = ...
): ...
def generate(self, counter: int) -> bytes: ...
def get_provisioning_uri(self, account_name: str, counter: int, issuer: str | None) -> str: ...
def verify(self, hotp: bytes, counter: int) -> None: ...

View File

@@ -1,16 +0,0 @@
from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives.hashes import HashAlgorithm
class TOTP:
def __init__(
self,
key: bytes,
length: int,
algorithm: HashAlgorithm,
time_step: int,
backend: HMACBackend | None = ...,
enforce_key_length: bool = ...,
): ...
def generate(self, time: int) -> bytes: ...
def get_provisioning_uri(self, account_name: str, issuer: str | None) -> str: ...
def verify(self, totp: bytes, time: int) -> None: ...

View File

@@ -1,480 +0,0 @@
import datetime
from _typeshed import Incomplete, Self
from abc import ABCMeta, abstractmethod
from collections.abc import Generator, Iterable, Sequence
from enum import Enum
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
from typing import Any, ClassVar, Generic, TypeVar
from cryptography.hazmat.backends.interfaces import X509Backend
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurvePublicKey
from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey, Ed448PublicKey
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.hazmat.primitives.serialization import Encoding
class ObjectIdentifier:
@property
def dotted_string(self) -> str: ...
def __init__(self, dotted_string: str) -> None: ...
class CRLEntryExtensionOID:
CERTIFICATE_ISSUER: ClassVar[ObjectIdentifier]
CRL_REASON: ClassVar[ObjectIdentifier]
INVALIDITY_DATE: ClassVar[ObjectIdentifier]
class ExtensionOID:
AUTHORITY_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
AUTHORITY_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
BASIC_CONSTRAINTS: ClassVar[ObjectIdentifier]
CERTIFICATE_POLICIES: ClassVar[ObjectIdentifier]
CRL_DISTRIBUTION_POINTS: ClassVar[ObjectIdentifier]
CRL_NUMBER: ClassVar[ObjectIdentifier]
DELTA_CRL_INDICATOR: ClassVar[ObjectIdentifier]
EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
FRESHEST_CRL: ClassVar[ObjectIdentifier]
INHIBIT_ANY_POLICY: ClassVar[ObjectIdentifier]
ISSUER_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
ISSUING_DISTRIBUTION_POINT: ClassVar[ObjectIdentifier]
KEY_USAGE: ClassVar[ObjectIdentifier]
NAME_CONSTRAINTS: ClassVar[ObjectIdentifier]
OCSP_NO_CHECK: ClassVar[ObjectIdentifier]
POLICY_CONSTRAINTS: ClassVar[ObjectIdentifier]
POLICY_MAPPINGS: ClassVar[ObjectIdentifier]
PRECERT_POISON: ClassVar[ObjectIdentifier]
PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: ClassVar[ObjectIdentifier]
SUBJECT_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
SUBJECT_DIRECTORY_ATTRIBUTES: ClassVar[ObjectIdentifier]
SUBJECT_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
SUBJECT_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
TLS_FEATURE: ClassVar[ObjectIdentifier]
class NameOID:
BUSINESS_CATEGORY: ClassVar[ObjectIdentifier]
COMMON_NAME: ClassVar[ObjectIdentifier]
COUNTRY_NAME: ClassVar[ObjectIdentifier]
DN_QUALIFIER: ClassVar[ObjectIdentifier]
DOMAIN_COMPONENT: ClassVar[ObjectIdentifier]
EMAIL_ADDRESS: ClassVar[ObjectIdentifier]
GENERATION_QUALIFIER: ClassVar[ObjectIdentifier]
GIVEN_NAME: ClassVar[ObjectIdentifier]
JURISDICTION_COUNTRY_NAME: ClassVar[ObjectIdentifier]
JURISDICTION_LOCALITY_NAME: ClassVar[ObjectIdentifier]
JURISDICTION_STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
LOCALITY_NAME: ClassVar[ObjectIdentifier]
ORGANIZATIONAL_UNIT_NAME: ClassVar[ObjectIdentifier]
ORGANIZATION_NAME: ClassVar[ObjectIdentifier]
POSTAL_ADDRESS: ClassVar[ObjectIdentifier]
POSTAL_CODE: ClassVar[ObjectIdentifier]
PSEUDONYM: ClassVar[ObjectIdentifier]
SERIAL_NUMBER: ClassVar[ObjectIdentifier]
STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
STREET_ADDRESS: ClassVar[ObjectIdentifier]
SURNAME: ClassVar[ObjectIdentifier]
TITLE: ClassVar[ObjectIdentifier]
USER_ID: ClassVar[ObjectIdentifier]
X500_UNIQUE_IDENTIFIER: ClassVar[ObjectIdentifier]
class OCSPExtensionOID:
NONCE: ClassVar[ObjectIdentifier]
class SignatureAlgorithmOID:
DSA_WITH_SHA1: ClassVar[ObjectIdentifier]
DSA_WITH_SHA224: ClassVar[ObjectIdentifier]
DSA_WITH_SHA256: ClassVar[ObjectIdentifier]
ECDSA_WITH_SHA1: ClassVar[ObjectIdentifier]
ECDSA_WITH_SHA224: ClassVar[ObjectIdentifier]
ECDSA_WITH_SHA256: ClassVar[ObjectIdentifier]
ECDSA_WITH_SHA384: ClassVar[ObjectIdentifier]
ECDSA_WITH_SHA512: ClassVar[ObjectIdentifier]
ED25519: ClassVar[ObjectIdentifier]
ED448: ClassVar[ObjectIdentifier]
RSASSA_PSS: ClassVar[ObjectIdentifier]
RSA_WITH_MD5: ClassVar[ObjectIdentifier]
RSA_WITH_SHA1: ClassVar[ObjectIdentifier]
RSA_WITH_SHA224: ClassVar[ObjectIdentifier]
RSA_WITH_SHA256: ClassVar[ObjectIdentifier]
RSA_WITH_SHA384: ClassVar[ObjectIdentifier]
RSA_WITH_SHA512: ClassVar[ObjectIdentifier]
class ExtendedKeyUsageOID:
SERVER_AUTH: ClassVar[ObjectIdentifier]
CLIENT_AUTH: ClassVar[ObjectIdentifier]
CODE_SIGNING: ClassVar[ObjectIdentifier]
EMAIL_PROTECTION: ClassVar[ObjectIdentifier]
TIME_STAMPING: ClassVar[ObjectIdentifier]
OCSP_SIGNING: ClassVar[ObjectIdentifier]
ANY_EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
class NameAttribute:
@property
def oid(self) -> ObjectIdentifier: ...
@property
def value(self) -> str: ...
def __init__(self, oid: ObjectIdentifier, value: str) -> None: ...
def rfc4514_string(self) -> str: ...
class RelativeDistinguishedName:
def __init__(self, attributes: list[NameAttribute]) -> None: ...
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
def get_attributes_for_oid(self, oid: ObjectIdentifier) -> list[NameAttribute]: ...
def rfc4514_string(self) -> str: ...
class Name:
@property
def rdns(self) -> list[RelativeDistinguishedName]: ...
def __init__(self, attributes: Sequence[NameAttribute | RelativeDistinguishedName]) -> None: ...
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
def __len__(self) -> int: ...
def get_attributes_for_oid(self, oid: ObjectIdentifier) -> list[NameAttribute]: ...
def public_bytes(self, backend: X509Backend | None = ...) -> bytes: ...
def rfc4514_string(self) -> str: ...
class Version(Enum):
v1: int
v3: int
# These are actually abstractproperties on Certificate,
# but let's not worry too much about that
class Certificate(metaclass=ABCMeta):
@property
def extensions(self) -> Extensions: ...
@property
def issuer(self) -> Name: ...
@property
def not_valid_after(self) -> datetime.datetime: ...
@property
def not_valid_before(self) -> datetime.datetime: ...
@property
def serial_number(self) -> int: ...
@property
def signature(self) -> bytes: ...
@property
def signature_algorithm_oid(self) -> ObjectIdentifier: ...
@property
def signature_hash_algorithm(self) -> HashAlgorithm: ...
@property
def tbs_certificate_bytes(self) -> bytes: ...
@property
def subject(self) -> Name: ...
@property
def version(self) -> Version: ...
@abstractmethod
def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
@abstractmethod
def public_bytes(self, encoding: Encoding) -> bytes: ...
@abstractmethod
def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
@abstractmethod
def __eq__(self, __other: object) -> bool: ...
@abstractmethod
def __ne__(self, __other: object) -> bool: ...
class CertificateBuilder:
def __init__(
self,
issuer_name: Name | None = ...,
subject_name: Name | None = ...,
public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey | None = ...,
serial_number: int | None = ...,
not_valid_before: datetime.datetime | None = ...,
not_valid_after: datetime.datetime | None = ...,
extensions: Iterable[ExtensionType] | None = ...,
) -> None: ...
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateBuilder: ...
def issuer_name(self, name: Name) -> CertificateBuilder: ...
def not_valid_after(self, time: datetime.datetime) -> CertificateBuilder: ...
def not_valid_before(self, time: datetime.datetime) -> CertificateBuilder: ...
def public_key(
self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey
) -> CertificateBuilder: ...
def serial_number(self, serial_number: int) -> CertificateBuilder: ...
def sign(
self,
private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm | None,
backend: X509Backend | None = ...,
) -> Certificate: ...
def subject_name(self, name: Name) -> CertificateBuilder: ...
class CertificateRevocationList(metaclass=ABCMeta):
@property
def extensions(self) -> Extensions: ...
@property
def issuer(self) -> Name: ...
@property
def last_update(self) -> datetime.datetime: ...
@property
def next_update(self) -> datetime.datetime: ...
@property
def signature(self) -> bytes: ...
@property
def signature_algorithm_oid(self) -> ObjectIdentifier: ...
@property
def signature_hash_algorithm(self) -> HashAlgorithm: ...
@property
def tbs_certlist_bytes(self) -> bytes: ...
@abstractmethod
def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
@abstractmethod
def get_revoked_certificate_by_serial_number(self, serial_number: int) -> RevokedCertificate: ...
@abstractmethod
def is_signature_valid(
self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey
) -> bool: ...
@abstractmethod
def public_bytes(self, encoding: Encoding) -> bytes: ...
@abstractmethod
def __eq__(self, __other: object) -> bool: ...
@abstractmethod
def __ne__(self, __other: object) -> bool: ...
class CertificateRevocationListBuilder:
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateRevocationListBuilder: ...
def add_revoked_certificate(self, revoked_certificate: RevokedCertificate) -> CertificateRevocationListBuilder: ...
def issuer_name(self, name: Name) -> CertificateRevocationListBuilder: ...
def last_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
def next_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
def sign(
self,
private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm | None,
backend: X509Backend | None = ...,
) -> CertificateRevocationList: ...
class CertificateSigningRequest(metaclass=ABCMeta):
@property
def extensions(self) -> Extensions: ...
@property
def is_signature_valid(self) -> bool: ...
@property
def signature(self) -> bytes: ...
@property
def signature_algorithm_oid(self) -> ObjectIdentifier: ...
@property
def signature_hash_algorithm(self) -> HashAlgorithm: ...
@property
def subject(self) -> Name: ...
@property
def tbs_certrequest_bytes(self) -> bytes: ...
@abstractmethod
def public_bytes(self, encoding: Encoding) -> bytes: ...
@abstractmethod
def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
@abstractmethod
def __eq__(self, __other: object) -> bool: ...
@abstractmethod
def __ne__(self, __other: object) -> bool: ...
class CertificateSigningRequestBuilder:
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateSigningRequestBuilder: ...
def subject_name(self, name: Name) -> CertificateSigningRequestBuilder: ...
def sign(
self,
private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
algorithm: HashAlgorithm | None,
backend: X509Backend | None = ...,
) -> CertificateSigningRequest: ...
class RevokedCertificate(metaclass=ABCMeta):
@property
def extensions(self) -> Extensions: ...
@property
def revocation_date(self) -> datetime.datetime: ...
@property
def serial_number(self) -> int: ...
class RevokedCertificateBuilder:
def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ...
def build(self, backend: X509Backend | None = ...) -> RevokedCertificate: ...
def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ...
def serial_number(self, serial_number: int) -> RevokedCertificateBuilder: ...
# General Name Classes
class GeneralName(metaclass=ABCMeta):
@property
def value(self): ...
class DirectoryName(GeneralName):
@property
def value(self) -> Name: ...
def __init__(self, value: Name) -> None: ...
class DNSName(GeneralName):
@property
def value(self) -> str: ...
def __init__(self, value: str) -> None: ...
class IPAddress(GeneralName):
@property
def value(self) -> IPv4Address | IPv6Address | IPv4Network | IPv6Network: ...
def __init__(self, value: IPv4Address | IPv6Address | IPv4Network | IPv6Network) -> None: ...
class OtherName(GeneralName):
@property
def type_id(self) -> ObjectIdentifier: ...
@property
def value(self) -> bytes: ...
def __init__(self, type_id: ObjectIdentifier, value: bytes) -> None: ...
class RegisteredID(GeneralName):
@property
def value(self) -> ObjectIdentifier: ...
def __init__(self, value: ObjectIdentifier) -> None: ...
class RFC822Name(GeneralName):
@property
def value(self) -> str: ...
def __init__(self, value: str) -> None: ...
class UniformResourceIdentifier(GeneralName):
@property
def value(self) -> str: ...
def __init__(self, value: str) -> None: ...
# X.509 Extensions
class ExtensionType(metaclass=ABCMeta):
oid: ObjectIdentifier
_T = TypeVar("_T", bound=ExtensionType)
class Extension(Generic[_T]):
@property
def critical(self) -> bool: ...
@property
def oid(self) -> ObjectIdentifier: ...
@property
def value(self) -> _T: ...
class Extensions:
def __init__(self, general_names: list[Extension[Any]]) -> None: ...
def __iter__(self) -> Generator[Extension[Any], None, None]: ...
def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension[Any]: ...
def get_extension_for_class(self, extclass: type[_T]) -> Extension[_T]: ...
class DuplicateExtension(Exception):
oid: ObjectIdentifier
def __init__(self, msg: str, oid: ObjectIdentifier) -> None: ...
class ExtensionNotFound(Exception):
oid: ObjectIdentifier
def __init__(self, msg: str, oid: ObjectIdentifier) -> None: ...
class IssuerAlternativeName(ExtensionType):
def __init__(self, general_names: list[GeneralName]) -> None: ...
def __iter__(self) -> Generator[GeneralName, None, None]: ...
def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ...
class SubjectAlternativeName(ExtensionType):
def __init__(self, general_names: list[GeneralName]) -> None: ...
def __iter__(self) -> Generator[GeneralName, None, None]: ...
def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ...
class AuthorityKeyIdentifier(ExtensionType):
@property
def key_identifier(self) -> bytes: ...
@property
def authority_cert_issuer(self) -> list[GeneralName] | None: ...
@property
def authority_cert_serial_number(self) -> int | None: ...
def __init__(
self, key_identifier: bytes, authority_cert_issuer: Iterable[GeneralName] | None, authority_cert_serial_number: int | None
) -> None: ...
@classmethod
def from_issuer_public_key(
cls: type[Self], public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey
) -> Self: ...
@classmethod
def from_issuer_subject_key_identifier(cls: type[Self], ski: SubjectKeyIdentifier) -> Self: ...
class SubjectKeyIdentifier(ExtensionType):
@property
def digest(self) -> bytes: ...
def __init__(self, digest: bytes) -> None: ...
@classmethod
def from_public_key(
cls: type[Self], public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey
) -> Self: ...
class AccessDescription:
@property
def access_method(self) -> ObjectIdentifier: ...
@property
def access_location(self) -> GeneralName: ...
def __init__(self, access_method: ObjectIdentifier, access_location: GeneralName) -> None: ...
class AuthorityInformationAccess(ExtensionType):
def __init__(self, descriptions: Iterable[AccessDescription]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[AccessDescription, None, None]: ...
def __getitem__(self, item: int) -> AccessDescription: ...
class SubjectInformationAccess(ExtensionType):
def __init__(self, descriptions: Iterable[AccessDescription]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[AccessDescription, None, None]: ...
def __getitem__(self, item: int) -> AccessDescription: ...
class BasicConstraints(ExtensionType):
@property
def ca(self) -> bool: ...
@property
def path_length(self) -> int | None: ...
def __init__(self, ca: bool, path_length: int | None) -> None: ...
class KeyUsage(ExtensionType):
@property
def digital_signature(self) -> bool: ...
@property
def content_commitment(self) -> bool: ...
@property
def key_encipherment(self) -> bool: ...
@property
def data_encipherment(self) -> bool: ...
@property
def key_agreement(self) -> bool: ...
@property
def key_cert_sign(self) -> bool: ...
@property
def crl_sign(self) -> bool: ...
@property
def encipher_only(self) -> bool: ...
@property
def decipher_only(self) -> bool: ...
def __init__(
self,
digital_signature: bool,
content_commitment: bool,
key_encipherment: bool,
data_encipherment: bool,
key_agreement: bool,
key_cert_sign: bool,
crl_sign: bool,
encipher_only: bool,
decipher_only: bool,
) -> None: ...
class ExtendedKeyUsage(ExtensionType):
def __init__(self, usages: Iterable[ObjectIdentifier]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[ObjectIdentifier, None, None]: ...
def __getitem__(self, item: int) -> ObjectIdentifier: ...
class UnrecognizedExtension(ExtensionType):
@property
def value(self) -> bytes: ...
@property
def oid(self) -> ObjectIdentifier: ... # type: ignore[override]
def __init__(self, oid: ObjectIdentifier, value: bytes) -> None: ...
def load_der_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ...
def load_pem_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ...
def load_der_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ...
def load_pem_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ...
def load_der_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ...
def load_pem_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ...
def __getattr__(name: str) -> Incomplete: ...

View File

@@ -1,26 +0,0 @@
from collections.abc import Iterator
from cryptography.x509 import GeneralName, ObjectIdentifier
class Extension:
@property
def value(self): ...
class GeneralNames:
def __iter__(self) -> Iterator[GeneralName]: ...
class DistributionPoint:
@property
def full_name(self) -> GeneralNames: ...
class CRLDistributionPoints:
def __iter__(self) -> Iterator[DistributionPoint]: ...
class AccessDescription:
@property
def access_method(self) -> ObjectIdentifier: ...
@property
def access_location(self) -> GeneralName: ...
class AuthorityInformationAccess:
def __iter__(self) -> Iterator[AccessDescription]: ...

View File

@@ -1,103 +0,0 @@
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from cryptography.x509 import ObjectIdentifier
class ExtensionOID:
SUBJECT_DIRECTORY_ATTRIBUTES: ObjectIdentifier = ...
SUBJECT_KEY_IDENTIFIER: ObjectIdentifier = ...
KEY_USAGE: ObjectIdentifier = ...
SUBJECT_ALTERNATIVE_NAME: ObjectIdentifier = ...
ISSUER_ALTERNATIVE_NAME: ObjectIdentifier = ...
BASIC_CONSTRAINTS: ObjectIdentifier = ...
NAME_CONSTRAINTS: ObjectIdentifier = ...
CRL_DISTRIBUTION_POINTS: ObjectIdentifier = ...
CERTIFICATE_POLICIES: ObjectIdentifier = ...
POLICY_MAPPINGS: ObjectIdentifier = ...
AUTHORITY_KEY_IDENTIFIER: ObjectIdentifier = ...
POLICY_CONSTRAINTS: ObjectIdentifier = ...
EXTENDED_KEY_USAGE: ObjectIdentifier = ...
FRESHEST_CRL: ObjectIdentifier = ...
INHIBIT_ANY_POLICY: ObjectIdentifier = ...
ISSUING_DISTRIBUTION_POINT: ObjectIdentifier = ...
AUTHORITY_INFORMATION_ACCESS: ObjectIdentifier = ...
SUBJECT_INFORMATION_ACCESS: ObjectIdentifier = ...
OCSP_NO_CHECK: ObjectIdentifier = ...
TLS_FEATURE: ObjectIdentifier = ...
CRL_NUMBER: ObjectIdentifier = ...
DELTA_CRL_INDICATOR: ObjectIdentifier = ...
PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: ObjectIdentifier = ...
PRECERT_POISON: ObjectIdentifier = ...
class OCSPExtensionOID:
NONCE: ObjectIdentifier = ...
class CRLEntryExtensionOID:
CERTIFICATE_ISSUER: ObjectIdentifier = ...
CRL_REASON: ObjectIdentifier = ...
INVALIDITY_DATE: ObjectIdentifier = ...
class NameOID:
COMMON_NAME: ObjectIdentifier = ...
COUNTRY_NAME: ObjectIdentifier = ...
LOCALITY_NAME: ObjectIdentifier = ...
STATE_OR_PROVINCE_NAME: ObjectIdentifier = ...
STREET_ADDRESS: ObjectIdentifier = ...
ORGANIZATION_NAME: ObjectIdentifier = ...
ORGANIZATIONAL_UNIT_NAME: ObjectIdentifier = ...
SERIAL_NUMBER: ObjectIdentifier = ...
SURNAME: ObjectIdentifier = ...
GIVEN_NAME: ObjectIdentifier = ...
TITLE: ObjectIdentifier = ...
GENERATION_QUALIFIER: ObjectIdentifier = ...
X500_UNIQUE_IDENTIFIER: ObjectIdentifier = ...
DN_QUALIFIER: ObjectIdentifier = ...
PSEUDONYM: ObjectIdentifier = ...
USER_ID: ObjectIdentifier = ...
DOMAIN_COMPONENT: ObjectIdentifier = ...
EMAIL_ADDRESS: ObjectIdentifier = ...
JURISDICTION_COUNTRY_NAME: ObjectIdentifier = ...
JURISDICTION_LOCALITY_NAME: ObjectIdentifier = ...
JURISDICTION_STATE_OR_PROVINCE_NAME: ObjectIdentifier = ...
BUSINESS_CATEGORY: ObjectIdentifier = ...
POSTAL_ADDRESS: ObjectIdentifier = ...
POSTAL_CODE: ObjectIdentifier = ...
class SignatureAlgorithmOID:
RSA_WITH_MD5: ObjectIdentifier = ...
RSA_WITH_SHA1: ObjectIdentifier = ...
_RSA_WITH_SHA1: ObjectIdentifier = ...
RSA_WITH_SHA224: ObjectIdentifier = ...
RSA_WITH_SHA256: ObjectIdentifier = ...
RSA_WITH_SHA384: ObjectIdentifier = ...
RSA_WITH_SHA512: ObjectIdentifier = ...
RSASSA_PSS: ObjectIdentifier = ...
ECDSA_WITH_SHA1: ObjectIdentifier = ...
ECDSA_WITH_SHA224: ObjectIdentifier = ...
ECDSA_WITH_SHA256: ObjectIdentifier = ...
ECDSA_WITH_SHA384: ObjectIdentifier = ...
ECDSA_WITH_SHA512: ObjectIdentifier = ...
DSA_WITH_SHA1: ObjectIdentifier = ...
DSA_WITH_SHA224: ObjectIdentifier = ...
DSA_WITH_SHA256: ObjectIdentifier = ...
ED25519: ObjectIdentifier = ...
ED448: ObjectIdentifier = ...
class ExtendedKeyUsageOID:
SERVER_AUTH: ObjectIdentifier = ...
CLIENT_AUTH: ObjectIdentifier = ...
CODE_SIGNING: ObjectIdentifier = ...
EMAIL_PROTECTION: ObjectIdentifier = ...
TIME_STAMPING: ObjectIdentifier = ...
OCSP_SIGNING: ObjectIdentifier = ...
ANY_EXTENDED_KEY_USAGE: ObjectIdentifier = ...
class AuthorityInformationAccessOID:
CA_ISSUERS: ObjectIdentifier = ...
OCSP: ObjectIdentifier = ...
class CertificatePoliciesOID:
CPS_QUALIFIER: ObjectIdentifier = ...
CPS_USER_NOTICE: ObjectIdentifier = ...
ANY_POLICY: ObjectIdentifier = ...
_OID_NAMES: dict[ObjectIdentifier, str]
_SIG_OIDS_TO_HASH: dict[ObjectIdentifier, HashAlgorithm | None]

View File

@@ -1,5 +1,6 @@
version = "2.12.*"
requires = ["types-cryptography"]
# Requires a version of cryptography where cryptography.hazmat.primitives.ciphers.Cipher is generic
requires = ["cryptography>=37.0.0"]
[tool.stubtest]
# linux and darwin are equivalent

View File

@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Callable
from hashlib import _Hash
from logging import Logger
@@ -25,7 +26,7 @@ class Packetizer:
def set_log(self, log: Logger) -> None: ...
def set_outbound_cipher(
self,
block_engine: Cipher,
block_engine: Cipher[Incomplete],
block_size: int,
mac_engine: _Hash,
mac_size: int,
@@ -34,7 +35,7 @@ class Packetizer:
etm: bool = ...,
) -> None: ...
def set_inbound_cipher(
self, block_engine: Cipher, block_size: int, mac_engine: _Hash, mac_size: int, mac_key: bytes, etm: bool = ...
self, block_engine: Cipher[Incomplete], block_size: int, mac_engine: _Hash, mac_size: int, mac_key: bytes, etm: bool = ...
) -> None: ...
def set_outbound_compressor(self, compressor: ZlibCompressor) -> None: ...
def set_inbound_compressor(self, compressor: ZlibDecompressor) -> None: ...

View File

@@ -1,2 +1,3 @@
version = "23.0.*"
requires = ["types-cryptography"]
# Requires a version of cryptography with a `py.typed` file
requires = ["cryptography>=35.0.0"]