@pairling/runtime-darwin-x64 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +1 -1
  2. package/bin/pairling-connectd +0 -0
  3. package/manifest.json +4 -4
  4. package/package.json +3 -3
  5. package/python/bin/python3 +0 -0
  6. package/python/bin/python3.12 +0 -0
  7. package/python/lib/libpython3.12.dylib +0 -0
  8. package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
  9. package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
  10. package/python/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so +0 -0
  11. package/python/lib/python3.12/site-packages/cffi/__init__.py +14 -0
  12. package/python/lib/python3.12/site-packages/cffi/_cffi_errors.h +149 -0
  13. package/python/lib/python3.12/site-packages/cffi/_cffi_include.h +389 -0
  14. package/python/lib/python3.12/site-packages/cffi/_embedding.h +550 -0
  15. package/python/lib/python3.12/site-packages/cffi/_imp_emulation.py +83 -0
  16. package/python/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py +45 -0
  17. package/python/lib/python3.12/site-packages/cffi/api.py +967 -0
  18. package/python/lib/python3.12/site-packages/cffi/backend_ctypes.py +1121 -0
  19. package/python/lib/python3.12/site-packages/cffi/cffi_opcode.py +187 -0
  20. package/python/lib/python3.12/site-packages/cffi/commontypes.py +82 -0
  21. package/python/lib/python3.12/site-packages/cffi/cparser.py +1015 -0
  22. package/python/lib/python3.12/site-packages/cffi/error.py +31 -0
  23. package/python/lib/python3.12/site-packages/cffi/ffiplatform.py +113 -0
  24. package/python/lib/python3.12/site-packages/cffi/lock.py +30 -0
  25. package/python/lib/python3.12/site-packages/cffi/model.py +618 -0
  26. package/python/lib/python3.12/site-packages/cffi/parse_c_type.h +181 -0
  27. package/python/lib/python3.12/site-packages/cffi/pkgconfig.py +121 -0
  28. package/python/lib/python3.12/site-packages/cffi/recompiler.py +1598 -0
  29. package/python/lib/python3.12/site-packages/cffi/setuptools_ext.py +216 -0
  30. package/python/lib/python3.12/site-packages/cffi/vengine_cpy.py +1084 -0
  31. package/python/lib/python3.12/site-packages/cffi/vengine_gen.py +679 -0
  32. package/python/lib/python3.12/site-packages/cffi/verifier.py +306 -0
  33. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/INSTALLER +1 -0
  34. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/LICENSE +26 -0
  35. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/METADATA +40 -0
  36. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/RECORD +30 -0
  37. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/WHEEL +5 -0
  38. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/entry_points.txt +2 -0
  39. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/top_level.txt +2 -0
  40. package/python/lib/python3.12/site-packages/cryptography/__about__.py +17 -0
  41. package/python/lib/python3.12/site-packages/cryptography/__init__.py +26 -0
  42. package/python/lib/python3.12/site-packages/cryptography/exceptions.py +52 -0
  43. package/python/lib/python3.12/site-packages/cryptography/fernet.py +224 -0
  44. package/python/lib/python3.12/site-packages/cryptography/hazmat/__init__.py +13 -0
  45. package/python/lib/python3.12/site-packages/cryptography/hazmat/_oid.py +348 -0
  46. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/__init__.py +13 -0
  47. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/__init__.py +9 -0
  48. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py +308 -0
  49. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
  50. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
  51. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
  52. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
  53. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
  54. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
  55. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
  56. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
  57. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
  58. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
  59. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
  60. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
  61. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
  62. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
  63. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
  64. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
  65. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
  66. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
  67. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
  68. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
  69. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
  70. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
  71. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
  72. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
  73. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
  74. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
  75. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
  76. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust.abi3.so +0 -0
  77. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/__init__.py +3 -0
  78. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +191 -0
  79. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/binding.py +122 -0
  80. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
  81. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
  82. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +112 -0
  83. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/__init__.py +3 -0
  84. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_asymmetric.py +19 -0
  85. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +60 -0
  86. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_serialization.py +168 -0
  87. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py +3 -0
  88. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +147 -0
  89. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +167 -0
  90. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +447 -0
  91. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +129 -0
  92. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +131 -0
  93. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +113 -0
  94. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +277 -0
  95. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py +111 -0
  96. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py +24 -0
  97. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +122 -0
  98. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +125 -0
  99. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
  100. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
  101. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +183 -0
  102. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py +146 -0
  103. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
  104. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/cmac.py +10 -0
  105. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/constant_time.py +14 -0
  106. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hashes.py +246 -0
  107. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hmac.py +13 -0
  108. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
  109. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/argon2.py +13 -0
  110. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +125 -0
  111. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +101 -0
  112. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +305 -0
  113. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +62 -0
  114. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py +19 -0
  115. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +61 -0
  116. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/keywrap.py +177 -0
  117. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/padding.py +69 -0
  118. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/poly1305.py +11 -0
  119. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +65 -0
  120. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/base.py +14 -0
  121. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +176 -0
  122. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +411 -0
  123. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1619 -0
  124. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/__init__.py +9 -0
  125. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +101 -0
  126. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +56 -0
  127. package/python/lib/python3.12/site-packages/cryptography/py.typed +0 -0
  128. package/python/lib/python3.12/site-packages/cryptography/utils.py +139 -0
  129. package/python/lib/python3.12/site-packages/cryptography/x509/__init__.py +270 -0
  130. package/python/lib/python3.12/site-packages/cryptography/x509/base.py +848 -0
  131. package/python/lib/python3.12/site-packages/cryptography/x509/certificate_transparency.py +35 -0
  132. package/python/lib/python3.12/site-packages/cryptography/x509/extensions.py +2528 -0
  133. package/python/lib/python3.12/site-packages/cryptography/x509/general_name.py +281 -0
  134. package/python/lib/python3.12/site-packages/cryptography/x509/name.py +477 -0
  135. package/python/lib/python3.12/site-packages/cryptography/x509/ocsp.py +379 -0
  136. package/python/lib/python3.12/site-packages/cryptography/x509/oid.py +37 -0
  137. package/python/lib/python3.12/site-packages/cryptography/x509/verification.py +34 -0
  138. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/INSTALLER +1 -0
  139. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/METADATA +139 -0
  140. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/RECORD +106 -0
  141. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/REQUESTED +0 -0
  142. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/WHEEL +4 -0
  143. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE +3 -0
  144. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.APACHE +202 -0
  145. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.BSD +27 -0
  146. package/python/lib/python3.12/site-packages/pycparser/__init__.py +99 -0
  147. package/python/lib/python3.12/site-packages/pycparser/_ast_gen.py +355 -0
  148. package/python/lib/python3.12/site-packages/pycparser/_c_ast.cfg +195 -0
  149. package/python/lib/python3.12/site-packages/pycparser/ast_transforms.py +174 -0
  150. package/python/lib/python3.12/site-packages/pycparser/c_ast.py +1341 -0
  151. package/python/lib/python3.12/site-packages/pycparser/c_generator.py +573 -0
  152. package/python/lib/python3.12/site-packages/pycparser/c_lexer.py +706 -0
  153. package/python/lib/python3.12/site-packages/pycparser/c_parser.py +2376 -0
  154. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/INSTALLER +1 -0
  155. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/METADATA +244 -0
  156. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/RECORD +14 -0
  157. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/WHEEL +5 -0
  158. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/licenses/LICENSE +27 -0
  159. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,9 @@
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
+
8
+ class InvalidToken(Exception):
9
+ pass
@@ -0,0 +1,101 @@
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 base64
8
+ import typing
9
+ from urllib.parse import quote, urlencode
10
+
11
+ from cryptography.hazmat.primitives import constant_time, hmac
12
+ from cryptography.hazmat.primitives.hashes import SHA1, SHA256, SHA512
13
+ from cryptography.hazmat.primitives.twofactor import InvalidToken
14
+ from cryptography.utils import Buffer
15
+
16
+ HOTPHashTypes = typing.Union[SHA1, SHA256, SHA512]
17
+
18
+
19
+ def _generate_uri(
20
+ hotp: HOTP,
21
+ type_name: str,
22
+ account_name: str,
23
+ issuer: str | None,
24
+ extra_parameters: list[tuple[str, int]],
25
+ ) -> str:
26
+ parameters = [
27
+ ("digits", hotp._length),
28
+ ("secret", base64.b32encode(hotp._key)),
29
+ ("algorithm", hotp._algorithm.name.upper()),
30
+ ]
31
+
32
+ if issuer is not None:
33
+ parameters.append(("issuer", issuer))
34
+
35
+ parameters.extend(extra_parameters)
36
+
37
+ label = (
38
+ f"{quote(issuer)}:{quote(account_name)}"
39
+ if issuer
40
+ else quote(account_name)
41
+ )
42
+ return f"otpauth://{type_name}/{label}?{urlencode(parameters)}"
43
+
44
+
45
+ class HOTP:
46
+ def __init__(
47
+ self,
48
+ key: Buffer,
49
+ length: int,
50
+ algorithm: HOTPHashTypes,
51
+ backend: typing.Any = None,
52
+ enforce_key_length: bool = True,
53
+ ) -> None:
54
+ if len(key) < 16 and enforce_key_length is True:
55
+ raise ValueError("Key length has to be at least 128 bits.")
56
+
57
+ if not isinstance(length, int):
58
+ raise TypeError("Length parameter must be an integer type.")
59
+
60
+ if length < 6 or length > 8:
61
+ raise ValueError("Length of HOTP has to be between 6 and 8.")
62
+
63
+ if not isinstance(algorithm, (SHA1, SHA256, SHA512)):
64
+ raise TypeError("Algorithm must be SHA1, SHA256 or SHA512.")
65
+
66
+ self._key = key
67
+ self._length = length
68
+ self._algorithm = algorithm
69
+
70
+ def generate(self, counter: int) -> bytes:
71
+ if not isinstance(counter, int):
72
+ raise TypeError("Counter parameter must be an integer type.")
73
+
74
+ truncated_value = self._dynamic_truncate(counter)
75
+ hotp = truncated_value % (10**self._length)
76
+ return "{0:0{1}}".format(hotp, self._length).encode()
77
+
78
+ def verify(self, hotp: bytes, counter: int) -> None:
79
+ if not constant_time.bytes_eq(self.generate(counter), hotp):
80
+ raise InvalidToken("Supplied HOTP value does not match.")
81
+
82
+ def _dynamic_truncate(self, counter: int) -> int:
83
+ ctx = hmac.HMAC(self._key, self._algorithm)
84
+
85
+ try:
86
+ ctx.update(counter.to_bytes(length=8, byteorder="big"))
87
+ except OverflowError:
88
+ raise ValueError(f"Counter must be between 0 and {2**64 - 1}.")
89
+
90
+ hmac_value = ctx.finalize()
91
+
92
+ offset = hmac_value[len(hmac_value) - 1] & 0b1111
93
+ p = hmac_value[offset : offset + 4]
94
+ return int.from_bytes(p, byteorder="big") & 0x7FFFFFFF
95
+
96
+ def get_provisioning_uri(
97
+ self, account_name: str, counter: int, issuer: str | None
98
+ ) -> str:
99
+ return _generate_uri(
100
+ self, "hotp", account_name, issuer, [("counter", int(counter))]
101
+ )
@@ -0,0 +1,56 @@
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 typing
8
+
9
+ from cryptography.hazmat.primitives import constant_time
10
+ from cryptography.hazmat.primitives.twofactor import InvalidToken
11
+ from cryptography.hazmat.primitives.twofactor.hotp import (
12
+ HOTP,
13
+ HOTPHashTypes,
14
+ _generate_uri,
15
+ )
16
+ from cryptography.utils import Buffer
17
+
18
+
19
+ class TOTP:
20
+ def __init__(
21
+ self,
22
+ key: Buffer,
23
+ length: int,
24
+ algorithm: HOTPHashTypes,
25
+ time_step: int,
26
+ backend: typing.Any = None,
27
+ enforce_key_length: bool = True,
28
+ ):
29
+ self._time_step = time_step
30
+ self._hotp = HOTP(
31
+ key, length, algorithm, enforce_key_length=enforce_key_length
32
+ )
33
+
34
+ def generate(self, time: int | float) -> bytes:
35
+ if not isinstance(time, (int, float)):
36
+ raise TypeError(
37
+ "Time parameter must be an integer type or float type."
38
+ )
39
+
40
+ counter = int(time / self._time_step)
41
+ return self._hotp.generate(counter)
42
+
43
+ def verify(self, totp: bytes, time: int) -> None:
44
+ if not constant_time.bytes_eq(self.generate(time), totp):
45
+ raise InvalidToken("Supplied TOTP value does not match.")
46
+
47
+ def get_provisioning_uri(
48
+ self, account_name: str, issuer: str | None
49
+ ) -> str:
50
+ return _generate_uri(
51
+ self._hotp,
52
+ "totp",
53
+ account_name,
54
+ issuer,
55
+ [("period", int(self._time_step))],
56
+ )
@@ -0,0 +1,139 @@
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 enum
8
+ import sys
9
+ import types
10
+ import typing
11
+ import warnings
12
+ from collections.abc import Callable, Sequence
13
+
14
+
15
+ # We use a UserWarning subclass, instead of DeprecationWarning, because CPython
16
+ # decided deprecation warnings should be invisible by default.
17
+ class CryptographyDeprecationWarning(UserWarning):
18
+ pass
19
+
20
+
21
+ # Several APIs were deprecated with no specific end-of-life date because of the
22
+ # ubiquity of their use. They should not be removed until we agree on when that
23
+ # cycle ends.
24
+ DeprecatedIn36 = CryptographyDeprecationWarning
25
+ DeprecatedIn37 = CryptographyDeprecationWarning
26
+ DeprecatedIn40 = CryptographyDeprecationWarning
27
+ DeprecatedIn41 = CryptographyDeprecationWarning
28
+ DeprecatedIn42 = CryptographyDeprecationWarning
29
+ DeprecatedIn43 = CryptographyDeprecationWarning
30
+ DeprecatedIn45 = CryptographyDeprecationWarning
31
+
32
+
33
+ # If you're wondering why we don't use `Buffer`, it's because `Buffer` would
34
+ # be more accurately named: Bufferable. It means something which has an
35
+ # `__buffer__`. Which means you can't actually treat the result as a buffer
36
+ # (and do things like take a `len()`).
37
+ if sys.version_info >= (3, 9):
38
+ Buffer = typing.Union[bytes, bytearray, memoryview]
39
+ else:
40
+ Buffer = typing.ByteString
41
+
42
+
43
+ def _check_bytes(name: str, value: bytes) -> None:
44
+ if not isinstance(value, bytes):
45
+ raise TypeError(f"{name} must be bytes")
46
+
47
+
48
+ def _check_byteslike(name: str, value: Buffer) -> None:
49
+ try:
50
+ memoryview(value)
51
+ except TypeError:
52
+ raise TypeError(f"{name} must be bytes-like")
53
+
54
+
55
+ def int_to_bytes(integer: int, length: int | None = None) -> bytes:
56
+ if length == 0:
57
+ raise ValueError("length argument can't be 0")
58
+ return integer.to_bytes(
59
+ length or (integer.bit_length() + 7) // 8 or 1, "big"
60
+ )
61
+
62
+
63
+ class InterfaceNotImplemented(Exception):
64
+ pass
65
+
66
+
67
+ class _DeprecatedValue:
68
+ def __init__(self, value: object, message: str, warning_class):
69
+ self.value = value
70
+ self.message = message
71
+ self.warning_class = warning_class
72
+
73
+
74
+ class _ModuleWithDeprecations(types.ModuleType):
75
+ def __init__(self, module: types.ModuleType):
76
+ super().__init__(module.__name__)
77
+ self.__dict__["_module"] = module
78
+
79
+ def __getattr__(self, attr: str) -> object:
80
+ obj = getattr(self._module, attr)
81
+ if isinstance(obj, _DeprecatedValue):
82
+ warnings.warn(obj.message, obj.warning_class, stacklevel=2)
83
+ obj = obj.value
84
+ return obj
85
+
86
+ def __setattr__(self, attr: str, value: object) -> None:
87
+ setattr(self._module, attr, value)
88
+
89
+ def __delattr__(self, attr: str) -> None:
90
+ obj = getattr(self._module, attr)
91
+ if isinstance(obj, _DeprecatedValue):
92
+ warnings.warn(obj.message, obj.warning_class, stacklevel=2)
93
+
94
+ delattr(self._module, attr)
95
+
96
+ def __dir__(self) -> Sequence[str]:
97
+ return ["_module", *dir(self._module)]
98
+
99
+
100
+ def deprecated(
101
+ value: object,
102
+ module_name: str,
103
+ message: str,
104
+ warning_class: type[Warning],
105
+ name: str | None = None,
106
+ ) -> _DeprecatedValue:
107
+ module = sys.modules[module_name]
108
+ if not isinstance(module, _ModuleWithDeprecations):
109
+ sys.modules[module_name] = module = _ModuleWithDeprecations(module)
110
+ dv = _DeprecatedValue(value, message, warning_class)
111
+ # Maintain backwards compatibility with `name is None` for pyOpenSSL.
112
+ if name is not None:
113
+ setattr(module, name, dv)
114
+ return dv
115
+
116
+
117
+ def cached_property(func: Callable) -> property:
118
+ cached_name = f"_cached_{func}"
119
+ sentinel = object()
120
+
121
+ def inner(instance: object):
122
+ cache = getattr(instance, cached_name, sentinel)
123
+ if cache is not sentinel:
124
+ return cache
125
+ result = func(instance)
126
+ setattr(instance, cached_name, result)
127
+ return result
128
+
129
+ return property(inner)
130
+
131
+
132
+ # Python 3.10 changed representation of enums. We use well-defined object
133
+ # representation and string representation from Python 3.9.
134
+ class Enum(enum.Enum):
135
+ def __repr__(self) -> str:
136
+ return f"<{self.__class__.__name__}.{self._name_}: {self._value_!r}>"
137
+
138
+ def __str__(self) -> str:
139
+ return f"{self.__class__.__name__}.{self._name_}"
@@ -0,0 +1,270 @@
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.x509 import certificate_transparency, verification
8
+ from cryptography.x509.base import (
9
+ Attribute,
10
+ AttributeNotFound,
11
+ Attributes,
12
+ Certificate,
13
+ CertificateBuilder,
14
+ CertificateRevocationList,
15
+ CertificateRevocationListBuilder,
16
+ CertificateSigningRequest,
17
+ CertificateSigningRequestBuilder,
18
+ InvalidVersion,
19
+ RevokedCertificate,
20
+ RevokedCertificateBuilder,
21
+ Version,
22
+ load_der_x509_certificate,
23
+ load_der_x509_crl,
24
+ load_der_x509_csr,
25
+ load_pem_x509_certificate,
26
+ load_pem_x509_certificates,
27
+ load_pem_x509_crl,
28
+ load_pem_x509_csr,
29
+ random_serial_number,
30
+ )
31
+ from cryptography.x509.extensions import (
32
+ AccessDescription,
33
+ Admission,
34
+ Admissions,
35
+ AuthorityInformationAccess,
36
+ AuthorityKeyIdentifier,
37
+ BasicConstraints,
38
+ CertificateIssuer,
39
+ CertificatePolicies,
40
+ CRLDistributionPoints,
41
+ CRLNumber,
42
+ CRLReason,
43
+ DeltaCRLIndicator,
44
+ DistributionPoint,
45
+ DuplicateExtension,
46
+ ExtendedKeyUsage,
47
+ Extension,
48
+ ExtensionNotFound,
49
+ Extensions,
50
+ ExtensionType,
51
+ FreshestCRL,
52
+ GeneralNames,
53
+ InhibitAnyPolicy,
54
+ InvalidityDate,
55
+ IssuerAlternativeName,
56
+ IssuingDistributionPoint,
57
+ KeyUsage,
58
+ MSCertificateTemplate,
59
+ NameConstraints,
60
+ NamingAuthority,
61
+ NoticeReference,
62
+ OCSPAcceptableResponses,
63
+ OCSPNoCheck,
64
+ OCSPNonce,
65
+ PolicyConstraints,
66
+ PolicyInformation,
67
+ PrecertificateSignedCertificateTimestamps,
68
+ PrecertPoison,
69
+ PrivateKeyUsagePeriod,
70
+ ProfessionInfo,
71
+ ReasonFlags,
72
+ SignedCertificateTimestamps,
73
+ SubjectAlternativeName,
74
+ SubjectInformationAccess,
75
+ SubjectKeyIdentifier,
76
+ TLSFeature,
77
+ TLSFeatureType,
78
+ UnrecognizedExtension,
79
+ UserNotice,
80
+ )
81
+ from cryptography.x509.general_name import (
82
+ DirectoryName,
83
+ DNSName,
84
+ GeneralName,
85
+ IPAddress,
86
+ OtherName,
87
+ RegisteredID,
88
+ RFC822Name,
89
+ UniformResourceIdentifier,
90
+ UnsupportedGeneralNameType,
91
+ )
92
+ from cryptography.x509.name import (
93
+ Name,
94
+ NameAttribute,
95
+ RelativeDistinguishedName,
96
+ )
97
+ from cryptography.x509.oid import (
98
+ AuthorityInformationAccessOID,
99
+ CertificatePoliciesOID,
100
+ CRLEntryExtensionOID,
101
+ ExtendedKeyUsageOID,
102
+ ExtensionOID,
103
+ NameOID,
104
+ ObjectIdentifier,
105
+ PublicKeyAlgorithmOID,
106
+ SignatureAlgorithmOID,
107
+ )
108
+
109
+ OID_AUTHORITY_INFORMATION_ACCESS = ExtensionOID.AUTHORITY_INFORMATION_ACCESS
110
+ OID_AUTHORITY_KEY_IDENTIFIER = ExtensionOID.AUTHORITY_KEY_IDENTIFIER
111
+ OID_BASIC_CONSTRAINTS = ExtensionOID.BASIC_CONSTRAINTS
112
+ OID_CERTIFICATE_POLICIES = ExtensionOID.CERTIFICATE_POLICIES
113
+ OID_CRL_DISTRIBUTION_POINTS = ExtensionOID.CRL_DISTRIBUTION_POINTS
114
+ OID_EXTENDED_KEY_USAGE = ExtensionOID.EXTENDED_KEY_USAGE
115
+ OID_FRESHEST_CRL = ExtensionOID.FRESHEST_CRL
116
+ OID_INHIBIT_ANY_POLICY = ExtensionOID.INHIBIT_ANY_POLICY
117
+ OID_ISSUER_ALTERNATIVE_NAME = ExtensionOID.ISSUER_ALTERNATIVE_NAME
118
+ OID_KEY_USAGE = ExtensionOID.KEY_USAGE
119
+ OID_PRIVATE_KEY_USAGE_PERIOD = ExtensionOID.PRIVATE_KEY_USAGE_PERIOD
120
+ OID_NAME_CONSTRAINTS = ExtensionOID.NAME_CONSTRAINTS
121
+ OID_OCSP_NO_CHECK = ExtensionOID.OCSP_NO_CHECK
122
+ OID_POLICY_CONSTRAINTS = ExtensionOID.POLICY_CONSTRAINTS
123
+ OID_POLICY_MAPPINGS = ExtensionOID.POLICY_MAPPINGS
124
+ OID_SUBJECT_ALTERNATIVE_NAME = ExtensionOID.SUBJECT_ALTERNATIVE_NAME
125
+ OID_SUBJECT_DIRECTORY_ATTRIBUTES = ExtensionOID.SUBJECT_DIRECTORY_ATTRIBUTES
126
+ OID_SUBJECT_INFORMATION_ACCESS = ExtensionOID.SUBJECT_INFORMATION_ACCESS
127
+ OID_SUBJECT_KEY_IDENTIFIER = ExtensionOID.SUBJECT_KEY_IDENTIFIER
128
+
129
+ OID_DSA_WITH_SHA1 = SignatureAlgorithmOID.DSA_WITH_SHA1
130
+ OID_DSA_WITH_SHA224 = SignatureAlgorithmOID.DSA_WITH_SHA224
131
+ OID_DSA_WITH_SHA256 = SignatureAlgorithmOID.DSA_WITH_SHA256
132
+ OID_ECDSA_WITH_SHA1 = SignatureAlgorithmOID.ECDSA_WITH_SHA1
133
+ OID_ECDSA_WITH_SHA224 = SignatureAlgorithmOID.ECDSA_WITH_SHA224
134
+ OID_ECDSA_WITH_SHA256 = SignatureAlgorithmOID.ECDSA_WITH_SHA256
135
+ OID_ECDSA_WITH_SHA384 = SignatureAlgorithmOID.ECDSA_WITH_SHA384
136
+ OID_ECDSA_WITH_SHA512 = SignatureAlgorithmOID.ECDSA_WITH_SHA512
137
+ OID_RSA_WITH_MD5 = SignatureAlgorithmOID.RSA_WITH_MD5
138
+ OID_RSA_WITH_SHA1 = SignatureAlgorithmOID.RSA_WITH_SHA1
139
+ OID_RSA_WITH_SHA224 = SignatureAlgorithmOID.RSA_WITH_SHA224
140
+ OID_RSA_WITH_SHA256 = SignatureAlgorithmOID.RSA_WITH_SHA256
141
+ OID_RSA_WITH_SHA384 = SignatureAlgorithmOID.RSA_WITH_SHA384
142
+ OID_RSA_WITH_SHA512 = SignatureAlgorithmOID.RSA_WITH_SHA512
143
+ OID_RSASSA_PSS = SignatureAlgorithmOID.RSASSA_PSS
144
+
145
+ OID_COMMON_NAME = NameOID.COMMON_NAME
146
+ OID_COUNTRY_NAME = NameOID.COUNTRY_NAME
147
+ OID_DOMAIN_COMPONENT = NameOID.DOMAIN_COMPONENT
148
+ OID_DN_QUALIFIER = NameOID.DN_QUALIFIER
149
+ OID_EMAIL_ADDRESS = NameOID.EMAIL_ADDRESS
150
+ OID_GENERATION_QUALIFIER = NameOID.GENERATION_QUALIFIER
151
+ OID_GIVEN_NAME = NameOID.GIVEN_NAME
152
+ OID_LOCALITY_NAME = NameOID.LOCALITY_NAME
153
+ OID_ORGANIZATIONAL_UNIT_NAME = NameOID.ORGANIZATIONAL_UNIT_NAME
154
+ OID_ORGANIZATION_NAME = NameOID.ORGANIZATION_NAME
155
+ OID_PSEUDONYM = NameOID.PSEUDONYM
156
+ OID_SERIAL_NUMBER = NameOID.SERIAL_NUMBER
157
+ OID_STATE_OR_PROVINCE_NAME = NameOID.STATE_OR_PROVINCE_NAME
158
+ OID_SURNAME = NameOID.SURNAME
159
+ OID_TITLE = NameOID.TITLE
160
+
161
+ OID_CLIENT_AUTH = ExtendedKeyUsageOID.CLIENT_AUTH
162
+ OID_CODE_SIGNING = ExtendedKeyUsageOID.CODE_SIGNING
163
+ OID_EMAIL_PROTECTION = ExtendedKeyUsageOID.EMAIL_PROTECTION
164
+ OID_OCSP_SIGNING = ExtendedKeyUsageOID.OCSP_SIGNING
165
+ OID_SERVER_AUTH = ExtendedKeyUsageOID.SERVER_AUTH
166
+ OID_TIME_STAMPING = ExtendedKeyUsageOID.TIME_STAMPING
167
+
168
+ OID_ANY_POLICY = CertificatePoliciesOID.ANY_POLICY
169
+ OID_CPS_QUALIFIER = CertificatePoliciesOID.CPS_QUALIFIER
170
+ OID_CPS_USER_NOTICE = CertificatePoliciesOID.CPS_USER_NOTICE
171
+
172
+ OID_CERTIFICATE_ISSUER = CRLEntryExtensionOID.CERTIFICATE_ISSUER
173
+ OID_CRL_REASON = CRLEntryExtensionOID.CRL_REASON
174
+ OID_INVALIDITY_DATE = CRLEntryExtensionOID.INVALIDITY_DATE
175
+
176
+ OID_CA_ISSUERS = AuthorityInformationAccessOID.CA_ISSUERS
177
+ OID_OCSP = AuthorityInformationAccessOID.OCSP
178
+
179
+ __all__ = [
180
+ "OID_CA_ISSUERS",
181
+ "OID_OCSP",
182
+ "AccessDescription",
183
+ "Admission",
184
+ "Admissions",
185
+ "Attribute",
186
+ "AttributeNotFound",
187
+ "Attributes",
188
+ "AuthorityInformationAccess",
189
+ "AuthorityKeyIdentifier",
190
+ "BasicConstraints",
191
+ "CRLDistributionPoints",
192
+ "CRLNumber",
193
+ "CRLReason",
194
+ "Certificate",
195
+ "CertificateBuilder",
196
+ "CertificateIssuer",
197
+ "CertificatePolicies",
198
+ "CertificateRevocationList",
199
+ "CertificateRevocationListBuilder",
200
+ "CertificateSigningRequest",
201
+ "CertificateSigningRequestBuilder",
202
+ "DNSName",
203
+ "DeltaCRLIndicator",
204
+ "DirectoryName",
205
+ "DistributionPoint",
206
+ "DuplicateExtension",
207
+ "ExtendedKeyUsage",
208
+ "Extension",
209
+ "ExtensionNotFound",
210
+ "ExtensionType",
211
+ "Extensions",
212
+ "FreshestCRL",
213
+ "GeneralName",
214
+ "GeneralNames",
215
+ "IPAddress",
216
+ "InhibitAnyPolicy",
217
+ "InvalidVersion",
218
+ "InvalidityDate",
219
+ "IssuerAlternativeName",
220
+ "IssuingDistributionPoint",
221
+ "KeyUsage",
222
+ "MSCertificateTemplate",
223
+ "Name",
224
+ "NameAttribute",
225
+ "NameConstraints",
226
+ "NameOID",
227
+ "NamingAuthority",
228
+ "NoticeReference",
229
+ "OCSPAcceptableResponses",
230
+ "OCSPNoCheck",
231
+ "OCSPNonce",
232
+ "ObjectIdentifier",
233
+ "OtherName",
234
+ "PolicyConstraints",
235
+ "PolicyInformation",
236
+ "PrecertPoison",
237
+ "PrecertificateSignedCertificateTimestamps",
238
+ "PrivateKeyUsagePeriod",
239
+ "ProfessionInfo",
240
+ "PublicKeyAlgorithmOID",
241
+ "RFC822Name",
242
+ "ReasonFlags",
243
+ "RegisteredID",
244
+ "RelativeDistinguishedName",
245
+ "RevokedCertificate",
246
+ "RevokedCertificateBuilder",
247
+ "SignatureAlgorithmOID",
248
+ "SignedCertificateTimestamps",
249
+ "SubjectAlternativeName",
250
+ "SubjectInformationAccess",
251
+ "SubjectKeyIdentifier",
252
+ "TLSFeature",
253
+ "TLSFeatureType",
254
+ "UniformResourceIdentifier",
255
+ "UnrecognizedExtension",
256
+ "UnsupportedGeneralNameType",
257
+ "UserNotice",
258
+ "Version",
259
+ "certificate_transparency",
260
+ "load_der_x509_certificate",
261
+ "load_der_x509_crl",
262
+ "load_der_x509_csr",
263
+ "load_pem_x509_certificate",
264
+ "load_pem_x509_certificates",
265
+ "load_pem_x509_crl",
266
+ "load_pem_x509_csr",
267
+ "random_serial_number",
268
+ "verification",
269
+ "verification",
270
+ ]