Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/exceptions.py: 86%
37 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:36 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:36 +0000
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.
6import typing
8from cryptography import utils
10if typing.TYPE_CHECKING:
11 from cryptography.hazmat.bindings._rust import openssl as rust_openssl
14class _Reasons(utils.Enum):
15 BACKEND_MISSING_INTERFACE = 0
16 UNSUPPORTED_HASH = 1
17 UNSUPPORTED_CIPHER = 2
18 UNSUPPORTED_PADDING = 3
19 UNSUPPORTED_MGF = 4
20 UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
21 UNSUPPORTED_ELLIPTIC_CURVE = 6
22 UNSUPPORTED_SERIALIZATION = 7
23 UNSUPPORTED_X509 = 8
24 UNSUPPORTED_EXCHANGE_ALGORITHM = 9
25 UNSUPPORTED_DIFFIE_HELLMAN = 10
26 UNSUPPORTED_MAC = 11
29class UnsupportedAlgorithm(Exception):
30 def __init__(
31 self, message: str, reason: typing.Optional[_Reasons] = None
32 ) -> None:
33 super().__init__(message)
34 self._reason = reason
37class AlreadyFinalized(Exception):
38 pass
41class AlreadyUpdated(Exception):
42 pass
45class NotYetFinalized(Exception):
46 pass
49class InvalidTag(Exception):
50 pass
53class InvalidSignature(Exception):
54 pass
57class InternalError(Exception):
58 def __init__(
59 self, msg: str, err_code: typing.List["rust_openssl.OpenSSLError"]
60 ) -> None:
61 super().__init__(msg)
62 self.err_code = err_code
65class InvalidKey(Exception):
66 pass