• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5from __future__ import absolute_import, division, print_function
6
7from enum import Enum
8
9
10class _Reasons(Enum):
11    BACKEND_MISSING_INTERFACE = 0
12    UNSUPPORTED_HASH = 1
13    UNSUPPORTED_CIPHER = 2
14    UNSUPPORTED_PADDING = 3
15    UNSUPPORTED_MGF = 4
16    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
17    UNSUPPORTED_ELLIPTIC_CURVE = 6
18    UNSUPPORTED_SERIALIZATION = 7
19    UNSUPPORTED_X509 = 8
20    UNSUPPORTED_EXCHANGE_ALGORITHM = 9
21    UNSUPPORTED_DIFFIE_HELLMAN = 10
22    UNSUPPORTED_MAC = 11
23
24
25class UnsupportedAlgorithm(Exception):
26    def __init__(self, message, reason=None):
27        super(UnsupportedAlgorithm, self).__init__(message)
28        self._reason = reason
29
30
31class AlreadyFinalized(Exception):
32    pass
33
34
35class AlreadyUpdated(Exception):
36    pass
37
38
39class NotYetFinalized(Exception):
40    pass
41
42
43class InvalidTag(Exception):
44    pass
45
46
47class InvalidSignature(Exception):
48    pass
49
50
51class InternalError(Exception):
52    def __init__(self, msg, err_code):
53        super(InternalError, self).__init__(msg)
54        self.err_code = err_code
55
56
57class InvalidKey(Exception):
58    pass
59