pysequoia 0.1.36__cp315-cp315-win_amd64.whl
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.
- pysequoia/__init__.py +8 -0
- pysequoia/__init__.pyi +649 -0
- pysequoia/packet.pyi +614 -0
- pysequoia/py.typed +0 -0
- pysequoia/pysequoia.cp315-win_amd64.pyd +0 -0
- pysequoia-0.1.36.dist-info/METADATA +947 -0
- pysequoia-0.1.36.dist-info/RECORD +10 -0
- pysequoia-0.1.36.dist-info/WHEEL +4 -0
- pysequoia-0.1.36.dist-info/licenses/LICENSE +202 -0
- pysequoia-0.1.36.dist-info/sboms/pysequoia.cyclonedx.json +8607 -0
pysequoia/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from .pysequoia import * # noqa: F403
|
|
4
|
+
from .pysequoia import packet as packet
|
|
5
|
+
|
|
6
|
+
# Register the native submodule so that "from pysequoia.packet import ..." works.
|
|
7
|
+
# Without this, Python would look for pysequoia/packet.py which doesn't exist.
|
|
8
|
+
sys.modules[__name__ + ".packet"] = packet
|
pysequoia/__init__.pyi
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
from . import packet as packet
|
|
2
|
+
from .packet import HashAlgorithm, Packet, PublicKeyAlgorithm, SignatureType
|
|
3
|
+
from _typeshed import Incomplete, SupportsGetItem
|
|
4
|
+
from datetime import datetime, timedelta
|
|
5
|
+
from os import PathLike
|
|
6
|
+
from typing import Any, Final, SupportsIndex, final
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
class ArmorKind:
|
|
10
|
+
"""
|
|
11
|
+
The type of ASCII armor to use when wrapping OpenPGP data.
|
|
12
|
+
"""
|
|
13
|
+
Message: Final[ArmorKind]
|
|
14
|
+
"""
|
|
15
|
+
`PGP MESSAGE`
|
|
16
|
+
"""
|
|
17
|
+
PublicKey: Final[ArmorKind]
|
|
18
|
+
"""
|
|
19
|
+
`PGP PUBLIC KEY BLOCK`
|
|
20
|
+
"""
|
|
21
|
+
SecretKey: Final[ArmorKind]
|
|
22
|
+
"""
|
|
23
|
+
`PGP PRIVATE KEY BLOCK`
|
|
24
|
+
"""
|
|
25
|
+
Signature: Final[ArmorKind]
|
|
26
|
+
"""
|
|
27
|
+
`PGP SIGNATURE`
|
|
28
|
+
"""
|
|
29
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
30
|
+
def __int__(self, /) -> int: ...
|
|
31
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
32
|
+
def __repr__(self, /) -> str: ...
|
|
33
|
+
|
|
34
|
+
@final
|
|
35
|
+
class Cert:
|
|
36
|
+
"""
|
|
37
|
+
An OpenPGP certificate (public key with associated user IDs, subkeys, and signatures).
|
|
38
|
+
"""
|
|
39
|
+
def __bytes__(self, /) -> bytes:
|
|
40
|
+
"""
|
|
41
|
+
Return the raw binary encoding of this certificate.
|
|
42
|
+
"""
|
|
43
|
+
def __repr__(self, /) -> str: ...
|
|
44
|
+
def __str__(self, /) -> str:
|
|
45
|
+
"""
|
|
46
|
+
Return the ASCII-armored public key representation of this certificate.
|
|
47
|
+
"""
|
|
48
|
+
def add_user_id(self, /, value: str, certifier: PySigner) -> Cert:
|
|
49
|
+
"""
|
|
50
|
+
Add a User ID to this certificate, certified by the given signer.
|
|
51
|
+
"""
|
|
52
|
+
@property
|
|
53
|
+
def expiration(self, /) -> datetime | None:
|
|
54
|
+
"""
|
|
55
|
+
The expiration time of this certificate, or `None` if it does not expire.
|
|
56
|
+
"""
|
|
57
|
+
@property
|
|
58
|
+
def fingerprint(self, /) -> str:
|
|
59
|
+
"""
|
|
60
|
+
The fingerprint of this certificate's primary key, as a lowercase hex string.
|
|
61
|
+
"""
|
|
62
|
+
@staticmethod
|
|
63
|
+
def from_bytes(bytes: bytes, policy: Policy | None = None) -> Cert:
|
|
64
|
+
"""
|
|
65
|
+
Parse a certificate from a byte string.
|
|
66
|
+
|
|
67
|
+
The bytes may be binary or ASCII-armored.
|
|
68
|
+
"""
|
|
69
|
+
@staticmethod
|
|
70
|
+
def from_file(path: str, policy: Policy | None = None) -> Cert:
|
|
71
|
+
"""
|
|
72
|
+
Parse a certificate from a file on disk.
|
|
73
|
+
|
|
74
|
+
The file may be binary or ASCII-armored.
|
|
75
|
+
"""
|
|
76
|
+
@staticmethod
|
|
77
|
+
def from_packets(packets: SupportsGetItem[int, Packet], policy: Policy | None = None) -> Cert:
|
|
78
|
+
"""
|
|
79
|
+
Build a certificate from a sequence of OpenPGP packets.
|
|
80
|
+
|
|
81
|
+
The packets must form a valid certificate (a primary key followed by
|
|
82
|
+
its associated user IDs, user attributes, subkeys, and signatures).
|
|
83
|
+
"""
|
|
84
|
+
@staticmethod
|
|
85
|
+
def generate(user_id: str | None = None, user_ids: SupportsGetItem[int, str] | None = None, profile: Profile | None = None, validity_seconds: SupportsIndex | None = ...) -> Cert:
|
|
86
|
+
"""
|
|
87
|
+
Generate a new certificate with a certification-capable primary key,
|
|
88
|
+
a signing subkey, and an encryption subkey.
|
|
89
|
+
|
|
90
|
+
The generated certificate has a validity period of 3 years.
|
|
91
|
+
"""
|
|
92
|
+
@property
|
|
93
|
+
def has_secret_keys(self, /) -> bool:
|
|
94
|
+
"""
|
|
95
|
+
Whether this certificate contains secret key material.
|
|
96
|
+
"""
|
|
97
|
+
@property
|
|
98
|
+
def is_revoked(self, /) -> bool:
|
|
99
|
+
"""
|
|
100
|
+
Whether this certificate has been revoked.
|
|
101
|
+
"""
|
|
102
|
+
def merge(self, /, new_cert: Cert) -> Cert:
|
|
103
|
+
"""
|
|
104
|
+
Merge another certificate into this one, combining their packets.
|
|
105
|
+
|
|
106
|
+
Both certificates must have the same primary key fingerprint.
|
|
107
|
+
"""
|
|
108
|
+
def revoke(self, /, certifier: PySigner) -> Sig:
|
|
109
|
+
"""
|
|
110
|
+
Create a revocation signature for this certificate.
|
|
111
|
+
"""
|
|
112
|
+
def revoke_user_id(self, /, user_id: UserId, certifier: PySigner) -> Sig:
|
|
113
|
+
"""
|
|
114
|
+
Create a revocation signature for the given User ID.
|
|
115
|
+
"""
|
|
116
|
+
@property
|
|
117
|
+
def secrets(self, /) -> Tsk | None:
|
|
118
|
+
"""
|
|
119
|
+
Access the secret key material, if present.
|
|
120
|
+
|
|
121
|
+
Returns `None` if the certificate does not contain secret keys.
|
|
122
|
+
"""
|
|
123
|
+
def set_expiration(self, /, expiration: datetime, certifier: PySigner) -> Cert:
|
|
124
|
+
"""
|
|
125
|
+
Set the expiration time of this certificate.
|
|
126
|
+
"""
|
|
127
|
+
def set_notations(self, /, certifier: PySigner, notations: SupportsGetItem[int, Notation]) -> Cert:
|
|
128
|
+
"""
|
|
129
|
+
Set notation data on the first User ID's binding signature.
|
|
130
|
+
"""
|
|
131
|
+
@staticmethod
|
|
132
|
+
def split_bytes(bytes: bytes, policy: Policy | None = None) -> list[Cert]:
|
|
133
|
+
"""
|
|
134
|
+
Parse multiple certificates from a byte string.
|
|
135
|
+
|
|
136
|
+
Returns a list of all certificates found in the data.
|
|
137
|
+
The bytes may be binary or ASCII-armored.
|
|
138
|
+
"""
|
|
139
|
+
@staticmethod
|
|
140
|
+
def split_file(path: str, policy: Policy | None = None) -> list[Cert]:
|
|
141
|
+
"""
|
|
142
|
+
Parse multiple certificates from a file on disk.
|
|
143
|
+
|
|
144
|
+
Returns a list of all certificates found in the file.
|
|
145
|
+
The file may be binary or ASCII-armored.
|
|
146
|
+
"""
|
|
147
|
+
@property
|
|
148
|
+
def user_ids(self, /) -> list[UserId]:
|
|
149
|
+
"""
|
|
150
|
+
The non-revoked User IDs on this certificate.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
@final
|
|
154
|
+
class CipherSuite:
|
|
155
|
+
"""
|
|
156
|
+
The cipher suite to use when generating keys.
|
|
157
|
+
|
|
158
|
+
Controls which cryptographic algorithms are used for the primary key and subkeys.
|
|
159
|
+
The PQC (post-quantum cryptography) suites require `Profile.RFC9580`.
|
|
160
|
+
"""
|
|
161
|
+
Cv25519: Final[CipherSuite]
|
|
162
|
+
"""
|
|
163
|
+
EdDSA and ECDH over Curve25519 (default)
|
|
164
|
+
"""
|
|
165
|
+
Cv448: Final[CipherSuite]
|
|
166
|
+
"""
|
|
167
|
+
EdDSA and ECDH over Curve448
|
|
168
|
+
"""
|
|
169
|
+
MLDSA65_Ed25519: Final[CipherSuite]
|
|
170
|
+
"""
|
|
171
|
+
Post-quantum: ML-DSA-65 + Ed25519 signing, ML-KEM-768 + X25519 encryption (v6 only)
|
|
172
|
+
"""
|
|
173
|
+
MLDSA87_Ed448: Final[CipherSuite]
|
|
174
|
+
"""
|
|
175
|
+
Post-quantum: ML-DSA-87 + Ed448 signing, ML-KEM-1024 + X448 encryption (v6 only)
|
|
176
|
+
"""
|
|
177
|
+
P256: Final[CipherSuite]
|
|
178
|
+
"""
|
|
179
|
+
ECDSA and ECDH over NIST P-256
|
|
180
|
+
"""
|
|
181
|
+
P384: Final[CipherSuite]
|
|
182
|
+
"""
|
|
183
|
+
ECDSA and ECDH over NIST P-384
|
|
184
|
+
"""
|
|
185
|
+
P521: Final[CipherSuite]
|
|
186
|
+
"""
|
|
187
|
+
ECDSA and ECDH over NIST P-521
|
|
188
|
+
"""
|
|
189
|
+
RSA2k: Final[CipherSuite]
|
|
190
|
+
"""
|
|
191
|
+
2048-bit RSA
|
|
192
|
+
"""
|
|
193
|
+
RSA3k: Final[CipherSuite]
|
|
194
|
+
"""
|
|
195
|
+
3072-bit RSA
|
|
196
|
+
"""
|
|
197
|
+
RSA4k: Final[CipherSuite]
|
|
198
|
+
"""
|
|
199
|
+
4096-bit RSA
|
|
200
|
+
"""
|
|
201
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
202
|
+
def __int__(self, /) -> int: ...
|
|
203
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
204
|
+
def __repr__(self, /) -> str: ...
|
|
205
|
+
|
|
206
|
+
@final
|
|
207
|
+
class Decrypted:
|
|
208
|
+
"""
|
|
209
|
+
The result of a decryption or verification operation.
|
|
210
|
+
|
|
211
|
+
Contains the decrypted/verified content (if available) and any valid signatures found.
|
|
212
|
+
"""
|
|
213
|
+
@property
|
|
214
|
+
def bytes(self, /) -> bytes | None:
|
|
215
|
+
"""
|
|
216
|
+
The decrypted or verified content bytes, or `None` for file-based operations.
|
|
217
|
+
"""
|
|
218
|
+
@property
|
|
219
|
+
def valid_sigs(self, /) -> list[Any]:
|
|
220
|
+
"""
|
|
221
|
+
The list of valid signatures found during verification.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
@final
|
|
225
|
+
class EncryptionAlgorithm:
|
|
226
|
+
"""
|
|
227
|
+
The encryption algorithm to use when generating keys.
|
|
228
|
+
|
|
229
|
+
Used with `Tsk.generate(encryption_algorithm=...)` to override the
|
|
230
|
+
encryption algorithm independently of the cipher suite. Requires
|
|
231
|
+
`Profile.RFC9580` for PQC algorithms (except `MLKEM768_X25519`).
|
|
232
|
+
"""
|
|
233
|
+
MLKEM1024_X448: Final[EncryptionAlgorithm]
|
|
234
|
+
"""
|
|
235
|
+
Composite ML-KEM-1024 + X448 (post-quantum)
|
|
236
|
+
"""
|
|
237
|
+
MLKEM768_X25519: Final[EncryptionAlgorithm]
|
|
238
|
+
"""
|
|
239
|
+
Composite ML-KEM-768 + X25519 (post-quantum)
|
|
240
|
+
"""
|
|
241
|
+
X25519: Final[EncryptionAlgorithm]
|
|
242
|
+
"""
|
|
243
|
+
X25519
|
|
244
|
+
"""
|
|
245
|
+
X448: Final[EncryptionAlgorithm]
|
|
246
|
+
"""
|
|
247
|
+
X448
|
|
248
|
+
"""
|
|
249
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
250
|
+
def __int__(self, /) -> int: ...
|
|
251
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
252
|
+
def __repr__(self, /) -> str: ...
|
|
253
|
+
|
|
254
|
+
@final
|
|
255
|
+
class Notation:
|
|
256
|
+
"""
|
|
257
|
+
A key-value notation attached to an OpenPGP signature.
|
|
258
|
+
"""
|
|
259
|
+
def __new__(cls, /, key: str, value: str) -> Notation:
|
|
260
|
+
"""
|
|
261
|
+
Create a new notation with the given key and value.
|
|
262
|
+
"""
|
|
263
|
+
def __repr__(self, /) -> str: ...
|
|
264
|
+
def __str__(self, /) -> str: ...
|
|
265
|
+
@property
|
|
266
|
+
def key(self, /) -> str:
|
|
267
|
+
"""
|
|
268
|
+
The notation key (name).
|
|
269
|
+
"""
|
|
270
|
+
@property
|
|
271
|
+
def value(self, /) -> str:
|
|
272
|
+
"""
|
|
273
|
+
The notation value.
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
@final
|
|
277
|
+
class Policy:
|
|
278
|
+
"""
|
|
279
|
+
An OpenPGP cryptographic policy.
|
|
280
|
+
|
|
281
|
+
Pass a policy when reading or using certificates, or to `verify`,
|
|
282
|
+
`decrypt`, and `decrypt_file`.
|
|
283
|
+
"""
|
|
284
|
+
def __repr__(self, /) -> str: ...
|
|
285
|
+
@staticmethod
|
|
286
|
+
def default() -> Policy:
|
|
287
|
+
"""
|
|
288
|
+
Create the build's default cryptographic policy.
|
|
289
|
+
"""
|
|
290
|
+
@staticmethod
|
|
291
|
+
def from_sequoia_config_file(path: str | PathLike[str] | None = None) -> Policy:
|
|
292
|
+
"""
|
|
293
|
+
Load a Sequoia policy configuration file.
|
|
294
|
+
|
|
295
|
+
If no path is provided, check the `SEQUOIA_CRYPTO_POLICY` environment variable
|
|
296
|
+
and then the system's Sequoia policy file. Missing or invalid configuration raises
|
|
297
|
+
an exception.
|
|
298
|
+
"""
|
|
299
|
+
|
|
300
|
+
@final
|
|
301
|
+
class Profile:
|
|
302
|
+
"""
|
|
303
|
+
The OpenPGP profile to use when generating certificates.
|
|
304
|
+
|
|
305
|
+
Controls which packet format and algorithms are used.
|
|
306
|
+
"""
|
|
307
|
+
RFC4880: Final[Profile]
|
|
308
|
+
RFC9580: Final[Profile]
|
|
309
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
310
|
+
def __int__(self, /) -> int: ...
|
|
311
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
312
|
+
def __repr__(self, /) -> str: ...
|
|
313
|
+
|
|
314
|
+
@final
|
|
315
|
+
class PyDecryptor:
|
|
316
|
+
"""
|
|
317
|
+
A decryption helper that holds the key material needed to decrypt messages.
|
|
318
|
+
|
|
319
|
+
Obtain a `PyDecryptor` via `Tsk.decryptor()`.
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
@final
|
|
323
|
+
class PySigner:
|
|
324
|
+
"""
|
|
325
|
+
A handle to a signing key, used for creating signatures, certifications, and revocations.
|
|
326
|
+
|
|
327
|
+
Obtain a `PySigner` via `Tsk.signer()` or `Tsk.certifier()`.
|
|
328
|
+
"""
|
|
329
|
+
|
|
330
|
+
@final
|
|
331
|
+
class Sig:
|
|
332
|
+
"""
|
|
333
|
+
A detached OpenPGP signature.
|
|
334
|
+
"""
|
|
335
|
+
def __bytes__(self, /) -> bytes:
|
|
336
|
+
"""
|
|
337
|
+
Returns the raw binary encoding of the signature packet.
|
|
338
|
+
"""
|
|
339
|
+
def __repr__(self, /) -> str: ...
|
|
340
|
+
def __str__(self, /) -> str:
|
|
341
|
+
"""
|
|
342
|
+
Return the ASCII-armored representation of the signature.
|
|
343
|
+
"""
|
|
344
|
+
@property
|
|
345
|
+
def created(self, /) -> datetime | None:
|
|
346
|
+
"""
|
|
347
|
+
The time at which this signature was created.
|
|
348
|
+
|
|
349
|
+
Returns `None` if the signature does not carry a creation time subpacket.
|
|
350
|
+
"""
|
|
351
|
+
@property
|
|
352
|
+
def expiration(self, /) -> datetime | None:
|
|
353
|
+
"""
|
|
354
|
+
The time at which this signature expires, or `None` if it does not expire.
|
|
355
|
+
|
|
356
|
+
Returns `None` if either subpacket is absent.
|
|
357
|
+
"""
|
|
358
|
+
@staticmethod
|
|
359
|
+
def from_bytes(bytes: bytes) -> Sig:
|
|
360
|
+
"""
|
|
361
|
+
Loads a signature from a byte string.
|
|
362
|
+
|
|
363
|
+
The bytes may be binary or ASCII-armored.
|
|
364
|
+
"""
|
|
365
|
+
@staticmethod
|
|
366
|
+
def from_file(path: str) -> Sig:
|
|
367
|
+
"""
|
|
368
|
+
Loads a signature from a file on disk.
|
|
369
|
+
|
|
370
|
+
The file may be binary or ASCII-armored.
|
|
371
|
+
"""
|
|
372
|
+
@property
|
|
373
|
+
def hash_algorithm(self, /) -> HashAlgorithm:
|
|
374
|
+
"""
|
|
375
|
+
The hash algorithm used by this signature.
|
|
376
|
+
"""
|
|
377
|
+
@property
|
|
378
|
+
def issuer_fingerprint(self, /) -> str | None:
|
|
379
|
+
"""
|
|
380
|
+
The fingerprint of the key that made this signature, as a lowercase hex string.
|
|
381
|
+
|
|
382
|
+
Returns `None` if the signature does not carry an issuer fingerprint subpacket.
|
|
383
|
+
"""
|
|
384
|
+
@property
|
|
385
|
+
def issuer_fpr(self, /) -> str | None:
|
|
386
|
+
"""
|
|
387
|
+
DEPRECATED: The fingerprint of the key that made this signature, as a lowercase hex string.
|
|
388
|
+
|
|
389
|
+
Alias for `issuer_fingerprint`. Prefer `issuer_fingerprint` going forwards.
|
|
390
|
+
|
|
391
|
+
Returns `None` if the signature does not carry an issuer fingerprint subpacket.
|
|
392
|
+
Prefer this over `issuer_key_id` when available, as fingerprints are collision-resistant.
|
|
393
|
+
"""
|
|
394
|
+
@property
|
|
395
|
+
def issuer_key_id(self, /) -> str | None:
|
|
396
|
+
"""
|
|
397
|
+
The short key ID of the key that made this signature, as a lowercase hex string.
|
|
398
|
+
|
|
399
|
+
Returns `None` if the signature does not carry an issuer key ID subpacket.
|
|
400
|
+
Prefer `issuer_fingerprint` over this where possible, as key IDs are not collision-resistant.
|
|
401
|
+
"""
|
|
402
|
+
@property
|
|
403
|
+
def key_algorithm(self, /) -> PublicKeyAlgorithm:
|
|
404
|
+
"""
|
|
405
|
+
The public key algorithm used by this signature.
|
|
406
|
+
"""
|
|
407
|
+
@property
|
|
408
|
+
def key_validity_period(self, /) -> timedelta | None:
|
|
409
|
+
"""
|
|
410
|
+
The key validity period as a timedelta from key creation.
|
|
411
|
+
|
|
412
|
+
This is the duration after the key's creation time at which the key expires.
|
|
413
|
+
Found in Subkey Binding and Direct Key signatures.
|
|
414
|
+
Returns `None` if the subpacket is not present.
|
|
415
|
+
"""
|
|
416
|
+
@property
|
|
417
|
+
def signature_type(self, /) -> SignatureType:
|
|
418
|
+
"""
|
|
419
|
+
The signature type (e.g. `SignatureType.SubkeyBinding`).
|
|
420
|
+
"""
|
|
421
|
+
@property
|
|
422
|
+
def signers_user_id(self, /) -> str | None:
|
|
423
|
+
"""
|
|
424
|
+
The User ID of the signer, as declared in the signature's Signer's User ID subpacket.
|
|
425
|
+
|
|
426
|
+
Returns `None` if the signature does not carry a Signer's User ID subpacket.
|
|
427
|
+
Note that this value is self-reported by the signer and is not verified against any cert.
|
|
428
|
+
"""
|
|
429
|
+
@property
|
|
430
|
+
def version(self, /) -> int:
|
|
431
|
+
"""
|
|
432
|
+
The version of this signature packet (e.g. 4 or 6).
|
|
433
|
+
"""
|
|
434
|
+
|
|
435
|
+
@final
|
|
436
|
+
class SignatureMode:
|
|
437
|
+
"""
|
|
438
|
+
The mode of signature to produce.
|
|
439
|
+
"""
|
|
440
|
+
CLEAR: Final[SignatureMode]
|
|
441
|
+
DETACHED: Final[SignatureMode]
|
|
442
|
+
INLINE: Final[SignatureMode]
|
|
443
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
444
|
+
def __int__(self, /) -> int: ...
|
|
445
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
446
|
+
def __repr__(self, /) -> str: ...
|
|
447
|
+
|
|
448
|
+
@final
|
|
449
|
+
class SigningAlgorithm:
|
|
450
|
+
"""
|
|
451
|
+
The signing algorithm to use when generating keys.
|
|
452
|
+
|
|
453
|
+
Used with `Cert.generate(signing_algorithm=...)` to override the signing
|
|
454
|
+
algorithm independently of the cipher suite. Requires `Profile.RFC9580`
|
|
455
|
+
for PQC algorithms.
|
|
456
|
+
"""
|
|
457
|
+
Ed25519: Final[SigningAlgorithm]
|
|
458
|
+
"""
|
|
459
|
+
Ed25519
|
|
460
|
+
"""
|
|
461
|
+
Ed448: Final[SigningAlgorithm]
|
|
462
|
+
"""
|
|
463
|
+
Ed448
|
|
464
|
+
"""
|
|
465
|
+
MLDSA65_Ed25519: Final[SigningAlgorithm]
|
|
466
|
+
"""
|
|
467
|
+
Composite ML-DSA-65 + Ed25519 (post-quantum)
|
|
468
|
+
"""
|
|
469
|
+
MLDSA87_Ed448: Final[SigningAlgorithm]
|
|
470
|
+
"""
|
|
471
|
+
Composite ML-DSA-87 + Ed448 (post-quantum)
|
|
472
|
+
"""
|
|
473
|
+
SLHDSA128f: Final[SigningAlgorithm]
|
|
474
|
+
"""
|
|
475
|
+
SLH-DSA 128-bit fast signatures (post-quantum, stateless)
|
|
476
|
+
"""
|
|
477
|
+
SLHDSA128s: Final[SigningAlgorithm]
|
|
478
|
+
"""
|
|
479
|
+
SLH-DSA 128-bit small signatures (post-quantum, stateless)
|
|
480
|
+
"""
|
|
481
|
+
SLHDSA256s: Final[SigningAlgorithm]
|
|
482
|
+
"""
|
|
483
|
+
SLH-DSA 256-bit small signatures (post-quantum, stateless)
|
|
484
|
+
"""
|
|
485
|
+
def __eq__(self, value: object, /) -> bool: ...
|
|
486
|
+
def __int__(self, /) -> int: ...
|
|
487
|
+
def __ne__(self, value: object, /) -> bool: ...
|
|
488
|
+
def __repr__(self, /) -> str: ...
|
|
489
|
+
|
|
490
|
+
@final
|
|
491
|
+
class Tsk:
|
|
492
|
+
"""
|
|
493
|
+
A certificate that contains secret key material.
|
|
494
|
+
|
|
495
|
+
Provides access to signing, certification, and decryption operations
|
|
496
|
+
that require private keys.
|
|
497
|
+
"""
|
|
498
|
+
def __bytes__(self, /) -> bytes:
|
|
499
|
+
"""
|
|
500
|
+
Return the raw binary encoding of this certificate.
|
|
501
|
+
"""
|
|
502
|
+
def __repr__(self, /) -> str: ...
|
|
503
|
+
def __str__(self, /) -> str:
|
|
504
|
+
"""
|
|
505
|
+
Return the ASCII-armored secret key representation (Transferable Secret Key).
|
|
506
|
+
"""
|
|
507
|
+
def certifier(self, /, password: str | None = None) -> PySigner:
|
|
508
|
+
"""
|
|
509
|
+
Get a certifier using this certificate's certification-capable primary key.
|
|
510
|
+
|
|
511
|
+
If the secret key is password-protected, provide the password to decrypt it.
|
|
512
|
+
"""
|
|
513
|
+
def decryptor(self, /, password: str | None = None) -> PyDecryptor:
|
|
514
|
+
"""
|
|
515
|
+
Get a decryptor using this certificate's encryption component key.
|
|
516
|
+
|
|
517
|
+
If the secret key is password-protected, provide the password to decrypt it.
|
|
518
|
+
"""
|
|
519
|
+
def extract_certificate(self, /) -> Cert:
|
|
520
|
+
"""
|
|
521
|
+
Extracts public parts of this TSK.
|
|
522
|
+
"""
|
|
523
|
+
@staticmethod
|
|
524
|
+
def from_bytes(bytes: bytes, policy: Policy | None = None) -> Tsk:
|
|
525
|
+
"""
|
|
526
|
+
Parse a certificate from a byte string.
|
|
527
|
+
|
|
528
|
+
The bytes may be binary or ASCII-armored.
|
|
529
|
+
"""
|
|
530
|
+
@staticmethod
|
|
531
|
+
def from_file(path: str, policy: Policy | None = None) -> Tsk:
|
|
532
|
+
"""
|
|
533
|
+
Parse a certificate from a file on disk.
|
|
534
|
+
|
|
535
|
+
The file may be binary or ASCII-armored.
|
|
536
|
+
"""
|
|
537
|
+
@staticmethod
|
|
538
|
+
def from_packets(packets: SupportsGetItem[int, Packet], policy: Policy | None = None) -> Tsk:
|
|
539
|
+
"""
|
|
540
|
+
Build a certificate from a sequence of OpenPGP packets.
|
|
541
|
+
|
|
542
|
+
The packets must form a valid certificate (a primary key followed by
|
|
543
|
+
its associated user IDs, user attributes, subkeys, and signatures).
|
|
544
|
+
"""
|
|
545
|
+
@staticmethod
|
|
546
|
+
def generate(user_id: str | None = None, user_ids: SupportsGetItem[int, str] | None = None, profile: Profile | None = None, cipher_suite: CipherSuite | None = None, validity_seconds: SupportsIndex | None = None, *, signing_algorithm: SigningAlgorithm | None = None, encryption_algorithm: EncryptionAlgorithm | None = None, policy: Policy | None = None) -> Tsk:
|
|
547
|
+
"""
|
|
548
|
+
Generate a new TSK with a certification-capable primary key,
|
|
549
|
+
a signing subkey, and an encryption subkey.
|
|
550
|
+
|
|
551
|
+
The generated certificate does not expire unless explicitly instructed.
|
|
552
|
+
"""
|
|
553
|
+
def signer(self, /, password: str | None = None) -> PySigner:
|
|
554
|
+
"""
|
|
555
|
+
Get a signer using this certificate's signing component key.
|
|
556
|
+
|
|
557
|
+
If the secret key is password-protected, provide the password to decrypt it.
|
|
558
|
+
"""
|
|
559
|
+
@staticmethod
|
|
560
|
+
def split_bytes(bytes: bytes, policy: Policy | None = None) -> list[Tsk]:
|
|
561
|
+
"""
|
|
562
|
+
Parse multiple certificates with secret key material from a byte string.
|
|
563
|
+
|
|
564
|
+
Returns all certificates found in the data, retaining their secret key
|
|
565
|
+
material. The bytes may be binary or ASCII-armored.
|
|
566
|
+
"""
|
|
567
|
+
|
|
568
|
+
@final
|
|
569
|
+
class UserId:
|
|
570
|
+
"""
|
|
571
|
+
A User ID component of an OpenPGP certificate (e.g. `"Alice <alice@example.com>"`).
|
|
572
|
+
"""
|
|
573
|
+
def __repr__(self, /) -> str: ...
|
|
574
|
+
def __str__(self, /) -> str:
|
|
575
|
+
"""
|
|
576
|
+
Return the User ID string value.
|
|
577
|
+
"""
|
|
578
|
+
@property
|
|
579
|
+
def notations(self, /) -> list[Notation]:
|
|
580
|
+
"""
|
|
581
|
+
The human-readable notations from this User ID's binding signature.
|
|
582
|
+
"""
|
|
583
|
+
|
|
584
|
+
def armor(data: bytes, kind: ArmorKind) -> str:
|
|
585
|
+
"""
|
|
586
|
+
Wrap raw OpenPGP data in ASCII armor.
|
|
587
|
+
|
|
588
|
+
Takes raw binary OpenPGP data and an `ArmorKind` specifying the armor
|
|
589
|
+
header type, and returns the ASCII-armored string.
|
|
590
|
+
"""
|
|
591
|
+
|
|
592
|
+
def decrypt(bytes: bytes, decryptor: PyDecryptor | None = None, store: Any | None = None, passwords: SupportsGetItem[int, str] = ..., policy: Policy | None = None) -> Decrypted:
|
|
593
|
+
"""
|
|
594
|
+
Decrypt an OpenPGP message from bytes.
|
|
595
|
+
|
|
596
|
+
Provide either a `decryptor` (from a secret key) or `passwords` for password-based decryption.
|
|
597
|
+
Optionally provide a `store` callback for signature verification during decryption.
|
|
598
|
+
"""
|
|
599
|
+
|
|
600
|
+
def decrypt_file(input: str | PathLike[str], output: str | PathLike[str], decryptor: PyDecryptor | None = None, store: Any | None = None, passwords: SupportsGetItem[int, str] = ..., policy: Policy | None = None) -> Decrypted:
|
|
601
|
+
"""
|
|
602
|
+
Decrypt an OpenPGP message from a file, writing the plaintext to another file.
|
|
603
|
+
|
|
604
|
+
Provide either a `decryptor` (from a secret key) or `passwords` for password-based decryption.
|
|
605
|
+
Optionally provide a `store` callback for signature verification during decryption.
|
|
606
|
+
"""
|
|
607
|
+
|
|
608
|
+
def encrypt(bytes: bytes, recipients: SupportsGetItem[int, Cert] = ..., signer: PySigner | None = None, passwords: SupportsGetItem[int, str] = ..., *, armor: bool = True) -> bytes:
|
|
609
|
+
"""
|
|
610
|
+
Encrypt data for the given recipients and/or passwords.
|
|
611
|
+
|
|
612
|
+
Optionally sign the message with the given `signer`.
|
|
613
|
+
Set `armor=False` to produce binary output instead of ASCII-armored.
|
|
614
|
+
"""
|
|
615
|
+
|
|
616
|
+
def encrypt_file(input: str | PathLike[str], output: str | PathLike[str], recipients: SupportsGetItem[int, Cert] = ..., signer: PySigner | None = None, passwords: SupportsGetItem[int, str] = ..., *, armor: bool = True) -> None:
|
|
617
|
+
"""
|
|
618
|
+
Encrypt a file for the given recipients and/or passwords, writing to an output file.
|
|
619
|
+
|
|
620
|
+
Optionally sign the message with the given `signer`.
|
|
621
|
+
Set `armor=False` to produce binary output instead of ASCII-armored.
|
|
622
|
+
"""
|
|
623
|
+
|
|
624
|
+
def sign(signer: PySigner, bytes: bytes, *, mode: SignatureMode = ..., armor: bool = True) -> bytes:
|
|
625
|
+
"""
|
|
626
|
+
Sign data with the given signer.
|
|
627
|
+
|
|
628
|
+
The `mode` controls whether the signature is inline (the default), detached, or cleartext.
|
|
629
|
+
Set `armor=False` to produce binary output instead of ASCII-armored.
|
|
630
|
+
"""
|
|
631
|
+
|
|
632
|
+
def sign_file(signer: PySigner, input: str | PathLike[str], output: str | PathLike[str], *, mode: SignatureMode = ..., armor: bool = True) -> None:
|
|
633
|
+
"""
|
|
634
|
+
Sign a file with the given signer, writing the result to an output file.
|
|
635
|
+
|
|
636
|
+
The `mode` controls whether the signature is inline (the default), detached, or cleartext.
|
|
637
|
+
Set `armor=False` to produce binary output instead of ASCII-armored.
|
|
638
|
+
"""
|
|
639
|
+
|
|
640
|
+
def verify(bytes: bytes | None = None, store: Any | None = None, file: str | PathLike[str] | None = None, signature: Sig | None = None, policy: Policy | None = None) -> Decrypted:
|
|
641
|
+
"""
|
|
642
|
+
Verify an OpenPGP signature.
|
|
643
|
+
|
|
644
|
+
Provide either `bytes` or `file` as the signed data source. The `store` callback
|
|
645
|
+
is called with a list of key ID strings and must return a list of `Cert` objects.
|
|
646
|
+
For detached signature verification, pass a `Sig` object as `signature`.
|
|
647
|
+
"""
|
|
648
|
+
|
|
649
|
+
def __getattr__(name: str) -> Incomplete: ...
|