@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,125 @@
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.exceptions import UnsupportedAlgorithm, _Reasons
10
+ from cryptography.hazmat.bindings._rust import openssl as rust_openssl
11
+ from cryptography.hazmat.primitives import _serialization
12
+ from cryptography.utils import Buffer
13
+
14
+
15
+ class X448PublicKey(metaclass=abc.ABCMeta):
16
+ @classmethod
17
+ def from_public_bytes(cls, data: bytes) -> X448PublicKey:
18
+ from cryptography.hazmat.backends.openssl.backend import backend
19
+
20
+ if not backend.x448_supported():
21
+ raise UnsupportedAlgorithm(
22
+ "X448 is not supported by this version of OpenSSL.",
23
+ _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
24
+ )
25
+
26
+ return rust_openssl.x448.from_public_bytes(data)
27
+
28
+ @abc.abstractmethod
29
+ def public_bytes(
30
+ self,
31
+ encoding: _serialization.Encoding,
32
+ format: _serialization.PublicFormat,
33
+ ) -> bytes:
34
+ """
35
+ The serialized bytes of the public key.
36
+ """
37
+
38
+ @abc.abstractmethod
39
+ def public_bytes_raw(self) -> bytes:
40
+ """
41
+ The raw bytes of the public key.
42
+ Equivalent to public_bytes(Raw, Raw).
43
+ """
44
+
45
+ @abc.abstractmethod
46
+ def __eq__(self, other: object) -> bool:
47
+ """
48
+ Checks equality.
49
+ """
50
+
51
+ @abc.abstractmethod
52
+ def __copy__(self) -> X448PublicKey:
53
+ """
54
+ Returns a copy.
55
+ """
56
+
57
+
58
+ if hasattr(rust_openssl, "x448"):
59
+ X448PublicKey.register(rust_openssl.x448.X448PublicKey)
60
+
61
+
62
+ class X448PrivateKey(metaclass=abc.ABCMeta):
63
+ @classmethod
64
+ def generate(cls) -> X448PrivateKey:
65
+ from cryptography.hazmat.backends.openssl.backend import backend
66
+
67
+ if not backend.x448_supported():
68
+ raise UnsupportedAlgorithm(
69
+ "X448 is not supported by this version of OpenSSL.",
70
+ _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
71
+ )
72
+
73
+ return rust_openssl.x448.generate_key()
74
+
75
+ @classmethod
76
+ def from_private_bytes(cls, data: Buffer) -> X448PrivateKey:
77
+ from cryptography.hazmat.backends.openssl.backend import backend
78
+
79
+ if not backend.x448_supported():
80
+ raise UnsupportedAlgorithm(
81
+ "X448 is not supported by this version of OpenSSL.",
82
+ _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
83
+ )
84
+
85
+ return rust_openssl.x448.from_private_bytes(data)
86
+
87
+ @abc.abstractmethod
88
+ def public_key(self) -> X448PublicKey:
89
+ """
90
+ Returns the public key associated with this private key
91
+ """
92
+
93
+ @abc.abstractmethod
94
+ def private_bytes(
95
+ self,
96
+ encoding: _serialization.Encoding,
97
+ format: _serialization.PrivateFormat,
98
+ encryption_algorithm: _serialization.KeySerializationEncryption,
99
+ ) -> bytes:
100
+ """
101
+ The serialized bytes of the private key.
102
+ """
103
+
104
+ @abc.abstractmethod
105
+ def private_bytes_raw(self) -> bytes:
106
+ """
107
+ The raw bytes of the private key.
108
+ Equivalent to private_bytes(Raw, Raw, NoEncryption()).
109
+ """
110
+
111
+ @abc.abstractmethod
112
+ def exchange(self, peer_public_key: X448PublicKey) -> bytes:
113
+ """
114
+ Performs a key exchange operation using the provided peer's public key.
115
+ """
116
+
117
+ @abc.abstractmethod
118
+ def __copy__(self) -> X448PrivateKey:
119
+ """
120
+ Returns a copy.
121
+ """
122
+
123
+
124
+ if hasattr(rust_openssl, "x448"):
125
+ X448PrivateKey.register(rust_openssl.x448.X448PrivateKey)
@@ -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
+ ]
@@ -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
@@ -0,0 +1,183 @@
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: utils.Buffer):
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: utils.Buffer):
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: utils.Buffer):
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: utils.Buffer):
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 "
86
+ "cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.",
87
+ utils.DeprecatedIn43,
88
+ name="ARC4",
89
+ )
90
+
91
+
92
+ utils.deprecated(
93
+ TripleDES,
94
+ __name__,
95
+ "TripleDES has been moved to "
96
+ "cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and "
97
+ "will be removed from "
98
+ "cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.",
99
+ utils.DeprecatedIn43,
100
+ name="TripleDES",
101
+ )
102
+
103
+ utils.deprecated(
104
+ Blowfish,
105
+ __name__,
106
+ "Blowfish has been moved to "
107
+ "cryptography.hazmat.decrepit.ciphers.algorithms.Blowfish and "
108
+ "will be removed from "
109
+ "cryptography.hazmat.primitives.ciphers.algorithms in 45.0.0.",
110
+ utils.DeprecatedIn37,
111
+ name="Blowfish",
112
+ )
113
+
114
+
115
+ utils.deprecated(
116
+ CAST5,
117
+ __name__,
118
+ "CAST5 has been moved to "
119
+ "cryptography.hazmat.decrepit.ciphers.algorithms.CAST5 and "
120
+ "will be removed from "
121
+ "cryptography.hazmat.primitives.ciphers.algorithms in 45.0.0.",
122
+ utils.DeprecatedIn37,
123
+ name="CAST5",
124
+ )
125
+
126
+
127
+ utils.deprecated(
128
+ IDEA,
129
+ __name__,
130
+ "IDEA has been moved to "
131
+ "cryptography.hazmat.decrepit.ciphers.algorithms.IDEA and "
132
+ "will be removed from "
133
+ "cryptography.hazmat.primitives.ciphers.algorithms in 45.0.0.",
134
+ utils.DeprecatedIn37,
135
+ name="IDEA",
136
+ )
137
+
138
+
139
+ utils.deprecated(
140
+ SEED,
141
+ __name__,
142
+ "SEED has been moved to "
143
+ "cryptography.hazmat.decrepit.ciphers.algorithms.SEED and "
144
+ "will be removed from "
145
+ "cryptography.hazmat.primitives.ciphers.algorithms in 45.0.0.",
146
+ utils.DeprecatedIn37,
147
+ name="SEED",
148
+ )
149
+
150
+
151
+ class ChaCha20(CipherAlgorithm):
152
+ name = "ChaCha20"
153
+ key_sizes = frozenset([256])
154
+
155
+ def __init__(self, key: utils.Buffer, nonce: utils.Buffer):
156
+ self.key = _verify_key_size(self, key)
157
+ utils._check_byteslike("nonce", nonce)
158
+
159
+ if len(nonce) != 16:
160
+ raise ValueError("nonce must be 128-bits (16 bytes)")
161
+
162
+ self._nonce = nonce
163
+
164
+ @property
165
+ def nonce(self) -> utils.Buffer:
166
+ return self._nonce
167
+
168
+ @property
169
+ def key_size(self) -> int:
170
+ return len(self.key) * 8
171
+
172
+
173
+ class SM4(BlockCipherAlgorithm):
174
+ name = "SM4"
175
+ block_size = 128
176
+ key_sizes = frozenset([128])
177
+
178
+ def __init__(self, key: bytes):
179
+ self.key = _verify_key_size(self, key)
180
+
181
+ @property
182
+ def key_size(self) -> int:
183
+ return len(self.key) * 8
@@ -0,0 +1,146 @@
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
+ from cryptography.utils import Buffer
14
+
15
+
16
+ class CipherContext(metaclass=abc.ABCMeta):
17
+ @abc.abstractmethod
18
+ def update(self, data: Buffer) -> bytes:
19
+ """
20
+ Processes the provided bytes through the cipher and returns the results
21
+ as bytes.
22
+ """
23
+
24
+ @abc.abstractmethod
25
+ def update_into(self, data: Buffer, buf: Buffer) -> int:
26
+ """
27
+ Processes the provided bytes and writes the resulting data into the
28
+ provided buffer. Returns the number of bytes written.
29
+ """
30
+
31
+ @abc.abstractmethod
32
+ def finalize(self) -> bytes:
33
+ """
34
+ Returns the results of processing the final block as bytes.
35
+ """
36
+
37
+ @abc.abstractmethod
38
+ def reset_nonce(self, nonce: bytes) -> None:
39
+ """
40
+ Resets the nonce for the cipher context to the provided value.
41
+ Raises an exception if it does not support reset or if the
42
+ provided nonce does not have a valid length.
43
+ """
44
+
45
+
46
+ class AEADCipherContext(CipherContext, metaclass=abc.ABCMeta):
47
+ @abc.abstractmethod
48
+ def authenticate_additional_data(self, data: Buffer) -> None:
49
+ """
50
+ Authenticates the provided bytes.
51
+ """
52
+
53
+
54
+ class AEADDecryptionContext(AEADCipherContext, metaclass=abc.ABCMeta):
55
+ @abc.abstractmethod
56
+ def finalize_with_tag(self, tag: bytes) -> bytes:
57
+ """
58
+ Returns the results of processing the final block as bytes and allows
59
+ delayed passing of the authentication tag.
60
+ """
61
+
62
+
63
+ class AEADEncryptionContext(AEADCipherContext, metaclass=abc.ABCMeta):
64
+ @property
65
+ @abc.abstractmethod
66
+ def tag(self) -> bytes:
67
+ """
68
+ Returns tag bytes. This is only available after encryption is
69
+ finalized.
70
+ """
71
+
72
+
73
+ Mode = typing.TypeVar(
74
+ "Mode", bound=typing.Optional[modes.Mode], covariant=True
75
+ )
76
+
77
+
78
+ class Cipher(typing.Generic[Mode]):
79
+ def __init__(
80
+ self,
81
+ algorithm: CipherAlgorithm,
82
+ mode: Mode,
83
+ backend: typing.Any = None,
84
+ ) -> None:
85
+ if not isinstance(algorithm, CipherAlgorithm):
86
+ raise TypeError("Expected interface of CipherAlgorithm.")
87
+
88
+ if mode is not None:
89
+ # mypy needs this assert to narrow the type from our generic
90
+ # type. Maybe it won't some time in the future.
91
+ assert isinstance(mode, modes.Mode)
92
+ mode.validate_for_algorithm(algorithm)
93
+
94
+ self.algorithm = algorithm
95
+ self.mode = mode
96
+
97
+ @typing.overload
98
+ def encryptor(
99
+ self: Cipher[modes.ModeWithAuthenticationTag],
100
+ ) -> AEADEncryptionContext: ...
101
+
102
+ @typing.overload
103
+ def encryptor(
104
+ self: _CIPHER_TYPE,
105
+ ) -> CipherContext: ...
106
+
107
+ def encryptor(self):
108
+ if isinstance(self.mode, modes.ModeWithAuthenticationTag):
109
+ if self.mode.tag is not None:
110
+ raise ValueError(
111
+ "Authentication tag must be None when encrypting."
112
+ )
113
+
114
+ return rust_openssl.ciphers.create_encryption_ctx(
115
+ self.algorithm, self.mode
116
+ )
117
+
118
+ @typing.overload
119
+ def decryptor(
120
+ self: Cipher[modes.ModeWithAuthenticationTag],
121
+ ) -> AEADDecryptionContext: ...
122
+
123
+ @typing.overload
124
+ def decryptor(
125
+ self: _CIPHER_TYPE,
126
+ ) -> CipherContext: ...
127
+
128
+ def decryptor(self):
129
+ return rust_openssl.ciphers.create_decryption_ctx(
130
+ self.algorithm, self.mode
131
+ )
132
+
133
+
134
+ _CIPHER_TYPE = Cipher[
135
+ typing.Union[
136
+ modes.ModeWithNonce,
137
+ modes.ModeWithTweak,
138
+ modes.ECB,
139
+ modes.ModeWithInitializationVector,
140
+ None,
141
+ ]
142
+ ]
143
+
144
+ CipherContext.register(rust_openssl.ciphers.CipherContext)
145
+ AEADEncryptionContext.register(rust_openssl.ciphers.AEADEncryptionContext)
146
+ AEADDecryptionContext.register(rust_openssl.ciphers.AEADDecryptionContext)