Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/hazmat/primitives/asymmetric/types.py: 100%
19 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:05 +0000
« 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.
5from __future__ import annotations
7import typing
9from cryptography import utils
10from cryptography.hazmat.primitives.asymmetric import (
11 dh,
12 dsa,
13 ec,
14 ed448,
15 ed25519,
16 rsa,
17 x448,
18 x25519,
19)
21# Every asymmetric key type
22PublicKeyTypes = typing.Union[
23 dh.DHPublicKey,
24 dsa.DSAPublicKey,
25 rsa.RSAPublicKey,
26 ec.EllipticCurvePublicKey,
27 ed25519.Ed25519PublicKey,
28 ed448.Ed448PublicKey,
29 x25519.X25519PublicKey,
30 x448.X448PublicKey,
31]
32PUBLIC_KEY_TYPES = PublicKeyTypes
33utils.deprecated(
34 PUBLIC_KEY_TYPES,
35 __name__,
36 "Use PublicKeyTypes instead",
37 utils.DeprecatedIn40,
38 name="PUBLIC_KEY_TYPES",
39)
40# Every asymmetric key type
41PrivateKeyTypes = typing.Union[
42 dh.DHPrivateKey,
43 ed25519.Ed25519PrivateKey,
44 ed448.Ed448PrivateKey,
45 rsa.RSAPrivateKey,
46 dsa.DSAPrivateKey,
47 ec.EllipticCurvePrivateKey,
48 x25519.X25519PrivateKey,
49 x448.X448PrivateKey,
50]
51PRIVATE_KEY_TYPES = PrivateKeyTypes
52utils.deprecated(
53 PRIVATE_KEY_TYPES,
54 __name__,
55 "Use PrivateKeyTypes instead",
56 utils.DeprecatedIn40,
57 name="PRIVATE_KEY_TYPES",
58)
59# Just the key types we allow to be used for x509 signing. This mirrors
60# the certificate public key types
61CertificateIssuerPrivateKeyTypes = typing.Union[
62 ed25519.Ed25519PrivateKey,
63 ed448.Ed448PrivateKey,
64 rsa.RSAPrivateKey,
65 dsa.DSAPrivateKey,
66 ec.EllipticCurvePrivateKey,
67]
68CERTIFICATE_PRIVATE_KEY_TYPES = CertificateIssuerPrivateKeyTypes
69utils.deprecated(
70 CERTIFICATE_PRIVATE_KEY_TYPES,
71 __name__,
72 "Use CertificateIssuerPrivateKeyTypes instead",
73 utils.DeprecatedIn40,
74 name="CERTIFICATE_PRIVATE_KEY_TYPES",
75)
76# Just the key types we allow to be used for x509 signing. This mirrors
77# the certificate private key types
78CertificateIssuerPublicKeyTypes = typing.Union[
79 dsa.DSAPublicKey,
80 rsa.RSAPublicKey,
81 ec.EllipticCurvePublicKey,
82 ed25519.Ed25519PublicKey,
83 ed448.Ed448PublicKey,
84]
85CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES = CertificateIssuerPublicKeyTypes
86utils.deprecated(
87 CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES,
88 __name__,
89 "Use CertificateIssuerPublicKeyTypes instead",
90 utils.DeprecatedIn40,
91 name="CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES",
92)
93# This type removes DHPublicKey. x448/x25519 can be a public key
94# but cannot be used in signing so they are allowed here.
95CertificatePublicKeyTypes = typing.Union[
96 dsa.DSAPublicKey,
97 rsa.RSAPublicKey,
98 ec.EllipticCurvePublicKey,
99 ed25519.Ed25519PublicKey,
100 ed448.Ed448PublicKey,
101 x25519.X25519PublicKey,
102 x448.X448PublicKey,
103]
104CERTIFICATE_PUBLIC_KEY_TYPES = CertificatePublicKeyTypes
105utils.deprecated(
106 CERTIFICATE_PUBLIC_KEY_TYPES,
107 __name__,
108 "Use CertificatePublicKeyTypes instead",
109 utils.DeprecatedIn40,
110 name="CERTIFICATE_PUBLIC_KEY_TYPES",
111)