Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py: 64%
58 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
8def cryptography_has_set_cert_cb() -> list[str]:
9 return [
10 "SSL_CTX_set_cert_cb",
11 "SSL_set_cert_cb",
12 ]
15def cryptography_has_ssl_st() -> list[str]:
16 return [
17 "SSL_ST_BEFORE",
18 "SSL_ST_OK",
19 "SSL_ST_INIT",
20 "SSL_ST_RENEGOTIATE",
21 ]
24def cryptography_has_tls_st() -> list[str]:
25 return [
26 "TLS_ST_BEFORE",
27 "TLS_ST_OK",
28 ]
31def cryptography_has_evp_pkey_dhx() -> list[str]:
32 return [
33 "EVP_PKEY_DHX",
34 ]
37def cryptography_has_mem_functions() -> list[str]:
38 return [
39 "Cryptography_CRYPTO_set_mem_functions",
40 ]
43def cryptography_has_x509_store_ctx_get_issuer() -> list[str]:
44 return [
45 "X509_STORE_set_get_issuer",
46 ]
49def cryptography_has_ed448() -> list[str]:
50 return [
51 "EVP_PKEY_ED448",
52 ]
55def cryptography_has_ssl_sigalgs() -> list[str]:
56 return [
57 "SSL_CTX_set1_sigalgs_list",
58 ]
61def cryptography_has_psk() -> list[str]:
62 return [
63 "SSL_CTX_use_psk_identity_hint",
64 "SSL_CTX_set_psk_server_callback",
65 "SSL_CTX_set_psk_client_callback",
66 ]
69def cryptography_has_psk_tlsv13() -> list[str]:
70 return [
71 "SSL_CTX_set_psk_find_session_callback",
72 "SSL_CTX_set_psk_use_session_callback",
73 "Cryptography_SSL_SESSION_new",
74 "SSL_CIPHER_find",
75 "SSL_SESSION_set1_master_key",
76 "SSL_SESSION_set_cipher",
77 "SSL_SESSION_set_protocol_version",
78 ]
81def cryptography_has_custom_ext() -> list[str]:
82 return [
83 "SSL_CTX_add_client_custom_ext",
84 "SSL_CTX_add_server_custom_ext",
85 "SSL_extension_supported",
86 ]
89def cryptography_has_tlsv13_functions() -> list[str]:
90 return [
91 "SSL_VERIFY_POST_HANDSHAKE",
92 "SSL_CTX_set_ciphersuites",
93 "SSL_verify_client_post_handshake",
94 "SSL_CTX_set_post_handshake_auth",
95 "SSL_set_post_handshake_auth",
96 "SSL_SESSION_get_max_early_data",
97 "SSL_write_early_data",
98 "SSL_read_early_data",
99 "SSL_CTX_set_max_early_data",
100 ]
103def cryptography_has_engine() -> list[str]:
104 return [
105 "ENGINE_by_id",
106 "ENGINE_init",
107 "ENGINE_finish",
108 "ENGINE_get_default_RAND",
109 "ENGINE_set_default_RAND",
110 "ENGINE_unregister_RAND",
111 "ENGINE_ctrl_cmd",
112 "ENGINE_free",
113 "ENGINE_get_name",
114 "ENGINE_ctrl_cmd_string",
115 "ENGINE_load_builtin_engines",
116 "ENGINE_load_private_key",
117 "ENGINE_load_public_key",
118 "SSL_CTX_set_client_cert_engine",
119 ]
122def cryptography_has_verified_chain() -> list[str]:
123 return [
124 "SSL_get0_verified_chain",
125 ]
128def cryptography_has_srtp() -> list[str]:
129 return [
130 "SSL_CTX_set_tlsext_use_srtp",
131 "SSL_set_tlsext_use_srtp",
132 "SSL_get_selected_srtp_profile",
133 ]
136def cryptography_has_providers() -> list[str]:
137 return [
138 "OSSL_PROVIDER_load",
139 "OSSL_PROVIDER_unload",
140 "ERR_LIB_PROV",
141 "PROV_R_WRONG_FINAL_BLOCK_LENGTH",
142 "PROV_R_BAD_DECRYPT",
143 ]
146def cryptography_has_op_no_renegotiation() -> list[str]:
147 return [
148 "SSL_OP_NO_RENEGOTIATION",
149 ]
152def cryptography_has_dtls_get_data_mtu() -> list[str]:
153 return [
154 "DTLS_get_data_mtu",
155 ]
158def cryptography_has_300_fips() -> list[str]:
159 return [
160 "EVP_default_properties_enable_fips",
161 ]
164def cryptography_has_ssl_cookie() -> list[str]:
165 return [
166 "SSL_OP_COOKIE_EXCHANGE",
167 "DTLSv1_listen",
168 "SSL_CTX_set_cookie_generate_cb",
169 "SSL_CTX_set_cookie_verify_cb",
170 ]
173def cryptography_has_pkcs7_funcs() -> list[str]:
174 return [
175 "PKCS7_verify",
176 "SMIME_read_PKCS7",
177 ]
180def cryptography_has_prime_checks() -> list[str]:
181 return [
182 "BN_prime_checks_for_size",
183 ]
186def cryptography_has_300_evp_cipher() -> list[str]:
187 return ["EVP_CIPHER_fetch", "EVP_CIPHER_free"]
190def cryptography_has_unexpected_eof_while_reading() -> list[str]:
191 return ["SSL_R_UNEXPECTED_EOF_WHILE_READING"]
194def cryptography_has_pkcs12_set_mac() -> list[str]:
195 return ["PKCS12_set_mac"]
198def cryptography_has_ssl_op_ignore_unexpected_eof() -> list[str]:
199 return [
200 "SSL_OP_IGNORE_UNEXPECTED_EOF",
201 ]
204def cryptography_has_get_extms_support() -> list[str]:
205 return ["SSL_get_extms_support"]
208def cryptography_has_evp_aead() -> list[str]:
209 return [
210 "EVP_aead_chacha20_poly1305",
211 "EVP_AEAD_CTX_free",
212 "EVP_AEAD_CTX_seal",
213 "EVP_AEAD_CTX_open",
214 "EVP_AEAD_max_overhead",
215 "Cryptography_EVP_AEAD_CTX_new",
216 ]
219# This is a mapping of
220# {condition: function-returning-names-dependent-on-that-condition} so we can
221# loop over them and delete unsupported names at runtime. It will be removed
222# when cffi supports #if in cdef. We use functions instead of just a dict of
223# lists so we can use coverage to measure which are used.
224CONDITIONAL_NAMES = {
225 "Cryptography_HAS_SET_CERT_CB": cryptography_has_set_cert_cb,
226 "Cryptography_HAS_SSL_ST": cryptography_has_ssl_st,
227 "Cryptography_HAS_TLS_ST": cryptography_has_tls_st,
228 "Cryptography_HAS_EVP_PKEY_DHX": cryptography_has_evp_pkey_dhx,
229 "Cryptography_HAS_MEM_FUNCTIONS": cryptography_has_mem_functions,
230 "Cryptography_HAS_X509_STORE_CTX_GET_ISSUER": (
231 cryptography_has_x509_store_ctx_get_issuer
232 ),
233 "Cryptography_HAS_ED448": cryptography_has_ed448,
234 "Cryptography_HAS_SIGALGS": cryptography_has_ssl_sigalgs,
235 "Cryptography_HAS_PSK": cryptography_has_psk,
236 "Cryptography_HAS_PSK_TLSv1_3": cryptography_has_psk_tlsv13,
237 "Cryptography_HAS_CUSTOM_EXT": cryptography_has_custom_ext,
238 "Cryptography_HAS_TLSv1_3_FUNCTIONS": cryptography_has_tlsv13_functions,
239 "Cryptography_HAS_ENGINE": cryptography_has_engine,
240 "Cryptography_HAS_VERIFIED_CHAIN": cryptography_has_verified_chain,
241 "Cryptography_HAS_SRTP": cryptography_has_srtp,
242 "Cryptography_HAS_PROVIDERS": cryptography_has_providers,
243 "Cryptography_HAS_OP_NO_RENEGOTIATION": (
244 cryptography_has_op_no_renegotiation
245 ),
246 "Cryptography_HAS_DTLS_GET_DATA_MTU": cryptography_has_dtls_get_data_mtu,
247 "Cryptography_HAS_300_FIPS": cryptography_has_300_fips,
248 "Cryptography_HAS_SSL_COOKIE": cryptography_has_ssl_cookie,
249 "Cryptography_HAS_PKCS7_FUNCS": cryptography_has_pkcs7_funcs,
250 "Cryptography_HAS_PRIME_CHECKS": cryptography_has_prime_checks,
251 "Cryptography_HAS_300_EVP_CIPHER": cryptography_has_300_evp_cipher,
252 "Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING": (
253 cryptography_has_unexpected_eof_while_reading
254 ),
255 "Cryptography_HAS_PKCS12_SET_MAC": cryptography_has_pkcs12_set_mac,
256 "Cryptography_HAS_SSL_OP_IGNORE_UNEXPECTED_EOF": (
257 cryptography_has_ssl_op_ignore_unexpected_eof
258 ),
259 "Cryptography_HAS_GET_EXTMS_SUPPORT": cryptography_has_get_extms_support,
260 "Cryptography_HAS_EVP_AEAD": cryptography_has_evp_aead,
261}