@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.
- package/README.md +1 -1
- package/bin/pairling-connectd +0 -0
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/python/bin/python3 +0 -0
- package/python/bin/python3.12 +0 -0
- package/python/lib/libpython3.12.dylib +0 -0
- package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/site-packages/cffi/__init__.py +14 -0
- package/python/lib/python3.12/site-packages/cffi/_cffi_errors.h +149 -0
- package/python/lib/python3.12/site-packages/cffi/_cffi_include.h +389 -0
- package/python/lib/python3.12/site-packages/cffi/_embedding.h +550 -0
- package/python/lib/python3.12/site-packages/cffi/_imp_emulation.py +83 -0
- package/python/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py +45 -0
- package/python/lib/python3.12/site-packages/cffi/api.py +967 -0
- package/python/lib/python3.12/site-packages/cffi/backend_ctypes.py +1121 -0
- package/python/lib/python3.12/site-packages/cffi/cffi_opcode.py +187 -0
- package/python/lib/python3.12/site-packages/cffi/commontypes.py +82 -0
- package/python/lib/python3.12/site-packages/cffi/cparser.py +1015 -0
- package/python/lib/python3.12/site-packages/cffi/error.py +31 -0
- package/python/lib/python3.12/site-packages/cffi/ffiplatform.py +113 -0
- package/python/lib/python3.12/site-packages/cffi/lock.py +30 -0
- package/python/lib/python3.12/site-packages/cffi/model.py +618 -0
- package/python/lib/python3.12/site-packages/cffi/parse_c_type.h +181 -0
- package/python/lib/python3.12/site-packages/cffi/pkgconfig.py +121 -0
- package/python/lib/python3.12/site-packages/cffi/recompiler.py +1598 -0
- package/python/lib/python3.12/site-packages/cffi/setuptools_ext.py +216 -0
- package/python/lib/python3.12/site-packages/cffi/vengine_cpy.py +1084 -0
- package/python/lib/python3.12/site-packages/cffi/vengine_gen.py +679 -0
- package/python/lib/python3.12/site-packages/cffi/verifier.py +306 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/LICENSE +26 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/METADATA +40 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/RECORD +30 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/WHEEL +5 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/entry_points.txt +2 -0
- package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/top_level.txt +2 -0
- package/python/lib/python3.12/site-packages/cryptography/__about__.py +17 -0
- package/python/lib/python3.12/site-packages/cryptography/__init__.py +26 -0
- package/python/lib/python3.12/site-packages/cryptography/exceptions.py +52 -0
- package/python/lib/python3.12/site-packages/cryptography/fernet.py +224 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/__init__.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/_oid.py +348 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/__init__.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/__init__.py +9 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py +308 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust.abi3.so +0 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +191 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/binding.py +122 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +112 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_asymmetric.py +19 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +60 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_serialization.py +168 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +147 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +167 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +447 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +129 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +131 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +113 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +277 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py +111 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py +24 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +122 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +125 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +183 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py +146 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/cmac.py +10 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/constant_time.py +14 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hashes.py +246 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hmac.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/argon2.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +125 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +101 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +305 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +62 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py +19 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +61 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/keywrap.py +177 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/padding.py +69 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/poly1305.py +11 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +65 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/base.py +14 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +176 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +411 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1619 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/__init__.py +9 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +101 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +56 -0
- package/python/lib/python3.12/site-packages/cryptography/py.typed +0 -0
- package/python/lib/python3.12/site-packages/cryptography/utils.py +139 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/__init__.py +270 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/base.py +848 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/certificate_transparency.py +35 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/extensions.py +2528 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/general_name.py +281 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/name.py +477 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/ocsp.py +379 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/oid.py +37 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/verification.py +34 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/METADATA +139 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/RECORD +106 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/REQUESTED +0 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/WHEEL +4 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE +3 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.APACHE +202 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.BSD +27 -0
- package/python/lib/python3.12/site-packages/pycparser/__init__.py +99 -0
- package/python/lib/python3.12/site-packages/pycparser/_ast_gen.py +355 -0
- package/python/lib/python3.12/site-packages/pycparser/_c_ast.cfg +195 -0
- package/python/lib/python3.12/site-packages/pycparser/ast_transforms.py +174 -0
- package/python/lib/python3.12/site-packages/pycparser/c_ast.py +1341 -0
- package/python/lib/python3.12/site-packages/pycparser/c_generator.py +573 -0
- package/python/lib/python3.12/site-packages/pycparser/c_lexer.py +706 -0
- package/python/lib/python3.12/site-packages/pycparser/c_parser.py +2376 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/METADATA +244 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/RECORD +14 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/WHEEL +5 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/licenses/LICENSE +27 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/top_level.txt +1 -0
package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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.primitives import hashes
|
|
10
|
+
from cryptography.hazmat.primitives._asymmetric import (
|
|
11
|
+
AsymmetricPadding as AsymmetricPadding,
|
|
12
|
+
)
|
|
13
|
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PKCS1v15(AsymmetricPadding):
|
|
17
|
+
name = "EMSA-PKCS1-v1_5"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class _MaxLength:
|
|
21
|
+
"Sentinel value for `MAX_LENGTH`."
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _Auto:
|
|
25
|
+
"Sentinel value for `AUTO`."
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _DigestLength:
|
|
29
|
+
"Sentinel value for `DIGEST_LENGTH`."
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class PSS(AsymmetricPadding):
|
|
33
|
+
MAX_LENGTH = _MaxLength()
|
|
34
|
+
AUTO = _Auto()
|
|
35
|
+
DIGEST_LENGTH = _DigestLength()
|
|
36
|
+
name = "EMSA-PSS"
|
|
37
|
+
_salt_length: int | _MaxLength | _Auto | _DigestLength
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
mgf: MGF,
|
|
42
|
+
salt_length: int | _MaxLength | _Auto | _DigestLength,
|
|
43
|
+
) -> None:
|
|
44
|
+
self._mgf = mgf
|
|
45
|
+
|
|
46
|
+
if not isinstance(
|
|
47
|
+
salt_length, (int, _MaxLength, _Auto, _DigestLength)
|
|
48
|
+
):
|
|
49
|
+
raise TypeError(
|
|
50
|
+
"salt_length must be an integer, MAX_LENGTH, "
|
|
51
|
+
"DIGEST_LENGTH, or AUTO"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if isinstance(salt_length, int) and salt_length < 0:
|
|
55
|
+
raise ValueError("salt_length must be zero or greater.")
|
|
56
|
+
|
|
57
|
+
self._salt_length = salt_length
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def mgf(self) -> MGF:
|
|
61
|
+
return self._mgf
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class OAEP(AsymmetricPadding):
|
|
65
|
+
name = "EME-OAEP"
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
mgf: MGF,
|
|
70
|
+
algorithm: hashes.HashAlgorithm,
|
|
71
|
+
label: bytes | None,
|
|
72
|
+
):
|
|
73
|
+
if not isinstance(algorithm, hashes.HashAlgorithm):
|
|
74
|
+
raise TypeError("Expected instance of hashes.HashAlgorithm.")
|
|
75
|
+
|
|
76
|
+
self._mgf = mgf
|
|
77
|
+
self._algorithm = algorithm
|
|
78
|
+
self._label = label
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def algorithm(self) -> hashes.HashAlgorithm:
|
|
82
|
+
return self._algorithm
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def mgf(self) -> MGF:
|
|
86
|
+
return self._mgf
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class MGF(metaclass=abc.ABCMeta):
|
|
90
|
+
_algorithm: hashes.HashAlgorithm
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class MGF1(MGF):
|
|
94
|
+
MAX_LENGTH = _MaxLength()
|
|
95
|
+
|
|
96
|
+
def __init__(self, algorithm: hashes.HashAlgorithm):
|
|
97
|
+
if not isinstance(algorithm, hashes.HashAlgorithm):
|
|
98
|
+
raise TypeError("Expected instance of hashes.HashAlgorithm.")
|
|
99
|
+
|
|
100
|
+
self._algorithm = algorithm
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def calculate_max_pss_salt_length(
|
|
104
|
+
key: rsa.RSAPrivateKey | rsa.RSAPublicKey,
|
|
105
|
+
hash_algorithm: hashes.HashAlgorithm,
|
|
106
|
+
) -> int:
|
|
107
|
+
if not isinstance(key, (rsa.RSAPrivateKey, rsa.RSAPublicKey)):
|
|
108
|
+
raise TypeError("key must be an RSA public or private key")
|
|
109
|
+
# bit length - 1 per RFC 3447
|
|
110
|
+
emlen = (key.key_size + 6) // 8
|
|
111
|
+
salt_length = emlen - hash_algorithm.digest_size - 2
|
|
112
|
+
assert salt_length >= 0
|
|
113
|
+
return salt_length
|
|
@@ -0,0 +1,277 @@
|
|
|
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 random
|
|
9
|
+
import typing
|
|
10
|
+
from math import gcd
|
|
11
|
+
|
|
12
|
+
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
|
13
|
+
from cryptography.hazmat.primitives import _serialization, hashes
|
|
14
|
+
from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding
|
|
15
|
+
from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RSAPrivateKey(metaclass=abc.ABCMeta):
|
|
19
|
+
@abc.abstractmethod
|
|
20
|
+
def decrypt(self, ciphertext: bytes, padding: AsymmetricPadding) -> bytes:
|
|
21
|
+
"""
|
|
22
|
+
Decrypts the provided ciphertext.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
@abc.abstractmethod
|
|
27
|
+
def key_size(self) -> int:
|
|
28
|
+
"""
|
|
29
|
+
The bit length of the public modulus.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
@abc.abstractmethod
|
|
33
|
+
def public_key(self) -> RSAPublicKey:
|
|
34
|
+
"""
|
|
35
|
+
The RSAPublicKey associated with this private key.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
@abc.abstractmethod
|
|
39
|
+
def sign(
|
|
40
|
+
self,
|
|
41
|
+
data: bytes,
|
|
42
|
+
padding: AsymmetricPadding,
|
|
43
|
+
algorithm: asym_utils.Prehashed | hashes.HashAlgorithm,
|
|
44
|
+
) -> bytes:
|
|
45
|
+
"""
|
|
46
|
+
Signs the data.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
@abc.abstractmethod
|
|
50
|
+
def private_numbers(self) -> RSAPrivateNumbers:
|
|
51
|
+
"""
|
|
52
|
+
Returns an RSAPrivateNumbers.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
@abc.abstractmethod
|
|
56
|
+
def private_bytes(
|
|
57
|
+
self,
|
|
58
|
+
encoding: _serialization.Encoding,
|
|
59
|
+
format: _serialization.PrivateFormat,
|
|
60
|
+
encryption_algorithm: _serialization.KeySerializationEncryption,
|
|
61
|
+
) -> bytes:
|
|
62
|
+
"""
|
|
63
|
+
Returns the key serialized as bytes.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
@abc.abstractmethod
|
|
67
|
+
def __copy__(self) -> RSAPrivateKey:
|
|
68
|
+
"""
|
|
69
|
+
Returns a copy.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
RSAPrivateKeyWithSerialization = RSAPrivateKey
|
|
74
|
+
RSAPrivateKey.register(rust_openssl.rsa.RSAPrivateKey)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class RSAPublicKey(metaclass=abc.ABCMeta):
|
|
78
|
+
@abc.abstractmethod
|
|
79
|
+
def encrypt(self, plaintext: bytes, padding: AsymmetricPadding) -> bytes:
|
|
80
|
+
"""
|
|
81
|
+
Encrypts the given plaintext.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
@abc.abstractmethod
|
|
86
|
+
def key_size(self) -> int:
|
|
87
|
+
"""
|
|
88
|
+
The bit length of the public modulus.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@abc.abstractmethod
|
|
92
|
+
def public_numbers(self) -> RSAPublicNumbers:
|
|
93
|
+
"""
|
|
94
|
+
Returns an RSAPublicNumbers
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
@abc.abstractmethod
|
|
98
|
+
def public_bytes(
|
|
99
|
+
self,
|
|
100
|
+
encoding: _serialization.Encoding,
|
|
101
|
+
format: _serialization.PublicFormat,
|
|
102
|
+
) -> bytes:
|
|
103
|
+
"""
|
|
104
|
+
Returns the key serialized as bytes.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
@abc.abstractmethod
|
|
108
|
+
def verify(
|
|
109
|
+
self,
|
|
110
|
+
signature: bytes,
|
|
111
|
+
data: bytes,
|
|
112
|
+
padding: AsymmetricPadding,
|
|
113
|
+
algorithm: asym_utils.Prehashed | hashes.HashAlgorithm,
|
|
114
|
+
) -> None:
|
|
115
|
+
"""
|
|
116
|
+
Verifies the signature of the data.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
@abc.abstractmethod
|
|
120
|
+
def recover_data_from_signature(
|
|
121
|
+
self,
|
|
122
|
+
signature: bytes,
|
|
123
|
+
padding: AsymmetricPadding,
|
|
124
|
+
algorithm: hashes.HashAlgorithm | None,
|
|
125
|
+
) -> bytes:
|
|
126
|
+
"""
|
|
127
|
+
Recovers the original data from the signature.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
@abc.abstractmethod
|
|
131
|
+
def __eq__(self, other: object) -> bool:
|
|
132
|
+
"""
|
|
133
|
+
Checks equality.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
@abc.abstractmethod
|
|
137
|
+
def __copy__(self) -> RSAPublicKey:
|
|
138
|
+
"""
|
|
139
|
+
Returns a copy.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
RSAPublicKeyWithSerialization = RSAPublicKey
|
|
144
|
+
RSAPublicKey.register(rust_openssl.rsa.RSAPublicKey)
|
|
145
|
+
|
|
146
|
+
RSAPrivateNumbers = rust_openssl.rsa.RSAPrivateNumbers
|
|
147
|
+
RSAPublicNumbers = rust_openssl.rsa.RSAPublicNumbers
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def generate_private_key(
|
|
151
|
+
public_exponent: int,
|
|
152
|
+
key_size: int,
|
|
153
|
+
backend: typing.Any = None,
|
|
154
|
+
) -> RSAPrivateKey:
|
|
155
|
+
_verify_rsa_parameters(public_exponent, key_size)
|
|
156
|
+
return rust_openssl.rsa.generate_private_key(public_exponent, key_size)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _verify_rsa_parameters(public_exponent: int, key_size: int) -> None:
|
|
160
|
+
if public_exponent not in (3, 65537):
|
|
161
|
+
raise ValueError(
|
|
162
|
+
"public_exponent must be either 3 (for legacy compatibility) or "
|
|
163
|
+
"65537. Almost everyone should choose 65537 here!"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
if key_size < 1024:
|
|
167
|
+
raise ValueError("key_size must be at least 1024-bits.")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _modinv(e: int, m: int) -> int:
|
|
171
|
+
"""
|
|
172
|
+
Modular Multiplicative Inverse. Returns x such that: (x*e) mod m == 1
|
|
173
|
+
"""
|
|
174
|
+
x1, x2 = 1, 0
|
|
175
|
+
a, b = e, m
|
|
176
|
+
while b > 0:
|
|
177
|
+
q, r = divmod(a, b)
|
|
178
|
+
xn = x1 - q * x2
|
|
179
|
+
a, b, x1, x2 = b, r, x2, xn
|
|
180
|
+
return x1 % m
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def rsa_crt_iqmp(p: int, q: int) -> int:
|
|
184
|
+
"""
|
|
185
|
+
Compute the CRT (q ** -1) % p value from RSA primes p and q.
|
|
186
|
+
"""
|
|
187
|
+
return _modinv(q, p)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def rsa_crt_dmp1(private_exponent: int, p: int) -> int:
|
|
191
|
+
"""
|
|
192
|
+
Compute the CRT private_exponent % (p - 1) value from the RSA
|
|
193
|
+
private_exponent (d) and p.
|
|
194
|
+
"""
|
|
195
|
+
return private_exponent % (p - 1)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def rsa_crt_dmq1(private_exponent: int, q: int) -> int:
|
|
199
|
+
"""
|
|
200
|
+
Compute the CRT private_exponent % (q - 1) value from the RSA
|
|
201
|
+
private_exponent (d) and q.
|
|
202
|
+
"""
|
|
203
|
+
return private_exponent % (q - 1)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def rsa_recover_private_exponent(e: int, p: int, q: int) -> int:
|
|
207
|
+
"""
|
|
208
|
+
Compute the RSA private_exponent (d) given the public exponent (e)
|
|
209
|
+
and the RSA primes p and q.
|
|
210
|
+
|
|
211
|
+
This uses the Carmichael totient function to generate the
|
|
212
|
+
smallest possible working value of the private exponent.
|
|
213
|
+
"""
|
|
214
|
+
# This lambda_n is the Carmichael totient function.
|
|
215
|
+
# The original RSA paper uses the Euler totient function
|
|
216
|
+
# here: phi_n = (p - 1) * (q - 1)
|
|
217
|
+
# Either version of the private exponent will work, but the
|
|
218
|
+
# one generated by the older formulation may be larger
|
|
219
|
+
# than necessary. (lambda_n always divides phi_n)
|
|
220
|
+
#
|
|
221
|
+
# TODO: Replace with lcm(p - 1, q - 1) once the minimum
|
|
222
|
+
# supported Python version is >= 3.9.
|
|
223
|
+
lambda_n = (p - 1) * (q - 1) // gcd(p - 1, q - 1)
|
|
224
|
+
return _modinv(e, lambda_n)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
# Controls the number of iterations rsa_recover_prime_factors will perform
|
|
228
|
+
# to obtain the prime factors.
|
|
229
|
+
_MAX_RECOVERY_ATTEMPTS = 500
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def rsa_recover_prime_factors(n: int, e: int, d: int) -> tuple[int, int]:
|
|
233
|
+
"""
|
|
234
|
+
Compute factors p and q from the private exponent d. We assume that n has
|
|
235
|
+
no more than two factors. This function is adapted from code in PyCrypto.
|
|
236
|
+
"""
|
|
237
|
+
# reject invalid values early
|
|
238
|
+
if d <= 1 or e <= 1:
|
|
239
|
+
raise ValueError("d, e can't be <= 1")
|
|
240
|
+
if 17 != pow(17, e * d, n):
|
|
241
|
+
raise ValueError("n, d, e don't match")
|
|
242
|
+
# See 8.2.2(i) in Handbook of Applied Cryptography.
|
|
243
|
+
ktot = d * e - 1
|
|
244
|
+
# The quantity d*e-1 is a multiple of phi(n), even,
|
|
245
|
+
# and can be represented as t*2^s.
|
|
246
|
+
t = ktot
|
|
247
|
+
while t % 2 == 0:
|
|
248
|
+
t = t // 2
|
|
249
|
+
# Cycle through all multiplicative inverses in Zn.
|
|
250
|
+
# The algorithm is non-deterministic, but there is a 50% chance
|
|
251
|
+
# any candidate a leads to successful factoring.
|
|
252
|
+
# See "Digitalized Signatures and Public Key Functions as Intractable
|
|
253
|
+
# as Factorization", M. Rabin, 1979
|
|
254
|
+
spotted = False
|
|
255
|
+
tries = 0
|
|
256
|
+
while not spotted and tries < _MAX_RECOVERY_ATTEMPTS:
|
|
257
|
+
a = random.randint(2, n - 1)
|
|
258
|
+
tries += 1
|
|
259
|
+
k = t
|
|
260
|
+
# Cycle through all values a^{t*2^i}=a^k
|
|
261
|
+
while k < ktot:
|
|
262
|
+
cand = pow(a, k, n)
|
|
263
|
+
# Check if a^k is a non-trivial root of unity (mod n)
|
|
264
|
+
if cand != 1 and cand != (n - 1) and pow(cand, 2, n) == 1:
|
|
265
|
+
# We have found a number such that (cand-1)(cand+1)=0 (mod n).
|
|
266
|
+
# Either of the terms divides n.
|
|
267
|
+
p = gcd(cand + 1, n)
|
|
268
|
+
spotted = True
|
|
269
|
+
break
|
|
270
|
+
k *= 2
|
|
271
|
+
if not spotted:
|
|
272
|
+
raise ValueError("Unable to compute factors p and q from exponent d.")
|
|
273
|
+
# Found !
|
|
274
|
+
q, r = divmod(n, p)
|
|
275
|
+
assert r == 0
|
|
276
|
+
p, q = sorted((p, q), reverse=True)
|
|
277
|
+
return (p, q)
|
package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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 import utils
|
|
10
|
+
from cryptography.hazmat.primitives.asymmetric import (
|
|
11
|
+
dh,
|
|
12
|
+
dsa,
|
|
13
|
+
ec,
|
|
14
|
+
ed448,
|
|
15
|
+
ed25519,
|
|
16
|
+
rsa,
|
|
17
|
+
x448,
|
|
18
|
+
x25519,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Every asymmetric key type
|
|
22
|
+
PublicKeyTypes = typing.Union[
|
|
23
|
+
dh.DHPublicKey,
|
|
24
|
+
dsa.DSAPublicKey,
|
|
25
|
+
rsa.RSAPublicKey,
|
|
26
|
+
ec.EllipticCurvePublicKey,
|
|
27
|
+
ed25519.Ed25519PublicKey,
|
|
28
|
+
ed448.Ed448PublicKey,
|
|
29
|
+
x25519.X25519PublicKey,
|
|
30
|
+
x448.X448PublicKey,
|
|
31
|
+
]
|
|
32
|
+
PUBLIC_KEY_TYPES = PublicKeyTypes
|
|
33
|
+
utils.deprecated(
|
|
34
|
+
PUBLIC_KEY_TYPES,
|
|
35
|
+
__name__,
|
|
36
|
+
"Use PublicKeyTypes instead",
|
|
37
|
+
utils.DeprecatedIn40,
|
|
38
|
+
name="PUBLIC_KEY_TYPES",
|
|
39
|
+
)
|
|
40
|
+
# Every asymmetric key type
|
|
41
|
+
PrivateKeyTypes = typing.Union[
|
|
42
|
+
dh.DHPrivateKey,
|
|
43
|
+
ed25519.Ed25519PrivateKey,
|
|
44
|
+
ed448.Ed448PrivateKey,
|
|
45
|
+
rsa.RSAPrivateKey,
|
|
46
|
+
dsa.DSAPrivateKey,
|
|
47
|
+
ec.EllipticCurvePrivateKey,
|
|
48
|
+
x25519.X25519PrivateKey,
|
|
49
|
+
x448.X448PrivateKey,
|
|
50
|
+
]
|
|
51
|
+
PRIVATE_KEY_TYPES = PrivateKeyTypes
|
|
52
|
+
utils.deprecated(
|
|
53
|
+
PRIVATE_KEY_TYPES,
|
|
54
|
+
__name__,
|
|
55
|
+
"Use PrivateKeyTypes instead",
|
|
56
|
+
utils.DeprecatedIn40,
|
|
57
|
+
name="PRIVATE_KEY_TYPES",
|
|
58
|
+
)
|
|
59
|
+
# Just the key types we allow to be used for x509 signing. This mirrors
|
|
60
|
+
# the certificate public key types
|
|
61
|
+
CertificateIssuerPrivateKeyTypes = typing.Union[
|
|
62
|
+
ed25519.Ed25519PrivateKey,
|
|
63
|
+
ed448.Ed448PrivateKey,
|
|
64
|
+
rsa.RSAPrivateKey,
|
|
65
|
+
dsa.DSAPrivateKey,
|
|
66
|
+
ec.EllipticCurvePrivateKey,
|
|
67
|
+
]
|
|
68
|
+
CERTIFICATE_PRIVATE_KEY_TYPES = CertificateIssuerPrivateKeyTypes
|
|
69
|
+
utils.deprecated(
|
|
70
|
+
CERTIFICATE_PRIVATE_KEY_TYPES,
|
|
71
|
+
__name__,
|
|
72
|
+
"Use CertificateIssuerPrivateKeyTypes instead",
|
|
73
|
+
utils.DeprecatedIn40,
|
|
74
|
+
name="CERTIFICATE_PRIVATE_KEY_TYPES",
|
|
75
|
+
)
|
|
76
|
+
# Just the key types we allow to be used for x509 signing. This mirrors
|
|
77
|
+
# the certificate private key types
|
|
78
|
+
CertificateIssuerPublicKeyTypes = typing.Union[
|
|
79
|
+
dsa.DSAPublicKey,
|
|
80
|
+
rsa.RSAPublicKey,
|
|
81
|
+
ec.EllipticCurvePublicKey,
|
|
82
|
+
ed25519.Ed25519PublicKey,
|
|
83
|
+
ed448.Ed448PublicKey,
|
|
84
|
+
]
|
|
85
|
+
CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES = CertificateIssuerPublicKeyTypes
|
|
86
|
+
utils.deprecated(
|
|
87
|
+
CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES,
|
|
88
|
+
__name__,
|
|
89
|
+
"Use CertificateIssuerPublicKeyTypes instead",
|
|
90
|
+
utils.DeprecatedIn40,
|
|
91
|
+
name="CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES",
|
|
92
|
+
)
|
|
93
|
+
# This type removes DHPublicKey. x448/x25519 can be a public key
|
|
94
|
+
# but cannot be used in signing so they are allowed here.
|
|
95
|
+
CertificatePublicKeyTypes = typing.Union[
|
|
96
|
+
dsa.DSAPublicKey,
|
|
97
|
+
rsa.RSAPublicKey,
|
|
98
|
+
ec.EllipticCurvePublicKey,
|
|
99
|
+
ed25519.Ed25519PublicKey,
|
|
100
|
+
ed448.Ed448PublicKey,
|
|
101
|
+
x25519.X25519PublicKey,
|
|
102
|
+
x448.X448PublicKey,
|
|
103
|
+
]
|
|
104
|
+
CERTIFICATE_PUBLIC_KEY_TYPES = CertificatePublicKeyTypes
|
|
105
|
+
utils.deprecated(
|
|
106
|
+
CERTIFICATE_PUBLIC_KEY_TYPES,
|
|
107
|
+
__name__,
|
|
108
|
+
"Use CertificatePublicKeyTypes instead",
|
|
109
|
+
utils.DeprecatedIn40,
|
|
110
|
+
name="CERTIFICATE_PUBLIC_KEY_TYPES",
|
|
111
|
+
)
|
package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file is dual licensed under the terms of the Apache License, Version
|
|
2
|
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
|
3
|
+
# for complete details.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from cryptography.hazmat.bindings._rust import asn1
|
|
8
|
+
from cryptography.hazmat.primitives import hashes
|
|
9
|
+
|
|
10
|
+
decode_dss_signature = asn1.decode_dss_signature
|
|
11
|
+
encode_dss_signature = asn1.encode_dss_signature
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Prehashed:
|
|
15
|
+
def __init__(self, algorithm: hashes.HashAlgorithm):
|
|
16
|
+
if not isinstance(algorithm, hashes.HashAlgorithm):
|
|
17
|
+
raise TypeError("Expected instance of HashAlgorithm.")
|
|
18
|
+
|
|
19
|
+
self._algorithm = algorithm
|
|
20
|
+
self._digest_size = algorithm.digest_size
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def digest_size(self) -> int:
|
|
24
|
+
return self._digest_size
|
package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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 X25519PublicKey(metaclass=abc.ABCMeta):
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_public_bytes(cls, data: bytes) -> X25519PublicKey:
|
|
18
|
+
from cryptography.hazmat.backends.openssl.backend import backend
|
|
19
|
+
|
|
20
|
+
if not backend.x25519_supported():
|
|
21
|
+
raise UnsupportedAlgorithm(
|
|
22
|
+
"X25519 is not supported by this version of OpenSSL.",
|
|
23
|
+
_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return rust_openssl.x25519.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) -> X25519PublicKey:
|
|
53
|
+
"""
|
|
54
|
+
Returns a copy.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
X25519PublicKey.register(rust_openssl.x25519.X25519PublicKey)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class X25519PrivateKey(metaclass=abc.ABCMeta):
|
|
62
|
+
@classmethod
|
|
63
|
+
def generate(cls) -> X25519PrivateKey:
|
|
64
|
+
from cryptography.hazmat.backends.openssl.backend import backend
|
|
65
|
+
|
|
66
|
+
if not backend.x25519_supported():
|
|
67
|
+
raise UnsupportedAlgorithm(
|
|
68
|
+
"X25519 is not supported by this version of OpenSSL.",
|
|
69
|
+
_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
|
|
70
|
+
)
|
|
71
|
+
return rust_openssl.x25519.generate_key()
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_private_bytes(cls, data: Buffer) -> X25519PrivateKey:
|
|
75
|
+
from cryptography.hazmat.backends.openssl.backend import backend
|
|
76
|
+
|
|
77
|
+
if not backend.x25519_supported():
|
|
78
|
+
raise UnsupportedAlgorithm(
|
|
79
|
+
"X25519 is not supported by this version of OpenSSL.",
|
|
80
|
+
_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
return rust_openssl.x25519.from_private_bytes(data)
|
|
84
|
+
|
|
85
|
+
@abc.abstractmethod
|
|
86
|
+
def public_key(self) -> X25519PublicKey:
|
|
87
|
+
"""
|
|
88
|
+
Returns the public key associated with this private key
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@abc.abstractmethod
|
|
92
|
+
def private_bytes(
|
|
93
|
+
self,
|
|
94
|
+
encoding: _serialization.Encoding,
|
|
95
|
+
format: _serialization.PrivateFormat,
|
|
96
|
+
encryption_algorithm: _serialization.KeySerializationEncryption,
|
|
97
|
+
) -> bytes:
|
|
98
|
+
"""
|
|
99
|
+
The serialized bytes of the private key.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
@abc.abstractmethod
|
|
103
|
+
def private_bytes_raw(self) -> bytes:
|
|
104
|
+
"""
|
|
105
|
+
The raw bytes of the private key.
|
|
106
|
+
Equivalent to private_bytes(Raw, Raw, NoEncryption()).
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
@abc.abstractmethod
|
|
110
|
+
def exchange(self, peer_public_key: X25519PublicKey) -> bytes:
|
|
111
|
+
"""
|
|
112
|
+
Performs a key exchange operation using the provided peer's public key.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
@abc.abstractmethod
|
|
116
|
+
def __copy__(self) -> X25519PrivateKey:
|
|
117
|
+
"""
|
|
118
|
+
Returns a copy.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
X25519PrivateKey.register(rust_openssl.x25519.X25519PrivateKey)
|