Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/Crypto/__init__.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3from typing import Union
5__all__ = [
6 "Cipher",
7 "Hash",
8 "Protocol",
9 "PublicKey",
10 "Util",
11 "Signature",
12 "IO",
13 "Math",
14 "PassphraseRequiredError",
15 "IncorrectPassphraseError",
16 "MessageTooLongError",
17 "KdfLimitError",
18 "KdfIterationLimitError",
19 "KdfMemoryLimitError",
20]
22version_info: tuple[int, int, Union[int, str]] = (4, 0, "1")
24__version__: str = ".".join([str(x) for x in version_info])
27class PassphraseRequiredError(ValueError):
28 """The data (for instance, a private key) is encrypted,
29 but no passphrase was provided.
31 This is a subclass of ``ValueError``.
32 """
35class IncorrectPassphraseError(ValueError):
36 """The encrypted data (for instance, a private key) could not be
37 decrypted with the passphrase.
39 Most likely, the passphrase is wrong; but the encrypted data might also
40 be corrupted (the two cases cannot be told apart).
42 This is a subclass of ``ValueError``.
43 """
46class MessageTooLongError(ValueError, OverflowError):
47 """The data is longer than a cipher can process with the same key
48 and nonce (for instance, the key stream would repeat).
50 This is a subclass of both ``ValueError`` and ``OverflowError``.
51 """
54class KdfLimitError(ValueError):
55 """Deriving a key from a password or a passphrase would take more time
56 or memory than allowed, as set to protect against malicious data
57 (for instance, an encrypted private key or a password hash that
58 states an extremely high cost).
60 This is a subclass of ``ValueError``.
61 """
64class KdfIterationLimitError(KdfLimitError):
65 """The cost of the key derivation (the iteration count of PBKDF2,
66 the cost of scrypt, or the rounds of bcrypt) is above the limit
67 (for instance, the one set with ``max_iteration_count``).
68 """
71class KdfMemoryLimitError(KdfLimitError):
72 """The key derivation needs more memory than the limit
73 (for instance, the one set with ``max_memory``).
74 """
77_PASSPHRASE_REQUIRED = "The private key is encrypted: a passphrase is required"
78_INCORRECT_PASSPHRASE = "Incorrect passphrase (or the encrypted private key is corrupted)"