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.2.2, created at 2023-03-26 06:36 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:36 +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.
6import typing
8from cryptography.hazmat.primitives.asymmetric import dh
9from cryptography.hazmat.primitives.asymmetric.types import (
10 PrivateKeyTypes,
11 PublicKeyTypes,
12)
15def load_pem_private_key(
16 data: bytes,
17 password: typing.Optional[bytes],
18 backend: typing.Any = None,
19 *,
20 unsafe_skip_rsa_key_validation: bool = False,
21) -> PrivateKeyTypes:
22 from cryptography.hazmat.backends.openssl.backend import backend as ossl
24 return ossl.load_pem_private_key(
25 data, password, unsafe_skip_rsa_key_validation
26 )
29def load_pem_public_key(
30 data: bytes, backend: typing.Any = None
31) -> PublicKeyTypes:
32 from cryptography.hazmat.backends.openssl.backend import backend as ossl
34 return ossl.load_pem_public_key(data)
37def load_pem_parameters(
38 data: bytes, backend: typing.Any = None
39) -> "dh.DHParameters":
40 from cryptography.hazmat.backends.openssl.backend import backend as ossl
42 return ossl.load_pem_parameters(data)
45def load_der_private_key(
46 data: bytes,
47 password: typing.Optional[bytes],
48 backend: typing.Any = None,
49 *,
50 unsafe_skip_rsa_key_validation: bool = False,
51) -> PrivateKeyTypes:
52 from cryptography.hazmat.backends.openssl.backend import backend as ossl
54 return ossl.load_der_private_key(
55 data, password, unsafe_skip_rsa_key_validation
56 )
59def load_der_public_key(
60 data: bytes, backend: typing.Any = None
61) -> PublicKeyTypes:
62 from cryptography.hazmat.backends.openssl.backend import backend as ossl
64 return ossl.load_der_public_key(data)
67def load_der_parameters(
68 data: bytes, backend: typing.Any = None
69) -> "dh.DHParameters":
70 from cryptography.hazmat.backends.openssl.backend import backend as ossl
72 return ossl.load_der_parameters(data)