@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,112 @@
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
+ # Not actually supported, marker for tests
44
+ class _DES:
45
+ key_size = 64
46
+
47
+
48
+ class Blowfish(BlockCipherAlgorithm):
49
+ name = "Blowfish"
50
+ block_size = 64
51
+ key_sizes = frozenset(range(32, 449, 8))
52
+
53
+ def __init__(self, key: bytes):
54
+ self.key = _verify_key_size(self, key)
55
+
56
+ @property
57
+ def key_size(self) -> int:
58
+ return len(self.key) * 8
59
+
60
+
61
+ class CAST5(BlockCipherAlgorithm):
62
+ name = "CAST5"
63
+ block_size = 64
64
+ key_sizes = frozenset(range(40, 129, 8))
65
+
66
+ def __init__(self, key: bytes):
67
+ self.key = _verify_key_size(self, key)
68
+
69
+ @property
70
+ def key_size(self) -> int:
71
+ return len(self.key) * 8
72
+
73
+
74
+ class SEED(BlockCipherAlgorithm):
75
+ name = "SEED"
76
+ block_size = 128
77
+ key_sizes = frozenset([128])
78
+
79
+ def __init__(self, key: bytes):
80
+ self.key = _verify_key_size(self, key)
81
+
82
+ @property
83
+ def key_size(self) -> int:
84
+ return len(self.key) * 8
85
+
86
+
87
+ class IDEA(BlockCipherAlgorithm):
88
+ name = "IDEA"
89
+ block_size = 64
90
+ key_sizes = frozenset([128])
91
+
92
+ def __init__(self, key: bytes):
93
+ self.key = _verify_key_size(self, key)
94
+
95
+ @property
96
+ def key_size(self) -> int:
97
+ return len(self.key) * 8
98
+
99
+
100
+ # This class only allows RC2 with a 128-bit key. No support for
101
+ # effective key bits or other key sizes is provided.
102
+ class RC2(BlockCipherAlgorithm):
103
+ name = "RC2"
104
+ block_size = 64
105
+ key_sizes = frozenset([128])
106
+
107
+ def __init__(self, key: bytes):
108
+ self.key = _verify_key_size(self, key)
109
+
110
+ @property
111
+ def key_size(self) -> int:
112
+ return len(self.key) * 8
@@ -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.
@@ -0,0 +1,19 @@
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
+ # This exists to break an import cycle. It is normally accessible from the
10
+ # asymmetric padding module.
11
+
12
+
13
+ class AsymmetricPadding(metaclass=abc.ABCMeta):
14
+ @property
15
+ @abc.abstractmethod
16
+ def name(self) -> str:
17
+ """
18
+ A string naming this padding (e.g. "PSS", "PKCS1").
19
+ """
@@ -0,0 +1,60 @@
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
+
11
+ # This exists to break an import cycle. It is normally accessible from the
12
+ # ciphers module.
13
+
14
+
15
+ class CipherAlgorithm(metaclass=abc.ABCMeta):
16
+ @property
17
+ @abc.abstractmethod
18
+ def name(self) -> str:
19
+ """
20
+ A string naming this mode (e.g. "AES", "Camellia").
21
+ """
22
+
23
+ @property
24
+ @abc.abstractmethod
25
+ def key_sizes(self) -> frozenset[int]:
26
+ """
27
+ Valid key sizes for this algorithm in bits
28
+ """
29
+
30
+ @property
31
+ @abc.abstractmethod
32
+ def key_size(self) -> int:
33
+ """
34
+ The size of the key being used as an integer in bits (e.g. 128, 256).
35
+ """
36
+
37
+
38
+ class BlockCipherAlgorithm(CipherAlgorithm):
39
+ key: utils.Buffer
40
+
41
+ @property
42
+ @abc.abstractmethod
43
+ def block_size(self) -> int:
44
+ """
45
+ The size of a block as an integer in bits (e.g. 64, 128).
46
+ """
47
+
48
+
49
+ def _verify_key_size(
50
+ algorithm: CipherAlgorithm, key: utils.Buffer
51
+ ) -> utils.Buffer:
52
+ # Verify that the key is instance of bytes
53
+ utils._check_byteslike("key", key)
54
+
55
+ # Verify that the key size matches the expected key size
56
+ if len(key) * 8 not in algorithm.key_sizes:
57
+ raise ValueError(
58
+ f"Invalid key size ({len(key) * 8}) for {algorithm.name}."
59
+ )
60
+ return key
@@ -0,0 +1,168 @@
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.hazmat.primitives.hashes import HashAlgorithm
11
+
12
+ # This exists to break an import cycle. These classes are normally accessible
13
+ # from the serialization module.
14
+
15
+
16
+ class PBES(utils.Enum):
17
+ PBESv1SHA1And3KeyTripleDESCBC = "PBESv1 using SHA1 and 3-Key TripleDES"
18
+ PBESv2SHA256AndAES256CBC = "PBESv2 using SHA256 PBKDF2 and AES256 CBC"
19
+
20
+
21
+ class Encoding(utils.Enum):
22
+ PEM = "PEM"
23
+ DER = "DER"
24
+ OpenSSH = "OpenSSH"
25
+ Raw = "Raw"
26
+ X962 = "ANSI X9.62"
27
+ SMIME = "S/MIME"
28
+
29
+
30
+ class PrivateFormat(utils.Enum):
31
+ PKCS8 = "PKCS8"
32
+ TraditionalOpenSSL = "TraditionalOpenSSL"
33
+ Raw = "Raw"
34
+ OpenSSH = "OpenSSH"
35
+ PKCS12 = "PKCS12"
36
+
37
+ def encryption_builder(self) -> KeySerializationEncryptionBuilder:
38
+ if self not in (PrivateFormat.OpenSSH, PrivateFormat.PKCS12):
39
+ raise ValueError(
40
+ "encryption_builder only supported with PrivateFormat.OpenSSH"
41
+ " and PrivateFormat.PKCS12"
42
+ )
43
+ return KeySerializationEncryptionBuilder(self)
44
+
45
+
46
+ class PublicFormat(utils.Enum):
47
+ SubjectPublicKeyInfo = "X.509 subjectPublicKeyInfo with PKCS#1"
48
+ PKCS1 = "Raw PKCS#1"
49
+ OpenSSH = "OpenSSH"
50
+ Raw = "Raw"
51
+ CompressedPoint = "X9.62 Compressed Point"
52
+ UncompressedPoint = "X9.62 Uncompressed Point"
53
+
54
+
55
+ class ParameterFormat(utils.Enum):
56
+ PKCS3 = "PKCS3"
57
+
58
+
59
+ class KeySerializationEncryption(metaclass=abc.ABCMeta):
60
+ pass
61
+
62
+
63
+ class BestAvailableEncryption(KeySerializationEncryption):
64
+ def __init__(self, password: bytes):
65
+ if not isinstance(password, bytes) or len(password) == 0:
66
+ raise ValueError("Password must be 1 or more bytes.")
67
+
68
+ self.password = password
69
+
70
+
71
+ class NoEncryption(KeySerializationEncryption):
72
+ pass
73
+
74
+
75
+ class KeySerializationEncryptionBuilder:
76
+ def __init__(
77
+ self,
78
+ format: PrivateFormat,
79
+ *,
80
+ _kdf_rounds: int | None = None,
81
+ _hmac_hash: HashAlgorithm | None = None,
82
+ _key_cert_algorithm: PBES | None = None,
83
+ ) -> None:
84
+ self._format = format
85
+
86
+ self._kdf_rounds = _kdf_rounds
87
+ self._hmac_hash = _hmac_hash
88
+ self._key_cert_algorithm = _key_cert_algorithm
89
+
90
+ def kdf_rounds(self, rounds: int) -> KeySerializationEncryptionBuilder:
91
+ if self._kdf_rounds is not None:
92
+ raise ValueError("kdf_rounds already set")
93
+
94
+ if not isinstance(rounds, int):
95
+ raise TypeError("kdf_rounds must be an integer")
96
+
97
+ if rounds < 1:
98
+ raise ValueError("kdf_rounds must be a positive integer")
99
+
100
+ return KeySerializationEncryptionBuilder(
101
+ self._format,
102
+ _kdf_rounds=rounds,
103
+ _hmac_hash=self._hmac_hash,
104
+ _key_cert_algorithm=self._key_cert_algorithm,
105
+ )
106
+
107
+ def hmac_hash(
108
+ self, algorithm: HashAlgorithm
109
+ ) -> KeySerializationEncryptionBuilder:
110
+ if self._format is not PrivateFormat.PKCS12:
111
+ raise TypeError(
112
+ "hmac_hash only supported with PrivateFormat.PKCS12"
113
+ )
114
+
115
+ if self._hmac_hash is not None:
116
+ raise ValueError("hmac_hash already set")
117
+ return KeySerializationEncryptionBuilder(
118
+ self._format,
119
+ _kdf_rounds=self._kdf_rounds,
120
+ _hmac_hash=algorithm,
121
+ _key_cert_algorithm=self._key_cert_algorithm,
122
+ )
123
+
124
+ def key_cert_algorithm(
125
+ self, algorithm: PBES
126
+ ) -> KeySerializationEncryptionBuilder:
127
+ if self._format is not PrivateFormat.PKCS12:
128
+ raise TypeError(
129
+ "key_cert_algorithm only supported with PrivateFormat.PKCS12"
130
+ )
131
+ if self._key_cert_algorithm is not None:
132
+ raise ValueError("key_cert_algorithm already set")
133
+ return KeySerializationEncryptionBuilder(
134
+ self._format,
135
+ _kdf_rounds=self._kdf_rounds,
136
+ _hmac_hash=self._hmac_hash,
137
+ _key_cert_algorithm=algorithm,
138
+ )
139
+
140
+ def build(self, password: bytes) -> KeySerializationEncryption:
141
+ if not isinstance(password, bytes) or len(password) == 0:
142
+ raise ValueError("Password must be 1 or more bytes.")
143
+
144
+ return _KeySerializationEncryption(
145
+ self._format,
146
+ password,
147
+ kdf_rounds=self._kdf_rounds,
148
+ hmac_hash=self._hmac_hash,
149
+ key_cert_algorithm=self._key_cert_algorithm,
150
+ )
151
+
152
+
153
+ class _KeySerializationEncryption(KeySerializationEncryption):
154
+ def __init__(
155
+ self,
156
+ format: PrivateFormat,
157
+ password: bytes,
158
+ *,
159
+ kdf_rounds: int | None,
160
+ hmac_hash: HashAlgorithm | None,
161
+ key_cert_algorithm: PBES | None,
162
+ ):
163
+ self._format = format
164
+ self.password = password
165
+
166
+ self._kdf_rounds = kdf_rounds
167
+ self._hmac_hash = hmac_hash
168
+ self._key_cert_algorithm = key_cert_algorithm
@@ -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.
@@ -0,0 +1,147 @@
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.hazmat.bindings._rust import openssl as rust_openssl
10
+ from cryptography.hazmat.primitives import _serialization
11
+
12
+ generate_parameters = rust_openssl.dh.generate_parameters
13
+
14
+
15
+ DHPrivateNumbers = rust_openssl.dh.DHPrivateNumbers
16
+ DHPublicNumbers = rust_openssl.dh.DHPublicNumbers
17
+ DHParameterNumbers = rust_openssl.dh.DHParameterNumbers
18
+
19
+
20
+ class DHParameters(metaclass=abc.ABCMeta):
21
+ @abc.abstractmethod
22
+ def generate_private_key(self) -> DHPrivateKey:
23
+ """
24
+ Generates and returns a DHPrivateKey.
25
+ """
26
+
27
+ @abc.abstractmethod
28
+ def parameter_bytes(
29
+ self,
30
+ encoding: _serialization.Encoding,
31
+ format: _serialization.ParameterFormat,
32
+ ) -> bytes:
33
+ """
34
+ Returns the parameters serialized as bytes.
35
+ """
36
+
37
+ @abc.abstractmethod
38
+ def parameter_numbers(self) -> DHParameterNumbers:
39
+ """
40
+ Returns a DHParameterNumbers.
41
+ """
42
+
43
+
44
+ DHParametersWithSerialization = DHParameters
45
+ DHParameters.register(rust_openssl.dh.DHParameters)
46
+
47
+
48
+ class DHPublicKey(metaclass=abc.ABCMeta):
49
+ @property
50
+ @abc.abstractmethod
51
+ def key_size(self) -> int:
52
+ """
53
+ The bit length of the prime modulus.
54
+ """
55
+
56
+ @abc.abstractmethod
57
+ def parameters(self) -> DHParameters:
58
+ """
59
+ The DHParameters object associated with this public key.
60
+ """
61
+
62
+ @abc.abstractmethod
63
+ def public_numbers(self) -> DHPublicNumbers:
64
+ """
65
+ Returns a DHPublicNumbers.
66
+ """
67
+
68
+ @abc.abstractmethod
69
+ def public_bytes(
70
+ self,
71
+ encoding: _serialization.Encoding,
72
+ format: _serialization.PublicFormat,
73
+ ) -> bytes:
74
+ """
75
+ Returns the key serialized as bytes.
76
+ """
77
+
78
+ @abc.abstractmethod
79
+ def __eq__(self, other: object) -> bool:
80
+ """
81
+ Checks equality.
82
+ """
83
+
84
+ @abc.abstractmethod
85
+ def __copy__(self) -> DHPublicKey:
86
+ """
87
+ Returns a copy.
88
+ """
89
+
90
+
91
+ DHPublicKeyWithSerialization = DHPublicKey
92
+ DHPublicKey.register(rust_openssl.dh.DHPublicKey)
93
+
94
+
95
+ class DHPrivateKey(metaclass=abc.ABCMeta):
96
+ @property
97
+ @abc.abstractmethod
98
+ def key_size(self) -> int:
99
+ """
100
+ The bit length of the prime modulus.
101
+ """
102
+
103
+ @abc.abstractmethod
104
+ def public_key(self) -> DHPublicKey:
105
+ """
106
+ The DHPublicKey associated with this private key.
107
+ """
108
+
109
+ @abc.abstractmethod
110
+ def parameters(self) -> DHParameters:
111
+ """
112
+ The DHParameters object associated with this private key.
113
+ """
114
+
115
+ @abc.abstractmethod
116
+ def exchange(self, peer_public_key: DHPublicKey) -> bytes:
117
+ """
118
+ Given peer's DHPublicKey, carry out the key exchange and
119
+ return shared key as bytes.
120
+ """
121
+
122
+ @abc.abstractmethod
123
+ def private_numbers(self) -> DHPrivateNumbers:
124
+ """
125
+ Returns a DHPrivateNumbers.
126
+ """
127
+
128
+ @abc.abstractmethod
129
+ def private_bytes(
130
+ self,
131
+ encoding: _serialization.Encoding,
132
+ format: _serialization.PrivateFormat,
133
+ encryption_algorithm: _serialization.KeySerializationEncryption,
134
+ ) -> bytes:
135
+ """
136
+ Returns the key serialized as bytes.
137
+ """
138
+
139
+ @abc.abstractmethod
140
+ def __copy__(self) -> DHPrivateKey:
141
+ """
142
+ Returns a copy.
143
+ """
144
+
145
+
146
+ DHPrivateKeyWithSerialization = DHPrivateKey
147
+ DHPrivateKey.register(rust_openssl.dh.DHPrivateKey)
@@ -0,0 +1,167 @@
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 import _serialization, hashes
12
+ from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
13
+ from cryptography.utils import Buffer
14
+
15
+
16
+ class DSAParameters(metaclass=abc.ABCMeta):
17
+ @abc.abstractmethod
18
+ def generate_private_key(self) -> DSAPrivateKey:
19
+ """
20
+ Generates and returns a DSAPrivateKey.
21
+ """
22
+
23
+ @abc.abstractmethod
24
+ def parameter_numbers(self) -> DSAParameterNumbers:
25
+ """
26
+ Returns a DSAParameterNumbers.
27
+ """
28
+
29
+
30
+ DSAParametersWithNumbers = DSAParameters
31
+ DSAParameters.register(rust_openssl.dsa.DSAParameters)
32
+
33
+
34
+ class DSAPrivateKey(metaclass=abc.ABCMeta):
35
+ @property
36
+ @abc.abstractmethod
37
+ def key_size(self) -> int:
38
+ """
39
+ The bit length of the prime modulus.
40
+ """
41
+
42
+ @abc.abstractmethod
43
+ def public_key(self) -> DSAPublicKey:
44
+ """
45
+ The DSAPublicKey associated with this private key.
46
+ """
47
+
48
+ @abc.abstractmethod
49
+ def parameters(self) -> DSAParameters:
50
+ """
51
+ The DSAParameters object associated with this private key.
52
+ """
53
+
54
+ @abc.abstractmethod
55
+ def sign(
56
+ self,
57
+ data: Buffer,
58
+ algorithm: asym_utils.Prehashed | hashes.HashAlgorithm,
59
+ ) -> bytes:
60
+ """
61
+ Signs the data
62
+ """
63
+
64
+ @abc.abstractmethod
65
+ def private_numbers(self) -> DSAPrivateNumbers:
66
+ """
67
+ Returns a DSAPrivateNumbers.
68
+ """
69
+
70
+ @abc.abstractmethod
71
+ def private_bytes(
72
+ self,
73
+ encoding: _serialization.Encoding,
74
+ format: _serialization.PrivateFormat,
75
+ encryption_algorithm: _serialization.KeySerializationEncryption,
76
+ ) -> bytes:
77
+ """
78
+ Returns the key serialized as bytes.
79
+ """
80
+
81
+ @abc.abstractmethod
82
+ def __copy__(self) -> DSAPrivateKey:
83
+ """
84
+ Returns a copy.
85
+ """
86
+
87
+
88
+ DSAPrivateKeyWithSerialization = DSAPrivateKey
89
+ DSAPrivateKey.register(rust_openssl.dsa.DSAPrivateKey)
90
+
91
+
92
+ class DSAPublicKey(metaclass=abc.ABCMeta):
93
+ @property
94
+ @abc.abstractmethod
95
+ def key_size(self) -> int:
96
+ """
97
+ The bit length of the prime modulus.
98
+ """
99
+
100
+ @abc.abstractmethod
101
+ def parameters(self) -> DSAParameters:
102
+ """
103
+ The DSAParameters object associated with this public key.
104
+ """
105
+
106
+ @abc.abstractmethod
107
+ def public_numbers(self) -> DSAPublicNumbers:
108
+ """
109
+ Returns a DSAPublicNumbers.
110
+ """
111
+
112
+ @abc.abstractmethod
113
+ def public_bytes(
114
+ self,
115
+ encoding: _serialization.Encoding,
116
+ format: _serialization.PublicFormat,
117
+ ) -> bytes:
118
+ """
119
+ Returns the key serialized as bytes.
120
+ """
121
+
122
+ @abc.abstractmethod
123
+ def verify(
124
+ self,
125
+ signature: Buffer,
126
+ data: Buffer,
127
+ algorithm: asym_utils.Prehashed | hashes.HashAlgorithm,
128
+ ) -> None:
129
+ """
130
+ Verifies the signature of the data.
131
+ """
132
+
133
+ @abc.abstractmethod
134
+ def __eq__(self, other: object) -> bool:
135
+ """
136
+ Checks equality.
137
+ """
138
+
139
+ @abc.abstractmethod
140
+ def __copy__(self) -> DSAPublicKey:
141
+ """
142
+ Returns a copy.
143
+ """
144
+
145
+
146
+ DSAPublicKeyWithSerialization = DSAPublicKey
147
+ DSAPublicKey.register(rust_openssl.dsa.DSAPublicKey)
148
+
149
+ DSAPrivateNumbers = rust_openssl.dsa.DSAPrivateNumbers
150
+ DSAPublicNumbers = rust_openssl.dsa.DSAPublicNumbers
151
+ DSAParameterNumbers = rust_openssl.dsa.DSAParameterNumbers
152
+
153
+
154
+ def generate_parameters(
155
+ key_size: int, backend: typing.Any = None
156
+ ) -> DSAParameters:
157
+ if key_size not in (1024, 2048, 3072, 4096):
158
+ raise ValueError("Key size must be 1024, 2048, 3072, or 4096 bits.")
159
+
160
+ return rust_openssl.dsa.generate_parameters(key_size)
161
+
162
+
163
+ def generate_private_key(
164
+ key_size: int, backend: typing.Any = None
165
+ ) -> DSAPrivateKey:
166
+ parameters = generate_parameters(key_size)
167
+ return parameters.generate_private_key()