Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/exceptions.py: 81%

26 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:05 +0000

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__( 

19 self, message: str, reason: typing.Optional[_Reasons] = None 

20 ) -> None: 

21 super().__init__(message) 

22 self._reason = reason 

23 

24 

25class AlreadyFinalized(Exception): 

26 pass 

27 

28 

29class AlreadyUpdated(Exception): 

30 pass 

31 

32 

33class NotYetFinalized(Exception): 

34 pass 

35 

36 

37class InvalidTag(Exception): 

38 pass 

39 

40 

41class InvalidSignature(Exception): 

42 pass 

43 

44 

45class InternalError(Exception): 

46 def __init__( 

47 self, msg: str, err_code: typing.List[rust_openssl.OpenSSLError] 

48 ) -> None: 

49 super().__init__(msg) 

50 self.err_code = err_code 

51 

52 

53class InvalidKey(Exception): 

54 pass