massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / cryptography / cryptography / x509 / __init__.pyi
1 import datetime
2 from abc import ABCMeta, abstractmethod
3 from enum import Enum
4 from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
5 from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, Text, Type, TypeVar
6
7 from cryptography.hazmat.backends.interfaces import X509Backend
8 from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
9 from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurvePublicKey
10 from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey, Ed448PublicKey
11 from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
12 from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
13 from cryptography.hazmat.primitives.hashes import HashAlgorithm
14 from cryptography.hazmat.primitives.serialization import Encoding
15
16 class ObjectIdentifier(object):
17     dotted_string: str
18     def __init__(self, dotted_string: str) -> None: ...
19
20 class CRLEntryExtensionOID(object):
21     CERTIFICATE_ISSUER: ClassVar[ObjectIdentifier]
22     CRL_REASON: ClassVar[ObjectIdentifier]
23     INVALIDITY_DATE: ClassVar[ObjectIdentifier]
24
25 class ExtensionOID(object):
26     AUTHORITY_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
27     AUTHORITY_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
28     BASIC_CONSTRAINTS: ClassVar[ObjectIdentifier]
29     CERTIFICATE_POLICIES: ClassVar[ObjectIdentifier]
30     CRL_DISTRIBUTION_POINTS: ClassVar[ObjectIdentifier]
31     CRL_NUMBER: ClassVar[ObjectIdentifier]
32     DELTA_CRL_INDICATOR: ClassVar[ObjectIdentifier]
33     EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
34     FRESHEST_CRL: ClassVar[ObjectIdentifier]
35     INHIBIT_ANY_POLICY: ClassVar[ObjectIdentifier]
36     ISSUER_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
37     ISSUING_DISTRIBUTION_POINT: ClassVar[ObjectIdentifier]
38     KEY_USAGE: ClassVar[ObjectIdentifier]
39     NAME_CONSTRAINTS: ClassVar[ObjectIdentifier]
40     OCSP_NO_CHECK: ClassVar[ObjectIdentifier]
41     POLICY_CONSTRAINTS: ClassVar[ObjectIdentifier]
42     POLICY_MAPPINGS: ClassVar[ObjectIdentifier]
43     PRECERT_POISON: ClassVar[ObjectIdentifier]
44     PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: ClassVar[ObjectIdentifier]
45     SUBJECT_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
46     SUBJECT_DIRECTORY_ATTRIBUTES: ClassVar[ObjectIdentifier]
47     SUBJECT_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
48     SUBJECT_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
49     TLS_FEATURE: ClassVar[ObjectIdentifier]
50
51 class NameOID(object):
52     BUSINESS_CATEGORY: ClassVar[ObjectIdentifier]
53     COMMON_NAME: ClassVar[ObjectIdentifier]
54     COUNTRY_NAME: ClassVar[ObjectIdentifier]
55     DN_QUALIFIER: ClassVar[ObjectIdentifier]
56     DOMAIN_COMPONENT: ClassVar[ObjectIdentifier]
57     EMAIL_ADDRESS: ClassVar[ObjectIdentifier]
58     GENERATION_QUALIFIER: ClassVar[ObjectIdentifier]
59     GIVEN_NAME: ClassVar[ObjectIdentifier]
60     JURISDICTION_COUNTRY_NAME: ClassVar[ObjectIdentifier]
61     JURISDICTION_LOCALITY_NAME: ClassVar[ObjectIdentifier]
62     JURISDICTION_STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
63     LOCALITY_NAME: ClassVar[ObjectIdentifier]
64     ORGANIZATIONAL_UNIT_NAME: ClassVar[ObjectIdentifier]
65     ORGANIZATION_NAME: ClassVar[ObjectIdentifier]
66     POSTAL_ADDRESS: ClassVar[ObjectIdentifier]
67     POSTAL_CODE: ClassVar[ObjectIdentifier]
68     PSEUDONYM: ClassVar[ObjectIdentifier]
69     SERIAL_NUMBER: ClassVar[ObjectIdentifier]
70     STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
71     STREET_ADDRESS: ClassVar[ObjectIdentifier]
72     SURNAME: ClassVar[ObjectIdentifier]
73     TITLE: ClassVar[ObjectIdentifier]
74     USER_ID: ClassVar[ObjectIdentifier]
75     X500_UNIQUE_IDENTIFIER: ClassVar[ObjectIdentifier]
76
77 class OCSPExtensionOID(object):
78     NONCE: ClassVar[ObjectIdentifier]
79
80 class SignatureAlgorithmOID(object):
81     DSA_WITH_SHA1: ClassVar[ObjectIdentifier]
82     DSA_WITH_SHA224: ClassVar[ObjectIdentifier]
83     DSA_WITH_SHA256: ClassVar[ObjectIdentifier]
84     ECDSA_WITH_SHA1: ClassVar[ObjectIdentifier]
85     ECDSA_WITH_SHA224: ClassVar[ObjectIdentifier]
86     ECDSA_WITH_SHA256: ClassVar[ObjectIdentifier]
87     ECDSA_WITH_SHA384: ClassVar[ObjectIdentifier]
88     ECDSA_WITH_SHA512: ClassVar[ObjectIdentifier]
89     ED25519: ClassVar[ObjectIdentifier]
90     ED448: ClassVar[ObjectIdentifier]
91     RSASSA_PSS: ClassVar[ObjectIdentifier]
92     RSA_WITH_MD5: ClassVar[ObjectIdentifier]
93     RSA_WITH_SHA1: ClassVar[ObjectIdentifier]
94     RSA_WITH_SHA224: ClassVar[ObjectIdentifier]
95     RSA_WITH_SHA256: ClassVar[ObjectIdentifier]
96     RSA_WITH_SHA384: ClassVar[ObjectIdentifier]
97     RSA_WITH_SHA512: ClassVar[ObjectIdentifier]
98
99 class ExtendedKeyUsageOID(object):
100     SERVER_AUTH: ClassVar[ObjectIdentifier]
101     CLIENT_AUTH: ClassVar[ObjectIdentifier]
102     CODE_SIGNING: ClassVar[ObjectIdentifier]
103     EMAIL_PROTECTION: ClassVar[ObjectIdentifier]
104     TIME_STAMPING: ClassVar[ObjectIdentifier]
105     OCSP_SIGNING: ClassVar[ObjectIdentifier]
106     ANY_EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
107
108 class NameAttribute(object):
109     oid: ObjectIdentifier
110     value: Text
111     def __init__(self, oid: ObjectIdentifier, value: Text) -> None: ...
112     def rfc4514_string(self) -> str: ...
113
114 class RelativeDistinguishedName(object):
115     def __init__(self, attributes: list[NameAttribute]) -> None: ...
116     def __iter__(self) -> Generator[NameAttribute, None, None]: ...
117     def get_attributes_for_oid(self, oid: ObjectIdentifier) -> list[NameAttribute]: ...
118     def rfc4514_string(self) -> str: ...
119
120 class Name(object):
121     rdns: list[RelativeDistinguishedName]
122     def __init__(self, attributes: Sequence[NameAttribute | RelativeDistinguishedName]) -> None: ...
123     def __iter__(self) -> Generator[NameAttribute, None, None]: ...
124     def __len__(self) -> int: ...
125     def get_attributes_for_oid(self, oid: ObjectIdentifier) -> list[NameAttribute]: ...
126     def public_bytes(self, backend: X509Backend | None = ...) -> bytes: ...
127     def rfc4514_string(self) -> str: ...
128
129 class Version(Enum):
130     v1: int
131     v3: int
132
133 class Certificate(metaclass=ABCMeta):
134     extensions: Extensions
135     issuer: Name
136     not_valid_after: datetime.datetime
137     not_valid_before: datetime.datetime
138     serial_number: int
139     signature: bytes
140     signature_algorithm_oid: ObjectIdentifier
141     signature_hash_algorithm: HashAlgorithm
142     tbs_certificate_bytes: bytes
143     subject: Name
144     version: Version
145     @abstractmethod
146     def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
147     @abstractmethod
148     def public_bytes(self, encoding: Encoding) -> bytes: ...
149     @abstractmethod
150     def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
151
152 class CertificateBuilder(object):
153     def __init__(
154         self,
155         issuer_name: Name | None = ...,
156         subject_name: Name | None = ...,
157         public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey | None = ...,
158         serial_number: int | None = ...,
159         not_valid_before: datetime.datetime | None = ...,
160         not_valid_after: datetime.datetime | None = ...,
161         extensions: Iterable[ExtensionType] | None = ...,
162     ) -> None: ...
163     def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateBuilder: ...
164     def issuer_name(self, name: Name) -> CertificateBuilder: ...
165     def not_valid_after(self, time: datetime.datetime) -> CertificateBuilder: ...
166     def not_valid_before(self, time: datetime.datetime) -> CertificateBuilder: ...
167     def public_key(
168         self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey
169     ) -> CertificateBuilder: ...
170     def serial_number(self, serial_number: int) -> CertificateBuilder: ...
171     def sign(
172         self,
173         private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
174         algorithm: HashAlgorithm | None,
175         backend: X509Backend | None = ...,
176     ) -> Certificate: ...
177     def subject_name(self, name: Name) -> CertificateBuilder: ...
178
179 class CertificateRevocationList(metaclass=ABCMeta):
180     extensions: Extensions
181     issuer: Name
182     last_update: datetime.datetime
183     next_update: datetime.datetime
184     signature: bytes
185     signature_algorithm_oid: ObjectIdentifier
186     signature_hash_algorithm: HashAlgorithm
187     tbs_certlist_bytes: bytes
188     @abstractmethod
189     def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
190     @abstractmethod
191     def get_revoked_certificate_by_serial_number(self, serial_number: int) -> RevokedCertificate: ...
192     @abstractmethod
193     def is_signature_valid(
194         self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey
195     ) -> bool: ...
196     @abstractmethod
197     def public_bytes(self, encoding: Encoding) -> bytes: ...
198
199 class CertificateRevocationListBuilder(object):
200     def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateRevocationListBuilder: ...
201     def add_revoked_certificate(self, revoked_certificate: RevokedCertificate) -> CertificateRevocationListBuilder: ...
202     def issuer_name(self, name: Name) -> CertificateRevocationListBuilder: ...
203     def last_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
204     def next_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
205     def sign(
206         self,
207         private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
208         algorithm: HashAlgorithm | None,
209         backend: X509Backend | None = ...,
210     ) -> CertificateRevocationList: ...
211
212 class CertificateSigningRequest(metaclass=ABCMeta):
213     extensions: Extensions
214     is_signature_valid: bool
215     signature: bytes
216     signature_algorithm_oid: ObjectIdentifier
217     signature_hash_algorithm: HashAlgorithm
218     subject: Name
219     tbs_certrequest_bytes: bytes
220     @abstractmethod
221     def public_bytes(self, encoding: Encoding) -> bytes: ...
222     @abstractmethod
223     def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
224
225 class CertificateSigningRequestBuilder(object):
226     def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateSigningRequestBuilder: ...
227     def subject_name(self, name: Name) -> CertificateSigningRequestBuilder: ...
228     def sign(
229         self,
230         private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey,
231         algorithm: HashAlgorithm | None,
232         backend: X509Backend | None = ...,
233     ) -> CertificateSigningRequest: ...
234
235 class RevokedCertificate(metaclass=ABCMeta):
236     extensions: Extensions
237     revocation_date: datetime.datetime
238     serial_number: int
239
240 class RevokedCertificateBuilder(object):
241     def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ...
242     def build(self, backend: X509Backend | None = ...) -> RevokedCertificate: ...
243     def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ...
244     def serial_number(self, serial_number: int) -> RevokedCertificateBuilder: ...
245
246 # General Name Classes
247
248 class GeneralName(metaclass=ABCMeta):
249     value: Any
250
251 class DirectoryName(GeneralName):
252     value: Name
253     def __init__(self, value: Name) -> None: ...
254
255 class DNSName(GeneralName):
256     value: Text
257     def __init__(self, value: Text) -> None: ...
258
259 class IPAddress(GeneralName):
260     value: IPv4Address | IPv6Address | IPv4Network | IPv6Network
261     def __init__(self, value: IPv4Address | IPv6Address | IPv4Network | IPv6Network) -> None: ...
262
263 class OtherName(GeneralName):
264     type_id: ObjectIdentifier
265     value: bytes
266     def __init__(self, type_id: ObjectIdentifier, value: bytes) -> None: ...
267
268 class RegisteredID(GeneralName):
269     value: ObjectIdentifier
270     def __init__(self, value: ObjectIdentifier) -> None: ...
271
272 class RFC822Name(GeneralName):
273     value: Text
274     def __init__(self, value: Text) -> None: ...
275
276 class UniformResourceIdentifier(GeneralName):
277     value: Text
278     def __init__(self, value: Text) -> None: ...
279
280 # X.509 Extensions
281
282 class ExtensionType(metaclass=ABCMeta):
283     oid: ObjectIdentifier
284
285 _T = TypeVar("_T", bound="ExtensionType")
286
287 class Extension(Generic[_T]):
288     critical: bool
289     oid: ObjectIdentifier
290     value: _T
291
292 class Extensions(object):
293     def __init__(self, general_names: list[Extension[Any]]) -> None: ...
294     def __iter__(self) -> Generator[Extension[Any], None, None]: ...
295     def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension[Any]: ...
296     def get_extension_for_class(self, extclass: Type[_T]) -> Extension[_T]: ...
297
298 class DuplicateExtension(Exception):
299     oid: ObjectIdentifier
300     def __init__(self, msg: str, oid: ObjectIdentifier) -> None: ...
301
302 class ExtensionNotFound(Exception):
303     oid: ObjectIdentifier
304     def __init__(self, msg: str, oid: ObjectIdentifier) -> None: ...
305
306 class IssuerAlternativeName(ExtensionType):
307     def __init__(self, general_names: list[GeneralName]) -> None: ...
308     def __iter__(self) -> Generator[GeneralName, None, None]: ...
309     def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ...
310
311 class SubjectAlternativeName(ExtensionType):
312     def __init__(self, general_names: list[GeneralName]) -> None: ...
313     def __iter__(self) -> Generator[GeneralName, None, None]: ...
314     def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ...
315
316 class AuthorityKeyIdentifier(ExtensionType):
317     @property
318     def key_identifier(self) -> bytes: ...
319     @property
320     def authority_cert_issuer(self) -> list[GeneralName] | None: ...
321     @property
322     def authority_cert_serial_number(self) -> int | None: ...
323     def __init__(
324         self, key_identifier: bytes, authority_cert_issuer: Iterable[GeneralName] | None, authority_cert_serial_number: int | None
325     ) -> None: ...
326     @classmethod
327     def from_issuer_public_key(
328         cls, public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey
329     ) -> AuthorityKeyIdentifier: ...
330     @classmethod
331     def from_issuer_subject_key_identifier(cls, ski: SubjectKeyIdentifier) -> AuthorityKeyIdentifier: ...
332
333 class SubjectKeyIdentifier(ExtensionType):
334     @property
335     def digest(self) -> bytes: ...
336     def __init__(self, digest: bytes) -> None: ...
337     @classmethod
338     def from_public_key(
339         cls, public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey
340     ) -> SubjectKeyIdentifier: ...
341
342 class AccessDescription:
343     @property
344     def access_method(self) -> ObjectIdentifier: ...
345     @property
346     def access_location(self) -> GeneralName: ...
347     def __init__(self, access_method: ObjectIdentifier, access_location: GeneralName) -> None: ...
348
349 class AuthorityInformationAccess(ExtensionType):
350     def __init__(self, descriptions: Iterable[AccessDescription]) -> None: ...
351     def __len__(self) -> int: ...
352     def __iter__(self) -> Generator[AccessDescription, None, None]: ...
353     def __getitem__(self, item: int) -> AccessDescription: ...
354
355 class SubjectInformationAccess(ExtensionType):
356     def __init__(self, descriptions: Iterable[AccessDescription]) -> None: ...
357     def __len__(self) -> int: ...
358     def __iter__(self) -> Generator[AccessDescription, None, None]: ...
359     def __getitem__(self, item: int) -> AccessDescription: ...
360
361 class BasicConstraints(ExtensionType):
362     @property
363     def ca(self) -> bool: ...
364     @property
365     def path_length(self) -> int | None: ...
366     def __init__(self, ca: bool, path_length: int | None) -> None: ...
367
368 class KeyUsage(ExtensionType):
369     @property
370     def digital_signature(self) -> bool: ...
371     @property
372     def content_commitment(self) -> bool: ...
373     @property
374     def key_encipherment(self) -> bool: ...
375     @property
376     def data_encipherment(self) -> bool: ...
377     @property
378     def key_agreement(self) -> bool: ...
379     @property
380     def key_cert_sign(self) -> bool: ...
381     @property
382     def crl_sign(self) -> bool: ...
383     @property
384     def encipher_only(self) -> bool: ...
385     @property
386     def decipher_only(self) -> bool: ...
387     def __init__(
388         self,
389         digital_signature: bool,
390         content_commitment: bool,
391         key_encipherment: bool,
392         data_encipherment: bool,
393         key_agreement: bool,
394         key_cert_sign: bool,
395         crl_sign: bool,
396         encipher_only: bool,
397         decipher_only: bool,
398     ) -> None: ...
399
400 class ExtendedKeyUsage(ExtensionType):
401     def __init__(self, usages: Iterable[ObjectIdentifier]) -> None: ...
402     def __len__(self) -> int: ...
403     def __iter__(self) -> Generator[ObjectIdentifier, None, None]: ...
404     def __getitem__(self, item: int) -> ObjectIdentifier: ...
405
406 class UnrecognizedExtension(ExtensionType):
407     @property
408     def value(self) -> bytes: ...
409     def __init__(self, oid: ObjectIdentifier, value: bytes) -> None: ...
410
411 def load_der_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ...
412 def load_pem_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ...
413 def load_der_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ...
414 def load_pem_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ...
415 def load_der_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ...
416 def load_pem_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ...
417 def __getattr__(name: str) -> Any: ...  # incomplete