Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/hazmat/primitives/serialization/base.py: 43%

21 statements  

« prev     ^ index     » next       coverage.py v7.0.1, created at 2022-12-25 06:11 +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 

5 

6import typing 

7 

8from cryptography.hazmat.primitives.asymmetric import dh 

9from cryptography.hazmat.primitives.asymmetric.types import ( 

10 PRIVATE_KEY_TYPES, 

11 PUBLIC_KEY_TYPES, 

12) 

13 

14 

15def load_pem_private_key( 

16 data: bytes, 

17 password: typing.Optional[bytes], 

18 backend: typing.Any = None, 

19) -> PRIVATE_KEY_TYPES: 

20 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

21 

22 return ossl.load_pem_private_key(data, password) 

23 

24 

25def load_pem_public_key( 

26 data: bytes, backend: typing.Any = None 

27) -> PUBLIC_KEY_TYPES: 

28 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

29 

30 return ossl.load_pem_public_key(data) 

31 

32 

33def load_pem_parameters( 

34 data: bytes, backend: typing.Any = None 

35) -> "dh.DHParameters": 

36 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

37 

38 return ossl.load_pem_parameters(data) 

39 

40 

41def load_der_private_key( 

42 data: bytes, 

43 password: typing.Optional[bytes], 

44 backend: typing.Any = None, 

45) -> PRIVATE_KEY_TYPES: 

46 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

47 

48 return ossl.load_der_private_key(data, password) 

49 

50 

51def load_der_public_key( 

52 data: bytes, backend: typing.Any = None 

53) -> PUBLIC_KEY_TYPES: 

54 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

55 

56 return ossl.load_der_public_key(data) 

57 

58 

59def load_der_parameters( 

60 data: bytes, backend: typing.Any = None 

61) -> "dh.DHParameters": 

62 from cryptography.hazmat.backends.openssl.backend import backend as ossl 

63 

64 return ossl.load_der_parameters(data)