exceptions.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 cryptography import utils
  5. class _Reasons(utils.Enum):
  6. BACKEND_MISSING_INTERFACE = 0
  7. UNSUPPORTED_HASH = 1
  8. UNSUPPORTED_CIPHER = 2
  9. UNSUPPORTED_PADDING = 3
  10. UNSUPPORTED_MGF = 4
  11. UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
  12. UNSUPPORTED_ELLIPTIC_CURVE = 6
  13. UNSUPPORTED_SERIALIZATION = 7
  14. UNSUPPORTED_X509 = 8
  15. UNSUPPORTED_EXCHANGE_ALGORITHM = 9
  16. UNSUPPORTED_DIFFIE_HELLMAN = 10
  17. UNSUPPORTED_MAC = 11
  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