You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB

4 years ago
  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. from __future__ import absolute_import, division, print_function
  5. from enum import Enum
  6. class _Reasons(Enum):
  7. BACKEND_MISSING_INTERFACE = 0
  8. UNSUPPORTED_HASH = 1
  9. UNSUPPORTED_CIPHER = 2
  10. UNSUPPORTED_PADDING = 3
  11. UNSUPPORTED_MGF = 4
  12. UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
  13. UNSUPPORTED_ELLIPTIC_CURVE = 6
  14. UNSUPPORTED_SERIALIZATION = 7
  15. UNSUPPORTED_X509 = 8
  16. UNSUPPORTED_EXCHANGE_ALGORITHM = 9
  17. UNSUPPORTED_DIFFIE_HELLMAN = 10
  18. class UnsupportedAlgorithm(Exception):
  19. def __init__(self, message, reason=None):
  20. super(UnsupportedAlgorithm, self).__init__(message)
  21. self._reason = reason
  22. class AlreadyFinalized(Exception):
  23. pass
  24. class AlreadyUpdated(Exception):
  25. pass
  26. class NotYetFinalized(Exception):
  27. pass
  28. class InvalidTag(Exception):
  29. pass
  30. class InvalidSignature(Exception):
  31. pass
  32. class InternalError(Exception):
  33. def __init__(self, msg, err_code):
  34. super(InternalError, self).__init__(msg)
  35. self.err_code = err_code
  36. class InvalidKey(Exception):
  37. pass