mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-24 04:41:30 +08:00
Made all backends Optional (#4625)
- in accordance with changes in cryptography Fixes #4561
This commit is contained in:
@@ -28,7 +28,7 @@ class DHParameterNumbers(object):
|
||||
@property
|
||||
def q(self) -> int: ...
|
||||
def __init__(self, p: int, g: int, q: Optional[int]) -> None: ...
|
||||
def parameters(self, backend: DHBackend) -> DHParameters: ...
|
||||
def parameters(self, backend: Optional[DHBackend] = ...) -> DHParameters: ...
|
||||
|
||||
class DHPrivateKey(metaclass=ABCMeta):
|
||||
key_size: int
|
||||
@@ -53,7 +53,7 @@ class DHPrivateNumbers(object):
|
||||
@property
|
||||
def x(self) -> int: ...
|
||||
def __init__(self, x: int, public_numbers: DHPublicNumbers) -> None: ...
|
||||
def private_key(self, backend: DHBackend) -> DHPrivateKey: ...
|
||||
def private_key(self, backend: Optional[DHBackend] = ...) -> DHPrivateKey: ...
|
||||
|
||||
class DHPublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@@ -74,4 +74,6 @@ class DHPublicNumbers(object):
|
||||
@property
|
||||
def y(self) -> int: ...
|
||||
def __init__(self, y: int, parameter_numbers: DHParameterNumbers) -> None: ...
|
||||
def public_key(self, backend: DHBackend) -> DHPublicKey: ...
|
||||
def public_key(self, backend: Optional[DHBackend] = ...) -> DHPublicKey: ...
|
||||
|
||||
def generate_parameters(generator: int, key_size: int, backend: Optional[DHBackend] = ...) -> DHParameters: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Union
|
||||
from typing import Optional, Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import DSABackend
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
@@ -23,7 +23,7 @@ class DSAParameterNumbers(object):
|
||||
@property
|
||||
def g(self) -> int: ...
|
||||
def __init__(self, p: int, q: int, g: int) -> None: ...
|
||||
def parameters(self, backend: DSABackend) -> DSAParameters: ...
|
||||
def parameters(self, backend: Optional[DSABackend] = ...) -> DSAParameters: ...
|
||||
|
||||
class DSAPrivateKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@@ -75,5 +75,5 @@ class DSAPublicNumbers(object):
|
||||
def parameter_numbers(self) -> DSAParameterNumbers: ...
|
||||
def __init__(self, y: int, parameter_numbers: DSAParameterNumbers) -> None: ...
|
||||
|
||||
def generate_parameters(key_size: int, backend: DSABackend) -> DSAParameters: ...
|
||||
def generate_private_key(key_size: int, backend: DSABackend) -> DSAPrivateKey: ...
|
||||
def generate_parameters(key_size: int, backend: Optional[DSABackend] = ...) -> DSAParameters: ...
|
||||
def generate_private_key(key_size: int, backend: Optional[DSABackend] = ...) -> DSAPrivateKey: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import ClassVar, Union
|
||||
from typing import ClassVar, Optional, Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import EllipticCurveBackend
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
@@ -141,7 +141,7 @@ class EllipticCurvePrivateNumbers(object):
|
||||
@property
|
||||
def public_numbers(self) -> EllipticCurvePublicNumbers: ...
|
||||
def __init__(self, private_value: int, public_numbers: EllipticCurvePublicNumbers) -> None: ...
|
||||
def private_key(self, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
def private_key(self, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePrivateKey: ...
|
||||
|
||||
class EllipticCurvePublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@@ -175,7 +175,7 @@ class EllipticCurvePublicNumbers(object):
|
||||
def __init__(self, x: int, y: int, curve: EllipticCurve) -> None: ...
|
||||
@classmethod
|
||||
def from_encoded_point(cls, curve: EllipticCurve, data: bytes) -> EllipticCurvePublicNumbers: ...
|
||||
def public_key(self, backend: EllipticCurveBackend) -> EllipticCurvePublicKey: ...
|
||||
def public_key(self, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePublicKey: ...
|
||||
|
||||
class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta):
|
||||
@property
|
||||
@@ -189,6 +189,8 @@ class ECDSA(EllipticCurveSignatureAlgorithm):
|
||||
@property
|
||||
def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ...
|
||||
|
||||
def derive_private_key(private_value: int, curve: EllipticCurve, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
def generate_private_key(curve: EllipticCurve, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
def derive_private_key(
|
||||
private_value: int, curve: EllipticCurve, backend: Optional[EllipticCurveBackend] = ...
|
||||
) -> EllipticCurvePrivateKey: ...
|
||||
def generate_private_key(curve: EllipticCurve, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePrivateKey: ...
|
||||
def get_curve_for_oid(oid: ObjectIdentifier) -> EllipticCurve: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Tuple, Union
|
||||
from typing import Optional, Tuple, Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import RSABackend
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
@@ -48,7 +48,9 @@ class RSAPublicKey(metaclass=ABCMeta):
|
||||
|
||||
RSAPublicKeyWithSerialization = RSAPublicKey
|
||||
|
||||
def generate_private_key(public_exponent: int, key_size: int, backend: RSABackend) -> RSAPrivateKeyWithSerialization: ...
|
||||
def generate_private_key(
|
||||
public_exponent: int, key_size: int, backend: Optional[RSABackend] = ...
|
||||
) -> 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: ...
|
||||
@@ -70,7 +72,7 @@ class RSAPrivateNumbers(object):
|
||||
def iqmp(self) -> int: ...
|
||||
@property
|
||||
def public_numbers(self) -> RSAPublicNumbers: ...
|
||||
def private_key(self, backend) -> RSAPrivateKey: ...
|
||||
def private_key(self, backend: Optional[RSABackend] = ...) -> RSAPrivateKey: ...
|
||||
|
||||
class RSAPublicNumbers(object):
|
||||
def __init__(self, e: int, n: int) -> None: ...
|
||||
@@ -78,4 +80,4 @@ class RSAPublicNumbers(object):
|
||||
def e(self) -> int: ...
|
||||
@property
|
||||
def n(self) -> int: ...
|
||||
def public_key(self, backend) -> RSAPublicKey: ...
|
||||
def public_key(self, backend: Optional[RSABackend] = ...) -> RSAPublicKey: ...
|
||||
|
||||
@@ -23,7 +23,7 @@ class BlockCipherAlgorithm(metaclass=ABCMeta):
|
||||
def block_size(self) -> int: ...
|
||||
|
||||
class Cipher(object):
|
||||
def __init__(self, algorithm: CipherAlgorithm, mode: Optional[Mode], backend: CipherBackend) -> None: ...
|
||||
def __init__(self, algorithm: CipherAlgorithm, mode: Optional[Mode], backend: Optional[CipherBackend] = ...) -> None: ...
|
||||
def decryptor(self) -> CipherContext: ...
|
||||
def encryptor(self) -> CipherContext: ...
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import CMACBackend
|
||||
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm
|
||||
|
||||
class CMAC(object):
|
||||
def __init__(self, algorithm: BlockCipherAlgorithm, backend: CMACBackend) -> None: ...
|
||||
def __init__(self, algorithm: BlockCipherAlgorithm, backend: Optional[CMACBackend] = ...) -> None: ...
|
||||
def copy(self) -> CMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HashBackend
|
||||
|
||||
@@ -37,7 +38,7 @@ class SHAKE256(HashAlgorithm):
|
||||
def __init__(self, digest_size: int) -> None: ...
|
||||
|
||||
class Hash(HashContext):
|
||||
def __init__(self, algorithm: HashAlgorithm, backend: HashBackend): ...
|
||||
def __init__(self, algorithm: HashAlgorithm, backend: Optional[HashBackend] = ...): ...
|
||||
def copy(self) -> Hash: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class HMAC(object):
|
||||
def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: HMACBackend) -> None: ...
|
||||
def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: Optional[HMACBackend] = ...) -> None: ...
|
||||
def copy(self) -> HMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, msg: bytes) -> None: ...
|
||||
|
||||
@@ -5,13 +5,20 @@ 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: Optional[bytes], backend: HashBackend): ...
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, otherinfo: Optional[bytes], backend: Optional[HashBackend] = ...
|
||||
): ...
|
||||
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: Optional[bytes], otherinfo: Optional[bytes], backend: HMACBackend
|
||||
self,
|
||||
algorithm: HashAlgorithm,
|
||||
length: int,
|
||||
salt: Optional[bytes],
|
||||
otherinfo: Optional[bytes],
|
||||
backend: Optional[HMACBackend] = ...,
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -6,12 +6,17 @@ from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class HKDF(KeyDerivationFunction):
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, salt: Optional[bytes], info: Optional[bytes], backend: HMACBackend
|
||||
self,
|
||||
algorithm: HashAlgorithm,
|
||||
length: int,
|
||||
salt: Optional[bytes],
|
||||
info: Optional[bytes],
|
||||
backend: Optional[HMACBackend] = ...,
|
||||
): ...
|
||||
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: Optional[bytes], backend: HMACBackend): ...
|
||||
def __init__(self, algorithm: HashAlgorithm, length: int, info: Optional[bytes], backend: Optional[HMACBackend] = ...): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -24,7 +24,7 @@ class KBKDFHMAC(KeyDerivationFunction):
|
||||
label: Optional[bytes],
|
||||
context: Optional[bytes],
|
||||
fixed: Optional[bytes],
|
||||
backend: HMACBackend,
|
||||
backend: Optional[HMACBackend] = ...,
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
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): ...
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, backend: Optional[PBKDF2HMACBackend] = ...
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from typing import Optional
|
||||
|
||||
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): ...
|
||||
def __init__(self, salt: bytes, length: int, n: int, r: int, p: int, backend: Optional[ScryptBackend] = ...): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -5,6 +5,8 @@ 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: Optional[bytes], backend: HashBackend): ...
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, sharedinfo: Optional[bytes], backend: Optional[HashBackend] = ...
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import CipherBackend
|
||||
|
||||
def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ...
|
||||
def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ...
|
||||
def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ...
|
||||
def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ...
|
||||
|
||||
class InvalidUnwrap(Exception): ...
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
def load_key_and_certificates(data: bytes, password: Optional[bytes], backend): ...
|
||||
def load_key_and_certificates(data: bytes, password: Optional[bytes], backend: Optional[Any] = ...): ...
|
||||
|
||||
22
third_party/2and3/cryptography/x509.pyi
vendored
22
third_party/2and3/cryptography/x509.pyi
vendored
@@ -114,7 +114,7 @@ class Name(object):
|
||||
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) -> bytes: ...
|
||||
def public_bytes(self, backend: Optional[X509Backend] = ...) -> bytes: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class Version(Enum):
|
||||
@@ -163,7 +163,7 @@ class CertificateBuilder(object):
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
backend: Optional[X509Backend] = ...,
|
||||
) -> Certificate: ...
|
||||
def subject_name(self, name: Name) -> CertificateBuilder: ...
|
||||
|
||||
@@ -197,7 +197,7 @@ class CertificateRevocationListBuilder(object):
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
backend: Optional[X509Backend] = ...,
|
||||
) -> CertificateRevocationList: ...
|
||||
|
||||
class CertificateSigningRequest(metaclass=ABCMeta):
|
||||
@@ -220,7 +220,7 @@ class CertificateSigningRequestBuilder(object):
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
backend: Optional[X509Backend] = ...,
|
||||
) -> CertificateSigningRequest: ...
|
||||
|
||||
class RevokedCertificate(metaclass=ABCMeta):
|
||||
@@ -230,7 +230,7 @@ class RevokedCertificate(metaclass=ABCMeta):
|
||||
|
||||
class RevokedCertificateBuilder(object):
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ...
|
||||
def build(self, backend: X509Backend) -> RevokedCertificate: ...
|
||||
def build(self, backend: Optional[X509Backend] = ...) -> RevokedCertificate: ...
|
||||
def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ...
|
||||
def serial_number(self, serial_number: int) -> RevokedCertificateBuilder: ...
|
||||
|
||||
@@ -296,10 +296,10 @@ class SubjectAlternativeName(ExtensionType):
|
||||
def __iter__(self) -> Generator[GeneralName, None, None]: ...
|
||||
def get_values_for_type(self, type: Type[GeneralName]) -> List[Any]: ...
|
||||
|
||||
def load_der_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
|
||||
def load_pem_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
|
||||
def load_der_x509_crl(data: bytes, backend: X509Backend) -> CertificateRevocationList: ...
|
||||
def load_pem_x509_crl(data: bytes, backend: X509Backend) -> CertificateRevocationList: ...
|
||||
def load_der_x509_csr(data: bytes, backend: X509Backend) -> CertificateSigningRequest: ...
|
||||
def load_pem_x509_csr(data: bytes, backend: X509Backend) -> CertificateSigningRequest: ...
|
||||
def load_der_x509_certificate(data: bytes, backend: Optional[X509Backend] = ...) -> Certificate: ...
|
||||
def load_pem_x509_certificate(data: bytes, backend: Optional[X509Backend] = ...) -> Certificate: ...
|
||||
def load_der_x509_crl(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateRevocationList: ...
|
||||
def load_pem_x509_crl(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateRevocationList: ...
|
||||
def load_der_x509_csr(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateSigningRequest: ...
|
||||
def load_pem_x509_csr(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateSigningRequest: ...
|
||||
def __getattr__(name: str) -> Any: ... # incomplete
|
||||
|
||||
Reference in New Issue
Block a user