Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/hazmat/primitives/serialization/base.py: 52%
21 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 07:26 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 07:26 +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.
5from __future__ import annotations
7import typing
9from cryptography.hazmat.bindings._rust import openssl as rust_openssl
10from cryptography.hazmat.primitives.asymmetric import dh
11from cryptography.hazmat.primitives.asymmetric.types import (
12 PrivateKeyTypes,
13 PublicKeyTypes,
14)
17def load_pem_private_key(
18 data: bytes,
19 password: bytes | None,
20 backend: typing.Any = None,
21 *,
22 unsafe_skip_rsa_key_validation: bool = False,
23) -> PrivateKeyTypes:
24 from cryptography.hazmat.backends.openssl.backend import backend as ossl
26 return ossl.load_pem_private_key(
27 data, password, unsafe_skip_rsa_key_validation
28 )
31def load_pem_public_key(
32 data: bytes, backend: typing.Any = None
33) -> PublicKeyTypes:
34 from cryptography.hazmat.backends.openssl.backend import backend as ossl
36 return ossl.load_pem_public_key(data)
39def load_pem_parameters(
40 data: bytes, backend: typing.Any = None
41) -> dh.DHParameters:
42 return rust_openssl.dh.from_pem_parameters(data)
45def load_der_private_key(
46 data: bytes,
47 password: bytes | None,
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 return rust_openssl.dh.from_der_parameters(data)