koichi12 commited on
Commit
9255ced
·
verified ·
1 Parent(s): 66f4e48

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. .venv/lib/python3.11/site-packages/cryptography/hazmat/__pycache__/__init__.cpython-311.pyc +0 -0
  3. .venv/lib/python3.11/site-packages/cryptography/hazmat/__pycache__/_oid.cpython-311.pyc +0 -0
  4. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
  5. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/__pycache__/__init__.cpython-311.pyc +0 -0
  6. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +24 -0
  7. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
  8. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
  9. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
  10. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +23 -0
  11. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +71 -0
  12. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
  13. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
  14. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
  15. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +17 -0
  16. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +33 -0
  17. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +12 -0
  18. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +12 -0
  19. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +46 -0
  20. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +30 -0
  21. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +29 -0
  22. .venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +108 -0
  23. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
  24. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/__pycache__/__init__.cpython-311.pyc +0 -0
  25. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
  26. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__pycache__/__init__.cpython-311.pyc +0 -0
  27. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__pycache__/algorithms.cpython-311.pyc +0 -0
  28. .venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +107 -0
  29. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/__init__.cpython-311.pyc +0 -0
  30. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_asymmetric.cpython-311.pyc +0 -0
  31. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_cipheralgorithm.cpython-311.pyc +0 -0
  32. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_serialization.cpython-311.pyc +0 -0
  33. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/cmac.cpython-311.pyc +0 -0
  34. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/constant_time.cpython-311.pyc +0 -0
  35. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/hashes.cpython-311.pyc +0 -0
  36. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/hmac.cpython-311.pyc +0 -0
  37. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/keywrap.cpython-311.pyc +0 -0
  38. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/padding.cpython-311.pyc +0 -0
  39. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/poly1305.cpython-311.pyc +0 -0
  40. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
  41. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/__init__.cpython-311.pyc +0 -0
  42. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/aead.cpython-311.pyc +0 -0
  43. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/algorithms.cpython-311.pyc +0 -0
  44. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-311.pyc +0 -0
  45. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/modes.cpython-311.pyc +0 -0
  46. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
  47. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +177 -0
  48. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/base.py +145 -0
  49. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
  50. .venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
.gitattributes CHANGED
@@ -329,3 +329,5 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cudnn/lib/
329
  .venv/lib/python3.11/site-packages/httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
330
  .venv/lib/python3.11/site-packages/httptools/parser/parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
331
  .venv/lib/python3.11/site-packages/yarl/_quoting_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
 
329
  .venv/lib/python3.11/site-packages/httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
330
  .venv/lib/python3.11/site-packages/httptools/parser/parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
331
  .venv/lib/python3.11/site-packages/yarl/_quoting_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
