Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/exceptions.py: 86%
37 statements
« prev ^ index » next coverage.py v7.0.1, created at 2022-12-25 06:11 +0000
« prev ^ index » next coverage.py v7.0.1, created at 2022-12-25 06:11 +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.openssl.binding import (
12 _OpenSSLErrorWithText,
13 )
16class _Reasons(utils.Enum):
17 BACKEND_MISSING_INTERFACE = 0
18 UNSUPPORTED_HASH = 1
19 UNSUPPORTED_CIPHER = 2
20 UNSUPPORTED_PADDING = 3
21 UNSUPPORTED_MGF = 4
22 UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
23 UNSUPPORTED_ELLIPTIC_CURVE = 6
24 UNSUPPORTED_SERIALIZATION = 7
25 UNSUPPORTED_X509 = 8
26 UNSUPPORTED_EXCHANGE_ALGORITHM = 9
27 UNSUPPORTED_DIFFIE_HELLMAN = 10
28 UNSUPPORTED_MAC = 11
31class UnsupportedAlgorithm(Exception):
32 def __init__(
33 self, message: str, reason: typing.Optional[_Reasons] = None
34 ) -> None:
35 super(UnsupportedAlgorithm, self).__init__(message)
36 self._reason = reason
39class AlreadyFinalized(Exception):
40 pass
43class AlreadyUpdated(Exception):
44 pass
47class NotYetFinalized(Exception):
48 pass
51class InvalidTag(Exception):
52 pass
55class InvalidSignature(Exception):
56 pass
59class InternalError(Exception):
60 def __init__(
61 self, msg: str, err_code: typing.List["_OpenSSLErrorWithText"]
62 ) -> None:
63 super(InternalError, self).__init__(msg)
64 self.err_code = err_code
67class InvalidKey(Exception):
68 pass