codekingpro/portable-devtools
115k
1# This file is dual licensed under the terms of the Apache License, Version2# 2.0, and the BSD License. See the LICENSE file in the root of this repository3# for complete details.4 5from __future__ import annotations6 7import typing8 9from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions10 11if typing.TYPE_CHECKING:12 from cryptography.hazmat.bindings._rust import openssl as rust_openssl13 14_Reasons = rust_exceptions._Reasons15 16 17class UnsupportedAlgorithm(Exception):18 def __init__(self, message: str, reason: _Reasons | None = None) -> None:19 super().__init__(message)20 self._reason = reason21 22 23class AlreadyFinalized(Exception):24 pass25 26 27class AlreadyUpdated(Exception):28 pass29 30 31class NotYetFinalized(Exception):32 pass33 34 35class InvalidTag(Exception):36 pass37 38 39class InvalidSignature(Exception):40 pass41 42 43class InternalError(Exception):44 def __init__(45 self, msg: str, err_code: list[rust_openssl.OpenSSLError]46 ) -> None:47 super().__init__(msg)48 self.err_code = err_code49 50 51class InvalidKey(Exception):52 pass53 