332
+ .venv/lib/python3.11/site-packages/cryptography/x509/__pycache__/extensions.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
333
+ .venv/lib/python3.11/site-packages/sentencepiece/_sentencepiece.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
.venv/lib/python3.11/site-packages/cryptography/hazmat/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (258 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/__pycache__/_oid.cpython-311.pyc ADDED
Binary file (18.9 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (201 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives import padding
8
+
9
+ def check_pkcs7_padding(data: bytes) -> bool: ...
10
+ def check_ansix923_padding(data: bytes) -> bool: ...
11
+
12
+ class PKCS7PaddingContext(padding.PaddingContext):
13
+ def __init__(self, block_size: int) -> None: ...
14
+ def update(self, data: bytes) -> bytes: ...
15
+ def finalize(self) -> bytes: ...
16
+
17
+ class ObjectIdentifier:
18
+ def __init__(self, val: str) -> None: ...
19
+ @property
20
+ def dotted_string(self) -> str: ...
21
+ @property
22
+ def _name(self) -> str: ...
23
+
24
+ T = typing.TypeVar("T")
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ lib = typing.Any
8
+ ffi = typing.Any
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ def decode_dss_signature(signature: bytes) -> tuple[int, int]: ...
6
+ def encode_dss_signature(r: int, s: int) -> bytes: ...
7
+ def parse_spki_for_data(data: bytes) -> bytes: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ class _Reasons:
6
+ BACKEND_MISSING_INTERFACE: _Reasons
7
+ UNSUPPORTED_HASH: _Reasons
8
+ UNSUPPORTED_CIPHER: _Reasons
9
+ UNSUPPORTED_PADDING: _Reasons
10
+ UNSUPPORTED_MGF: _Reasons
11
+ UNSUPPORTED_PUBLIC_KEY_ALGORITHM: _Reasons
12
+ UNSUPPORTED_ELLIPTIC_CURVE: _Reasons
13
+ UNSUPPORTED_SERIALIZATION: _Reasons
14
+ UNSUPPORTED_X509: _Reasons
15
+ UNSUPPORTED_EXCHANGE_ALGORITHM: _Reasons
16
+ UNSUPPORTED_DIFFIE_HELLMAN: _Reasons
17
+ UNSUPPORTED_MAC: _Reasons
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from cryptography.hazmat.primitives import hashes
6
+ from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
7
+ from cryptography.x509 import ocsp
8
+
9
+ class OCSPRequest: ...
10
+ class OCSPResponse: ...
11
+ class OCSPSingleResponse: ...
12
+
13
+ def load_der_ocsp_request(data: bytes) -> ocsp.OCSPRequest: ...
14
+ def load_der_ocsp_response(data: bytes) -> ocsp.OCSPResponse: ...
15
+ def create_ocsp_request(
16
+ builder: ocsp.OCSPRequestBuilder,
17
+ ) -> ocsp.OCSPRequest: ...
18
+ def create_ocsp_response(
19
+ status: ocsp.OCSPResponseStatus,
20
+ builder: ocsp.OCSPResponseBuilder | None,
21
+ private_key: PrivateKeyTypes | None,
22
+ hash_algorithm: hashes.HashAlgorithm | None,
23
+ ) -> ocsp.OCSPResponse: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.bindings._rust.openssl import (
8
+ aead,
9
+ ciphers,
10
+ cmac,
11
+ dh,
12
+ dsa,
13
+ ec,
14
+ ed448,
15
+ ed25519,
16
+ hashes,
17
+ hmac,
18
+ kdf,
19
+ keys,
20
+ poly1305,
21
+ rsa,
22
+ x448,
23
+ x25519,
24
+ )
25
+
26
+ __all__ = [
27
+ "aead",
28
+ "ciphers",
29
+ "cmac",
30
+ "dh",
31
+ "dsa",
32
+ "ec",
33
+ "ed448",
34
+ "ed25519",
35
+ "hashes",
36
+ "hmac",
37
+ "kdf",
38
+ "keys",
39
+ "openssl_version",
40
+ "openssl_version_text",
41
+ "poly1305",
42
+ "raise_openssl_error",
43
+ "rsa",
44
+ "x448",
45
+ "x25519",
46
+ ]
47
+
48
+ CRYPTOGRAPHY_IS_LIBRESSL: bool
49
+ CRYPTOGRAPHY_IS_BORINGSSL: bool
50
+ CRYPTOGRAPHY_OPENSSL_300_OR_GREATER: bool
51
+ CRYPTOGRAPHY_OPENSSL_320_OR_GREATER: bool
52
+
53
+ class Providers: ...
54
+
55
+ _legacy_provider_loaded: bool
56
+ _providers: Providers
57
+
58
+ def openssl_version() -> int: ...
59
+ def openssl_version_text() -> str: ...
60
+ def raise_openssl_error() -> typing.NoReturn: ...
61
+ def capture_error_stack() -> list[OpenSSLError]: ...
62
+ def is_fips_enabled() -> bool: ...
63
+ def enable_fips(providers: Providers) -> None: ...
64
+
65
+ class OpenSSLError:
66
+ @property
67
+ def lib(self) -> int: ...
68
+ @property
69
+ def reason(self) -> int: ...
70
+ @property
71
+ def reason_text(self) -> bytes: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives import ciphers
8
+ from cryptography.hazmat.primitives.ciphers import modes
9
+
10
+ @typing.overload
11
+ def create_encryption_ctx(
12
+ algorithm: ciphers.CipherAlgorithm, mode: modes.ModeWithAuthenticationTag
13
+ ) -> ciphers.AEADEncryptionContext: ...
14
+ @typing.overload
15
+ def create_encryption_ctx(
16
+ algorithm: ciphers.CipherAlgorithm, mode: modes.Mode
17
+ ) -> ciphers.CipherContext: ...
18
+ @typing.overload
19
+ def create_decryption_ctx(
20
+ algorithm: ciphers.CipherAlgorithm, mode: modes.ModeWithAuthenticationTag
21
+ ) -> ciphers.AEADDecryptionContext: ...
22
+ @typing.overload
23
+ def create_decryption_ctx(
24
+ algorithm: ciphers.CipherAlgorithm, mode: modes.Mode
25
+ ) -> ciphers.CipherContext: ...
26
+ def cipher_supported(
27
+ algorithm: ciphers.CipherAlgorithm, mode: modes.Mode
28
+ ) -> bool: ...
29
+ def _advance(
30
+ ctx: ciphers.AEADEncryptionContext | ciphers.AEADDecryptionContext, n: int
31
+ ) -> None: ...
32
+ def _advance_aad(
33
+ ctx: ciphers.AEADEncryptionContext | ciphers.AEADDecryptionContext, n: int
34
+ ) -> None: ...
35
+
36
+ class CipherContext: ...
37
+ class AEADEncryptionContext: ...
38
+ class AEADDecryptionContext: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives.asymmetric import dh
8
+
9
+ MIN_MODULUS_SIZE: int
10
+
11
+ class DHPrivateKey: ...
12
+ class DHPublicKey: ...
13
+ class DHParameters: ...
14
+
15
+ class DHPrivateNumbers:
16
+ def __init__(self, x: int, public_numbers: DHPublicNumbers) -> None: ...
17
+ def private_key(self, backend: typing.Any = None) -> dh.DHPrivateKey: ...
18
+ @property
19
+ def x(self) -> int: ...
20
+ @property
21
+ def public_numbers(self) -> DHPublicNumbers: ...
22
+
23
+ class DHPublicNumbers:
24
+ def __init__(
25
+ self, y: int, parameter_numbers: DHParameterNumbers
26
+ ) -> None: ...
27
+ def public_key(self, backend: typing.Any = None) -> dh.DHPublicKey: ...
28
+ @property
29
+ def y(self) -> int: ...
30
+ @property
31
+ def parameter_numbers(self) -> DHParameterNumbers: ...
32
+
33
+ class DHParameterNumbers:
34
+ def __init__(self, p: int, g: int, q: int | None = None) -> None: ...
35
+ def parameters(self, backend: typing.Any = None) -> dh.DHParameters: ...
36
+ @property
37
+ def p(self) -> int: ...
38
+ @property
39
+ def g(self) -> int: ...
40
+ @property
41
+ def q(self) -> int | None: ...
42
+
43
+ def generate_parameters(
44
+ generator: int, key_size: int, backend: typing.Any = None
45
+ ) -> dh.DHParameters: ...
46
+ def from_pem_parameters(
47
+ data: bytes, backend: typing.Any = None
48
+ ) -> dh.DHParameters: ...
49
+ def from_der_parameters(
50
+ data: bytes, backend: typing.Any = None
51
+ ) -> dh.DHParameters: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives.asymmetric import dsa
8
+
9
+ class DSAPrivateKey: ...
10
+ class DSAPublicKey: ...
11
+ class DSAParameters: ...
12
+
13
+ class DSAPrivateNumbers:
14
+ def __init__(self, x: int, public_numbers: DSAPublicNumbers) -> None: ...
15
+ @property
16
+ def x(self) -> int: ...
17
+ @property
18
+ def public_numbers(self) -> DSAPublicNumbers: ...
19
+ def private_key(self, backend: typing.Any = None) -> dsa.DSAPrivateKey: ...
20
+
21
+ class DSAPublicNumbers:
22
+ def __init__(
23
+ self, y: int, parameter_numbers: DSAParameterNumbers
24
+ ) -> None: ...
25
+ @property
26
+ def y(self) -> int: ...
27
+ @property
28
+ def parameter_numbers(self) -> DSAParameterNumbers: ...
29
+ def public_key(self, backend: typing.Any = None) -> dsa.DSAPublicKey: ...
30
+
31
+ class DSAParameterNumbers:
32
+ def __init__(self, p: int, q: int, g: int) -> None: ...
33
+ @property
34
+ def p(self) -> int: ...
35
+ @property
36
+ def q(self) -> int: ...
37
+ @property
38
+ def g(self) -> int: ...
39
+ def parameters(self, backend: typing.Any = None) -> dsa.DSAParameters: ...
40
+
41
+ def generate_parameters(key_size: int) -> dsa.DSAParameters: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives import hashes
8
+
9
+ class Hash(hashes.HashContext):
10
+ def __init__(
11
+ self, algorithm: hashes.HashAlgorithm, backend: typing.Any = None
12
+ ) -> None: ...
13
+ @property
14
+ def algorithm(self) -> hashes.HashAlgorithm: ...
15
+ def update(self, data: bytes) -> None: ...
16
+ def finalize(self) -> bytes: ...
17
+ def copy(self) -> Hash: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography.hazmat.primitives.asymmetric.types import (
8
+ PrivateKeyTypes,
9
+ PublicKeyTypes,
10
+ )
11
+
12
+ def load_der_private_key(
13
+ data: bytes,
14
+ password: bytes | None,
15
+ backend: typing.Any = None,
16
+ *,
17
+ unsafe_skip_rsa_key_validation: bool = False,
18
+ ) -> PrivateKeyTypes: ...
19
+ def load_pem_private_key(
20
+ data: bytes,
21
+ password: bytes | None,
22
+ backend: typing.Any = None,
23
+ *,
24
+ unsafe_skip_rsa_key_validation: bool = False,
25
+ ) -> PrivateKeyTypes: ...
26
+ def load_der_public_key(
27
+ data: bytes,
28
+ backend: typing.Any = None,
29
+ ) -> PublicKeyTypes: ...
30
+ def load_pem_public_key(
31
+ data: bytes,
32
+ backend: typing.Any = None,
33
+ ) -> PublicKeyTypes: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from cryptography.hazmat.primitives.asymmetric import x25519
6
+
7
+ class X25519PrivateKey: ...
8
+ class X25519PublicKey: ...
9
+
10
+ def generate_key() -> x25519.X25519PrivateKey: ...
11
+ def from_private_bytes(data: bytes) -> x25519.X25519PrivateKey: ...
12
+ def from_public_bytes(data: bytes) -> x25519.X25519PublicKey: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from cryptography.hazmat.primitives.asymmetric import x448
6
+
7
+ class X448PrivateKey: ...
8
+ class X448PublicKey: ...
9
+
10
+ def generate_key() -> x448.X448PrivateKey: ...
11
+ def from_private_bytes(data: bytes) -> x448.X448PrivateKey: ...
12
+ def from_public_bytes(data: bytes) -> x448.X448PublicKey: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography import x509
8
+ from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
9
+ from cryptography.hazmat.primitives.serialization import (
10
+ KeySerializationEncryption,
11
+ )
12
+ from cryptography.hazmat.primitives.serialization.pkcs12 import (
13
+ PKCS12KeyAndCertificates,
14
+ PKCS12PrivateKeyTypes,
15
+ )
16
+
17
+ class PKCS12Certificate:
18
+ def __init__(
19
+ self, cert: x509.Certificate, friendly_name: bytes | None
20
+ ) -> None: ...
21
+ @property
22
+ def friendly_name(self) -> bytes | None: ...
23
+ @property
24
+ def certificate(self) -> x509.Certificate: ...
25
+
26
+ def load_key_and_certificates(
27
+ data: bytes,
28
+ password: bytes | None,
29
+ backend: typing.Any = None,
30
+ ) -> tuple[
31
+ PrivateKeyTypes | None,
32
+ x509.Certificate | None,
33
+ list[x509.Certificate],
34
+ ]: ...
35
+ def load_pkcs12(
36
+ data: bytes,
37
+ password: bytes | None,
38
+ backend: typing.Any = None,
39
+ ) -> PKCS12KeyAndCertificates: ...
40
+ def serialize_key_and_certificates(
41
+ name: bytes | None,
42
+ key: PKCS12PrivateKeyTypes | None,
43
+ cert: x509.Certificate | None,
44
+ cas: typing.Iterable[x509.Certificate | PKCS12Certificate] | None,
45
+ encryption_algorithm: KeySerializationEncryption,
46
+ ) -> bytes: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import typing
6
+
7
+ from cryptography import x509
8
+ from cryptography.hazmat.primitives import serialization
9
+ from cryptography.hazmat.primitives.serialization import pkcs7
10
+
11
+ def serialize_certificates(
12
+ certs: list[x509.Certificate],
13
+ encoding: serialization.Encoding,
14
+ ) -> bytes: ...
15
+ def encrypt_and_serialize(
16
+ builder: pkcs7.PKCS7EnvelopeBuilder,
17
+ encoding: serialization.Encoding,
18
+ options: typing.Iterable[pkcs7.PKCS7Options],
19
+ ) -> bytes: ...
20
+ def sign_and_serialize(
21
+ builder: pkcs7.PKCS7SignatureBuilder,
22
+ encoding: serialization.Encoding,
23
+ options: typing.Iterable[pkcs7.PKCS7Options],
24
+ ) -> bytes: ...
25
+ def load_pem_pkcs7_certificates(
26
+ data: bytes,
27
+ ) -> list[x509.Certificate]: ...
28
+ def load_der_pkcs7_certificates(
29
+ data: bytes,
30
+ ) -> list[x509.Certificate]: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from cryptography import x509
6
+ from cryptography.hazmat.primitives import serialization
7
+ from cryptography.hazmat.primitives.serialization import pkcs7
8
+
9
+ class TestCertificate:
10
+ not_after_tag: int
11
+ not_before_tag: int
12
+ issuer_value_tags: list[int]
13
+ subject_value_tags: list[int]
14
+
15
+ def test_parse_certificate(data: bytes) -> TestCertificate: ...
16
+ def pkcs7_decrypt(
17
+ encoding: serialization.Encoding,
18
+ msg: bytes,
19
+ pkey: serialization.pkcs7.PKCS7PrivateKeyTypes,
20
+ cert_recipient: x509.Certificate,
21
+ options: list[pkcs7.PKCS7Options],
22
+ ) -> bytes: ...
23
+ def pkcs7_verify(
24
+ encoding: serialization.Encoding,
25
+ sig: bytes,
26
+ msg: bytes | None,
27
+ certs: list[x509.Certificate],
28
+ options: list[pkcs7.PKCS7Options],
29
+ ) -> None: ...
.venv/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import datetime
6
+ import typing
7
+
8
+ from cryptography import x509
9
+ from cryptography.hazmat.primitives import hashes
10
+ from cryptography.hazmat.primitives.asymmetric.padding import PSS, PKCS1v15
11
+ from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
12
+
13
+ def load_pem_x509_certificate(
14
+ data: bytes, backend: typing.Any = None
15
+ ) -> x509.Certificate: ...
16
+ def load_der_x509_certificate(
17
+ data: bytes, backend: typing.Any = None
18
+ ) -> x509.Certificate: ...
19
+ def load_pem_x509_certificates(
20
+ data: bytes,
21
+ ) -> list[x509.Certificate]: ...
22
+ def load_pem_x509_crl(
23
+ data: bytes, backend: typing.Any = None
24
+ ) -> x509.CertificateRevocationList: ...
25
+ def load_der_x509_crl(
26
+ data: bytes, backend: typing.Any = None
27
+ ) -> x509.CertificateRevocationList: ...
28
+ def load_pem_x509_csr(
29
+ data: bytes, backend: typing.Any = None
30
+ ) -> x509.CertificateSigningRequest: ...
31
+ def load_der_x509_csr(
32
+ data: bytes, backend: typing.Any = None
33
+ ) -> x509.CertificateSigningRequest: ...
34
+ def encode_name_bytes(name: x509.Name) -> bytes: ...
35
+ def encode_extension_value(extension: x509.ExtensionType) -> bytes: ...
36
+ def create_x509_certificate(
37
+ builder: x509.CertificateBuilder,
38
+ private_key: PrivateKeyTypes,
39
+ hash_algorithm: hashes.HashAlgorithm | None,
40
+ rsa_padding: PKCS1v15 | PSS | None,
41
+ ) -> x509.Certificate: ...
42
+ def create_x509_csr(
43
+ builder: x509.CertificateSigningRequestBuilder,
44
+ private_key: PrivateKeyTypes,
45
+ hash_algorithm: hashes.HashAlgorithm | None,
46
+ rsa_padding: PKCS1v15 | PSS | None,
47
+ ) -> x509.CertificateSigningRequest: ...
48
+ def create_x509_crl(
49
+ builder: x509.CertificateRevocationListBuilder,
50
+ private_key: PrivateKeyTypes,
51
+ hash_algorithm: hashes.HashAlgorithm | None,
52
+ rsa_padding: PKCS1v15 | PSS | None,
53
+ ) -> x509.CertificateRevocationList: ...
54
+
55
+ class Sct: ...
56
+ class Certificate: ...
57
+ class RevokedCertificate: ...
58
+ class CertificateRevocationList: ...
59
+ class CertificateSigningRequest: ...
60
+
61
+ class PolicyBuilder:
62
+ def time(self, new_time: datetime.datetime) -> PolicyBuilder: ...
63
+ def store(self, new_store: Store) -> PolicyBuilder: ...
64
+ def max_chain_depth(self, new_max_chain_depth: int) -> PolicyBuilder: ...
65
+ def build_client_verifier(self) -> ClientVerifier: ...
66
+ def build_server_verifier(
67
+ self, subject: x509.verification.Subject
68
+ ) -> ServerVerifier: ...
69
+
70
+ class VerifiedClient:
71
+ @property
72
+ def subjects(self) -> list[x509.GeneralName]: ...
73
+ @property
74
+ def chain(self) -> list[x509.Certificate]: ...
75
+
76
+ class ClientVerifier:
77
+ @property
78
+ def validation_time(self) -> datetime.datetime: ...
79
+ @property
80
+ def store(self) -> Store: ...
81
+ @property
82
+ def max_chain_depth(self) -> int: ...
83
+ def verify(
84
+ self,
85
+ leaf: x509.Certificate,
86
+ intermediates: list[x509.Certificate],
87
+ ) -> VerifiedClient: ...
88
+
89
+ class ServerVerifier:
90
+ @property
91
+ def subject(self) -> x509.verification.Subject: ...
92
+ @property
93
+ def validation_time(self) -> datetime.datetime: ...
94
+ @property
95
+ def store(self) -> Store: ...
96
+ @property
97
+ def max_chain_depth(self) -> int: ...
98
+ def verify(
99
+ self,
100
+ leaf: x509.Certificate,
101
+ intermediates: list[x509.Certificate],
102
+ ) -> list[x509.Certificate]: ...
103
+
104
+ class Store:
105
+ def __init__(self, certs: list[x509.Certificate]) -> None: ...
106
+
107
+ class VerificationError(Exception):
108
+ pass
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (263 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (271 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/__pycache__/algorithms.cpython-311.pyc ADDED
Binary file (5.67 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ from cryptography.hazmat.primitives._cipheralgorithm import (
8
+ BlockCipherAlgorithm,
9
+ CipherAlgorithm,
10
+ _verify_key_size,
11
+ )
12
+
13
+
14
+ class ARC4(CipherAlgorithm):
15
+ name = "RC4"
16
+ key_sizes = frozenset([40, 56, 64, 80, 128, 160, 192, 256])
17
+
18
+ def __init__(self, key: bytes):
19
+ self.key = _verify_key_size(self, key)
20
+
21
+ @property
22
+ def key_size(self) -> int:
23
+ return len(self.key) * 8
24
+
25
+
26
+ class TripleDES(BlockCipherAlgorithm):
27
+ name = "3DES"
28
+ block_size = 64
29
+ key_sizes = frozenset([64, 128, 192])
30
+
31
+ def __init__(self, key: bytes):
32
+ if len(key) == 8:
33
+ key += key + key
34
+ elif len(key) == 16:
35
+ key += key[:8]
36
+ self.key = _verify_key_size(self, key)
37
+
38
+ @property
39
+ def key_size(self) -> int:
40
+ return len(self.key) * 8
41
+
42
+
43
+ class Blowfish(BlockCipherAlgorithm):
44
+ name = "Blowfish"
45
+ block_size = 64
46
+ key_sizes = frozenset(range(32, 449, 8))
47
+
48
+ def __init__(self, key: bytes):
49
+ self.key = _verify_key_size(self, key)
50
+
51
+ @property
52
+ def key_size(self) -> int:
53
+ return len(self.key) * 8
54
+
55
+
56
+ class CAST5(BlockCipherAlgorithm):
57
+ name = "CAST5"
58
+ block_size = 64
59
+ key_sizes = frozenset(range(40, 129, 8))
60
+
61
+ def __init__(self, key: bytes):
62
+ self.key = _verify_key_size(self, key)
63
+
64
+ @property
65
+ def key_size(self) -> int:
66
+ return len(self.key) * 8
67
+
68
+
69
+ class SEED(BlockCipherAlgorithm):
70
+ name = "SEED"
71
+ block_size = 128
72
+ key_sizes = frozenset([128])
73
+
74
+ def __init__(self, key: bytes):
75
+ self.key = _verify_key_size(self, key)
76
+
77
+ @property
78
+ def key_size(self) -> int:
79
+ return len(self.key) * 8
80
+
81
+
82
+ class IDEA(BlockCipherAlgorithm):
83
+ name = "IDEA"
84
+ block_size = 64
85
+ key_sizes = frozenset([128])
86
+
87
+ def __init__(self, key: bytes):
88
+ self.key = _verify_key_size(self, key)
89
+
90
+ @property
91
+ def key_size(self) -> int:
92
+ return len(self.key) * 8
93
+
94
+
95
+ # This class only allows RC2 with a 128-bit key. No support for
96
+ # effective key bits or other key sizes is provided.
97
+ class RC2(BlockCipherAlgorithm):
98
+ name = "RC2"
99
+ block_size = 64
100
+ key_sizes = frozenset([128])
101
+
102
+ def __init__(self, key: bytes):
103
+ self.key = _verify_key_size(self, key)
104
+
105
+ @property
106
+ def key_size(self) -> int:
107
+ return len(self.key) * 8
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (203 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_asymmetric.cpython-311.pyc ADDED
Binary file (909 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_cipheralgorithm.cpython-311.pyc ADDED
Binary file (2.74 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/_serialization.cpython-311.pyc ADDED
Binary file (7.71 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/cmac.cpython-311.pyc ADDED
Binary file (429 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/constant_time.cpython-311.pyc ADDED
Binary file (775 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/hashes.cpython-311.pyc ADDED
Binary file (9.48 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/hmac.cpython-311.pyc ADDED
Binary file (606 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/keywrap.cpython-311.pyc ADDED
Binary file (9.13 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/padding.cpython-311.pyc ADDED
Binary file (9.38 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/__pycache__/poly1305.cpython-311.pyc ADDED
Binary file (441 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ from cryptography.hazmat.primitives._cipheralgorithm import (
8
+ BlockCipherAlgorithm,
9
+ CipherAlgorithm,
10
+ )
11
+ from cryptography.hazmat.primitives.ciphers.base import (
12
+ AEADCipherContext,
13
+ AEADDecryptionContext,
14
+ AEADEncryptionContext,
15
+ Cipher,
16
+ CipherContext,
17
+ )
18
+
19
+ __all__ = [
20
+ "AEADCipherContext",
21
+ "AEADDecryptionContext",
22
+ "AEADEncryptionContext",
23
+ "BlockCipherAlgorithm",
24
+ "Cipher",
25
+ "CipherAlgorithm",
26
+ "CipherContext",
27
+ ]
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (756 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/aead.cpython-311.pyc ADDED
Binary file (710 Bytes). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/algorithms.cpython-311.pyc ADDED
Binary file (6.74 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-311.pyc ADDED
Binary file (7.39 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/modes.cpython-311.pyc ADDED
Binary file (13.2 kB). View file
 
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/aead.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ from cryptography.hazmat.bindings._rust import openssl as rust_openssl
8
+
9
+ __all__ = [
10
+ "AESCCM",
11
+ "AESGCM",
12
+ "AESGCMSIV",
13
+ "AESOCB3",
14
+ "AESSIV",
15
+ "ChaCha20Poly1305",
16
+ ]
17
+
18
+ AESGCM = rust_openssl.aead.AESGCM
19
+ ChaCha20Poly1305 = rust_openssl.aead.ChaCha20Poly1305
20
+ AESCCM = rust_openssl.aead.AESCCM
21
+ AESSIV = rust_openssl.aead.AESSIV
22
+ AESOCB3 = rust_openssl.aead.AESOCB3
23
+ AESGCMSIV = rust_openssl.aead.AESGCMSIV
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ from cryptography import utils
8
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
9
+ ARC4 as ARC4,
10
+ )
11
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
12
+ CAST5 as CAST5,
13
+ )
14
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
15
+ IDEA as IDEA,
16
+ )
17
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
18
+ SEED as SEED,
19
+ )
20
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
21
+ Blowfish as Blowfish,
22
+ )
23
+ from cryptography.hazmat.decrepit.ciphers.algorithms import (
24
+ TripleDES as TripleDES,
25
+ )
26
+ from cryptography.hazmat.primitives._cipheralgorithm import _verify_key_size
27
+ from cryptography.hazmat.primitives.ciphers import (
28
+ BlockCipherAlgorithm,
29
+ CipherAlgorithm,
30
+ )
31
+
32
+
33
+ class AES(BlockCipherAlgorithm):
34
+ name = "AES"
35
+ block_size = 128
36
+ # 512 added to support AES-256-XTS, which uses 512-bit keys
37
+ key_sizes = frozenset([128, 192, 256, 512])
38
+
39
+ def __init__(self, key: bytes):
40
+ self.key = _verify_key_size(self, key)
41
+
42
+ @property
43
+ def key_size(self) -> int:
44
+ return len(self.key) * 8
45
+
46
+
47
+ class AES128(BlockCipherAlgorithm):
48
+ name = "AES"
49
+ block_size = 128
50
+ key_sizes = frozenset([128])
51
+ key_size = 128
52
+
53
+ def __init__(self, key: bytes):
54
+ self.key = _verify_key_size(self, key)
55
+
56
+
57
+ class AES256(BlockCipherAlgorithm):
58
+ name = "AES"
59
+ block_size = 128
60
+ key_sizes = frozenset([256])
61
+ key_size = 256
62
+
63
+ def __init__(self, key: bytes):
64
+ self.key = _verify_key_size(self, key)
65
+
66
+
67
+ class Camellia(BlockCipherAlgorithm):
68
+ name = "camellia"
69
+ block_size = 128
70
+ key_sizes = frozenset([128, 192, 256])
71
+
72
+ def __init__(self, key: bytes):
73
+ self.key = _verify_key_size(self, key)
74
+
75
+ @property
76
+ def key_size(self) -> int:
77
+ return len(self.key) * 8
78
+
79
+
80
+ utils.deprecated(
81
+ ARC4,
82
+ __name__,
83
+ "ARC4 has been moved to "
84
+ "cryptography.hazmat.decrepit.ciphers.algorithms.ARC4 and "
85
+ "will be removed from this module in 48.0.0.",
86
+ utils.DeprecatedIn43,
87
+ name="ARC4",
88
+ )
89
+
90
+
91
+ utils.deprecated(
92
+ TripleDES,
93
+ __name__,
94
+ "TripleDES has been moved to "
95
+ "cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and "
96
+ "will be removed from this module in 48.0.0.",
97
+ utils.DeprecatedIn43,
98
+ name="TripleDES",
99
+ )
100
+
101
+ utils.deprecated(
102
+ Blowfish,
103
+ __name__,
104
+ "Blowfish has been moved to "
105
+ "cryptography.hazmat.decrepit.ciphers.algorithms.Blowfish and "
106
+ "will be removed from this module in 45.0.0.",
107
+ utils.DeprecatedIn37,
108
+ name="Blowfish",
109
+ )
110
+
111
+
112
+ utils.deprecated(
113
+ CAST5,
114
+ __name__,
115
+ "CAST5 has been moved to "
116
+ "cryptography.hazmat.decrepit.ciphers.algorithms.CAST5 and "
117
+ "will be removed from this module in 45.0.0.",
118
+ utils.DeprecatedIn37,
119
+ name="CAST5",
120
+ )
121
+
122
+
123
+ utils.deprecated(
124
+ IDEA,
125
+ __name__,
126
+ "IDEA has been moved to "
127
+ "cryptography.hazmat.decrepit.ciphers.algorithms.IDEA and "
128
+ "will be removed from this module in 45.0.0.",
129
+ utils.DeprecatedIn37,
130
+ name="IDEA",
131
+ )
132
+
133
+
134
+ utils.deprecated(
135
+ SEED,
136
+ __name__,
137
+ "SEED has been moved to "
138
+ "cryptography.hazmat.decrepit.ciphers.algorithms.SEED and "
139
+ "will be removed from this module in 45.0.0.",
140
+ utils.DeprecatedIn37,
141
+ name="SEED",
142
+ )
143
+
144
+
145
+ class ChaCha20(CipherAlgorithm):
146
+ name = "ChaCha20"
147
+ key_sizes = frozenset([256])
148
+
149
+ def __init__(self, key: bytes, nonce: bytes):
150
+ self.key = _verify_key_size(self, key)
151
+ utils._check_byteslike("nonce", nonce)
152
+
153
+ if len(nonce) != 16:
154
+ raise ValueError("nonce must be 128-bits (16 bytes)")
155
+
156
+ self._nonce = nonce
157
+
158
+ @property
159
+ def nonce(self) -> bytes:
160
+ return self._nonce
161
+
162
+ @property
163
+ def key_size(self) -> int:
164
+ return len(self.key) * 8
165
+
166
+
167
+ class SM4(BlockCipherAlgorithm):
168
+ name = "SM4"
169
+ block_size = 128
170
+ key_sizes = frozenset([128])
171
+
172
+ def __init__(self, key: bytes):
173
+ self.key = _verify_key_size(self, key)
174
+
175
+ @property
176
+ def key_size(self) -> int:
177
+ return len(self.key) * 8
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/base.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ import abc
8
+ import typing
9
+
10
+ from cryptography.hazmat.bindings._rust import openssl as rust_openssl
11
+ from cryptography.hazmat.primitives._cipheralgorithm import CipherAlgorithm
12
+ from cryptography.hazmat.primitives.ciphers import modes
13
+
14
+
15
+ class CipherContext(metaclass=abc.ABCMeta):
16
+ @abc.abstractmethod
17
+ def update(self, data: bytes) -> bytes:
18
+ """
19
+ Processes the provided bytes through the cipher and returns the results
20
+ as bytes.
21
+ """
22
+
23
+ @abc.abstractmethod
24
+ def update_into(self, data: bytes, buf: bytes) -> int:
25
+ """
26
+ Processes the provided bytes and writes the resulting data into the
27
+ provided buffer. Returns the number of bytes written.
28
+ """
29
+
30
+ @abc.abstractmethod
31
+ def finalize(self) -> bytes:
32
+ """
33
+ Returns the results of processing the final block as bytes.
34
+ """
35
+
36
+ @abc.abstractmethod
37
+ def reset_nonce(self, nonce: bytes) -> None:
38
+ """
39
+ Resets the nonce for the cipher context to the provided value.
40
+ Raises an exception if it does not support reset or if the
41
+ provided nonce does not have a valid length.
42
+ """
43
+
44
+
45
+ class AEADCipherContext(CipherContext, metaclass=abc.ABCMeta):
46
+ @abc.abstractmethod
47
+ def authenticate_additional_data(self, data: bytes) -> None:
48
+ """
49
+ Authenticates the provided bytes.
50
+ """
51
+
52
+
53
+ class AEADDecryptionContext(AEADCipherContext, metaclass=abc.ABCMeta):
54
+ @abc.abstractmethod
55
+ def finalize_with_tag(self, tag: bytes) -> bytes:
56
+ """
57
+ Returns the results of processing the final block as bytes and allows
58
+ delayed passing of the authentication tag.
59
+ """
60
+
61
+
62
+ class AEADEncryptionContext(AEADCipherContext, metaclass=abc.ABCMeta):
63
+ @property
64
+ @abc.abstractmethod
65
+ def tag(self) -> bytes:
66
+ """
67
+ Returns tag bytes. This is only available after encryption is
68
+ finalized.
69
+ """
70
+
71
+
72
+ Mode = typing.TypeVar(
73
+ "Mode", bound=typing.Optional[modes.Mode], covariant=True
74
+ )
75
+
76
+
77
+ class Cipher(typing.Generic[Mode]):
78
+ def __init__(
79
+ self,
80
+ algorithm: CipherAlgorithm,
81
+ mode: Mode,
82
+ backend: typing.Any = None,
83
+ ) -> None:
84
+ if not isinstance(algorithm, CipherAlgorithm):
85
+ raise TypeError("Expected interface of CipherAlgorithm.")
86
+
87
+ if mode is not None:
88
+ # mypy needs this assert to narrow the type from our generic
89
+ # type. Maybe it won't some time in the future.
90
+ assert isinstance(mode, modes.Mode)
91
+ mode.validate_for_algorithm(algorithm)
92
+
93
+ self.algorithm = algorithm
94
+ self.mode = mode
95
+
96
+ @typing.overload
97
+ def encryptor(
98
+ self: Cipher[modes.ModeWithAuthenticationTag],
99
+ ) -> AEADEncryptionContext: ...
100
+
101
+ @typing.overload
102
+ def encryptor(
103
+ self: _CIPHER_TYPE,
104
+ ) -> CipherContext: ...
105
+
106
+ def encryptor(self):
107
+ if isinstance(self.mode, modes.ModeWithAuthenticationTag):
108
+ if self.mode.tag is not None:
109
+ raise ValueError(
110
+ "Authentication tag must be None when encrypting."
111
+ )
112
+
113
+ return rust_openssl.ciphers.create_encryption_ctx(
114
+ self.algorithm, self.mode
115
+ )
116
+
117
+ @typing.overload
118
+ def decryptor(
119
+ self: Cipher[modes.ModeWithAuthenticationTag],
120
+ ) -> AEADDecryptionContext: ...
121
+
122
+ @typing.overload
123
+ def decryptor(
124
+ self: _CIPHER_TYPE,
125
+ ) -> CipherContext: ...
126
+
127
+ def decryptor(self):
128
+ return rust_openssl.ciphers.create_decryption_ctx(
129
+ self.algorithm, self.mode
130
+ )
131
+
132
+
133
+ _CIPHER_TYPE = Cipher[
134
+ typing.Union[
135
+ modes.ModeWithNonce,
136
+ modes.ModeWithTweak,
137
+ None,
138
+ modes.ECB,
139
+ modes.ModeWithInitializationVector,
140
+ ]
141
+ ]
142
+
143
+ CipherContext.register(rust_openssl.ciphers.CipherContext)
144
+ AEADEncryptionContext.register(rust_openssl.ciphers.AEADEncryptionContext)
145
+ AEADDecryptionContext.register(rust_openssl.ciphers.AEADDecryptionContext)
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/modes.py ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ import abc
8
+
9
+ from cryptography import utils
10
+ from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
11
+ from cryptography.hazmat.primitives._cipheralgorithm import (
12
+ BlockCipherAlgorithm,
13
+ CipherAlgorithm,
14
+ )
15
+ from cryptography.hazmat.primitives.ciphers import algorithms
16
+
17
+
18
+ class Mode(metaclass=abc.ABCMeta):
19
+ @property
20
+ @abc.abstractmethod
21
+ def name(self) -> str:
22
+ """
23
+ A string naming this mode (e.g. "ECB", "CBC").
24
+ """
25
+
26
+ @abc.abstractmethod
27
+ def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None:
28
+ """
29
+ Checks that all the necessary invariants of this (mode, algorithm)
30
+ combination are met.
31
+ """
32
+
33
+
34
+ class ModeWithInitializationVector(Mode, metaclass=abc.ABCMeta):
35
+ @property
36
+ @abc.abstractmethod
37
+ def initialization_vector(self) -> bytes:
38
+ """
39
+ The value of the initialization vector for this mode as bytes.
40
+ """
41
+
42
+
43
+ class ModeWithTweak(Mode, metaclass=abc.ABCMeta):
44
+ @property
45
+ @abc.abstractmethod
46
+ def tweak(self) -> bytes:
47
+ """
48
+ The value of the tweak for this mode as bytes.
49
+ """
50
+
51
+
52
+ class ModeWithNonce(Mode, metaclass=abc.ABCMeta):
53
+ @property
54
+ @abc.abstractmethod
55
+ def nonce(self) -> bytes:
56
+ """
57
+ The value of the nonce for this mode as bytes.
58
+ """
59
+
60
+
61
+ class ModeWithAuthenticationTag(Mode, metaclass=abc.ABCMeta):
62
+ @property
63
+ @abc.abstractmethod
64
+ def tag(self) -> bytes | None:
65
+ """
66
+ The value of the tag supplied to the constructor of this mode.
67
+ """
68
+
69
+
70
+ def _check_aes_key_length(self: Mode, algorithm: CipherAlgorithm) -> None:
71
+ if algorithm.key_size > 256 and algorithm.name == "AES":
72
+ raise ValueError(
73
+ "Only 128, 192, and 256 bit keys are allowed for this AES mode"
74
+ )
75
+
76
+
77
+ def _check_iv_length(
78
+ self: ModeWithInitializationVector, algorithm: BlockCipherAlgorithm
79
+ ) -> None:
80
+ iv_len = len(self.initialization_vector)
81
+ if iv_len * 8 != algorithm.block_size:
82
+ raise ValueError(f"Invalid IV size ({iv_len}) for {self.name}.")
83
+
84
+
85
+ def _check_nonce_length(
86
+ nonce: bytes, name: str, algorithm: CipherAlgorithm
87
+ ) -> None:
88
+ if not isinstance(algorithm, BlockCipherAlgorithm):
89
+ raise UnsupportedAlgorithm(
90
+ f"{name} requires a block cipher algorithm",
91
+ _Reasons.UNSUPPORTED_CIPHER,
92
+ )
93
+ if len(nonce) * 8 != algorithm.block_size:
94
+ raise ValueError(f"Invalid nonce size ({len(nonce)}) for {name}.")
95
+
96
+
97
+ def _check_iv_and_key_length(
98
+ self: ModeWithInitializationVector, algorithm: CipherAlgorithm
99
+ ) -> None:
100
+ if not isinstance(algorithm, BlockCipherAlgorithm):
101
+ raise UnsupportedAlgorithm(
102
+ f"{self} requires a block cipher algorithm",
103
+ _Reasons.UNSUPPORTED_CIPHER,
104
+ )
105
+ _check_aes_key_length(self, algorithm)
106
+ _check_iv_length(self, algorithm)
107
+
108
+
109
+ class CBC(ModeWithInitializationVector):
110
+ name = "CBC"
111
+
112
+ def __init__(self, initialization_vector: bytes):
113
+ utils._check_byteslike("initialization_vector", initialization_vector)
114
+ self._initialization_vector = initialization_vector
115
+
116
+ @property
117
+ def initialization_vector(self) -> bytes:
118
+ return self._initialization_vector
119
+
120
+ validate_for_algorithm = _check_iv_and_key_length
121
+
122
+
123
+ class XTS(ModeWithTweak):
124
+ name = "XTS"
125
+
126
+ def __init__(self, tweak: bytes):
127
+ utils._check_byteslike("tweak", tweak)
128
+
129
+ if len(tweak) != 16:
130
+ raise ValueError("tweak must be 128-bits (16 bytes)")
131
+
132
+ self._tweak = tweak
133
+
134
+ @property
135
+ def tweak(self) -> bytes:
136
+ return self._tweak
137
+
138
+ def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None:
139
+ if isinstance(algorithm, (algorithms.AES128, algorithms.AES256)):
140
+ raise TypeError(
141
+ "The AES128 and AES256 classes do not support XTS, please use "
142
+ "the standard AES class instead."
143
+ )
144
+
145
+ if algorithm.key_size not in (256, 512):
146
+ raise ValueError(
147
+ "The XTS specification requires a 256-bit key for AES-128-XTS"
148
+ " and 512-bit key for AES-256-XTS"
149
+ )
150
+
151
+
152
+ class ECB(Mode):
153
+ name = "ECB"
154
+
155
+ validate_for_algorithm = _check_aes_key_length
156
+
157
+
158
+ class OFB(ModeWithInitializationVector):
159
+ name = "OFB"
160
+
161
+ def __init__(self, initialization_vector: bytes):
162
+ utils._check_byteslike("initialization_vector", initialization_vector)
163
+ self._initialization_vector = initialization_vector
164
+
165
+ @property
166
+ def initialization_vector(self) -> bytes:
167
+ return self._initialization_vector
168
+
169
+ validate_for_algorithm = _check_iv_and_key_length
170
+
171
+
172
+ class CFB(ModeWithInitializationVector):
173
+ name = "CFB"
174
+
175
+ def __init__(self, initialization_vector: bytes):
176
+ utils._check_byteslike("initialization_vector", initialization_vector)
177
+ self._initialization_vector = initialization_vector
178
+
179
+ @property
180
+ def initialization_vector(self) -> bytes:
181
+ return self._initialization_vector
182
+
183
+ validate_for_algorithm = _check_iv_and_key_length
184
+
185
+
186
+ class CFB8(ModeWithInitializationVector):
187
+ name = "CFB8"
188
+
189
+ def __init__(self, initialization_vector: bytes):
190
+ utils._check_byteslike("initialization_vector", initialization_vector)
191
+ self._initialization_vector = initialization_vector
192
+
193
+ @property
194
+ def initialization_vector(self) -> bytes:
195
+ return self._initialization_vector
196
+
197
+ validate_for_algorithm = _check_iv_and_key_length
198
+
199
+
200
+ class CTR(ModeWithNonce):
201
+ name = "CTR"
202
+
203
+ def __init__(self, nonce: bytes):
204
+ utils._check_byteslike("nonce", nonce)
205
+ self._nonce = nonce
206
+
207
+ @property
208
+ def nonce(self) -> bytes:
209
+ return self._nonce
210
+
211
+ def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None:
212
+ _check_aes_key_length(self, algorithm)
213
+ _check_nonce_length(self.nonce, self.name, algorithm)
214
+
215
+
216
+ class GCM(ModeWithInitializationVector, ModeWithAuthenticationTag):
217
+ name = "GCM"
218
+ _MAX_ENCRYPTED_BYTES = (2**39 - 256) // 8
219
+ _MAX_AAD_BYTES = (2**64) // 8
220
+
221
+ def __init__(
222
+ self,
223
+ initialization_vector: bytes,
224
+ tag: bytes | None = None,
225
+ min_tag_length: int = 16,
226
+ ):
227
+ # OpenSSL 3.0.0 constrains GCM IVs to [64, 1024] bits inclusive
228
+ # This is a sane limit anyway so we'll enforce it here.
229
+ utils._check_byteslike("initialization_vector", initialization_vector)
230
+ if len(initialization_vector) < 8 or len(initialization_vector) > 128:
231
+ raise ValueError(
232
+ "initialization_vector must be between 8 and 128 bytes (64 "
233
+ "and 1024 bits)."
234
+ )
235
+ self._initialization_vector = initialization_vector
236
+ if tag is not None:
237
+ utils._check_bytes("tag", tag)
238
+ if min_tag_length < 4:
239
+ raise ValueError("min_tag_length must be >= 4")
240
+ if len(tag) < min_tag_length:
241
+ raise ValueError(
242
+ f"Authentication tag must be {min_tag_length} bytes or "
243
+ "longer."
244
+ )
245
+ self._tag = tag
246
+ self._min_tag_length = min_tag_length
247
+
248
+ @property
249
+ def tag(self) -> bytes | None:
250
+ return self._tag
251
+
252
+ @property
253
+ def initialization_vector(self) -> bytes:
254
+ return self._initialization_vector
255
+
256
+ def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None:
257
+ _check_aes_key_length(self, algorithm)
258
+ if not isinstance(algorithm, BlockCipherAlgorithm):
259
+ raise UnsupportedAlgorithm(
260
+ "GCM requires a block cipher algorithm",
261
+ _Reasons.UNSUPPORTED_CIPHER,
262
+ )
263
+ block_size_bytes = algorithm.block_size // 8
264
+ if self._tag is not None and len(self._tag) > block_size_bytes:
265
+ raise ValueError(
266
+ f"Authentication tag cannot be more than {block_size_bytes} "
267
+ "bytes."
268
+ )
.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/kdf/__init__.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ from __future__ import annotations
6
+
7
+ import abc
8
+
9
+
10
+ class KeyDerivationFunction(metaclass=abc.ABCMeta):
11
+ @abc.abstractmethod
12
+ def derive(self, key_material: bytes) -> bytes:
13
+ """
14
+ Deterministically generates and returns a new key based on the existing
15
+ key material.
16
+ """
17
+
18
+ @abc.abstractmethod
19
+ def verify(self, key_material: bytes, expected_key: bytes) -> None:
20
+ """
21
+ Checks whether the key generated by the key material matches the
22
+ expected derived key. Raises an exception if they do not match.
23
+ """