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 annotations 
    6 
    7import typing 
    8 
    9from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions 
    10 
    11if typing.TYPE_CHECKING: 
    12    from cryptography.hazmat.bindings._rust import openssl as rust_openssl 
    13 
    14_Reasons = rust_exceptions._Reasons 
    15 
    16 
    17class UnsupportedAlgorithm(Exception): 
    18    def __init__(self, message: str, reason: _Reasons | None = None) -> None: 
    19        super().__init__(message) 
    20        self._reason = reason 
    21 
    22 
    23class AlreadyFinalized(Exception): 
    24    pass 
    25 
    26 
    27class AlreadyUpdated(Exception): 
    28    pass 
    29 
    30 
    31class NotYetFinalized(Exception): 
    32    pass 
    33 
    34 
    35class InvalidTag(Exception): 
    36    pass 
    37 
    38 
    39class InvalidSignature(Exception): 
    40    pass 
    41 
    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_code 
    49 
    50 
    51class InvalidKey(Exception): 
    52    pass