GCC Code Coverage Report


Directory: src/gate/
File: src/gate/net/platform/openssl_api.c
Date: 2026-09-21 06:26:40
Exec Total Coverage
Lines: 218 222 98.2%
Functions: 4 4 100.0%
Branches: 14 24 58.3%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/net/platform/openssl_api.h"
30
31
32 #if defined(GATE_NET_SSL_SHAREDLIB)
33
34 struct lib_pair
35 {
36 char const* lib1;
37 char const* lib2;
38 };
39
40 static struct lib_pair ssl_lib_names[] = {
41 #if defined(GATE_SYS_WIN)
42 { "libcrypto-1_1-x64.dll", "libssl-1_1-x64.dll" },
43 { "libcrypto-1_1.dll", "libssl-1_1.dll" },
44 { "libcrypto.dll", "libssl.dll" },
45 { "libeay32.dll", "ssleay32.dll" }
46 #elif defined(GATE_SYS_DARWIN)
47 { "libcrypto.dylib", "libssl.dylib" },
48 #else
49 { "libcrypto.so.1.1", "libssl.so.1.1" },
50 { "libcrypto.so", "libssl.so" },
51 { "libcrypto.so.3", "libssl.so.3" }
52 #endif
53 };
54 static gate_size_t const ssl_lib_names_count = sizeof(ssl_lib_names) / sizeof(ssl_lib_names[0]);
55
56 static gate_result_t load_libssl_libs(gate_library_t* ptr_lib1, gate_library_t* ptr_lib2)
57 {
58 gate_result_t result;
59 gate_size_t ndx;
60 gate_library_t lib1, lib2;
61 gate_string_t libname;
62
63 for (ndx = 0; ndx != ssl_lib_names_count; ++ndx)
64 {
65 gate_string_create_static(&libname, ssl_lib_names[ndx].lib1);
66 result = gate_library_open(&libname, &lib1, GATE_LIBRARY_FLAG_DEFAULT);
67 if (GATE_FAILED(result))
68 {
69 continue;
70 }
71 if (ptr_lib2)
72 {
73 gate_string_create_static(&libname, ssl_lib_names[ndx].lib2);
74 result = gate_library_open(&libname, &lib2, GATE_LIBRARY_FLAG_DEFAULT);
75 if (GATE_FAILED(result))
76 {
77 gate_library_close(lib1);
78 continue;
79 }
80 *ptr_lib2 = lib2;
81 }
82 *ptr_lib1 = lib1;
83 return GATE_RESULT_OK;
84 }
85 return GATE_RESULT_FAILED;
86 }
87
88
89 static gate_result_t load_libssl_function(void* target_ptr, char const* name)
90 {
91 static gate_library_t lib1 = NULL, lib2 = NULL;
92 static gate_bool_t volatile libs_loaded = false;
93 gate_result_t ret;
94
95 do
96 {
97 if (!libs_loaded)
98 {
99 ret = load_libssl_libs(&lib1, &lib2);
100 if (GATE_FAILED(ret))
101 {
102 ret = load_libssl_libs(&lib1, NULL);
103 }
104 GATE_BREAK_IF_FAILED(ret);
105 libs_loaded = true;
106 }
107 ret = gate_library_get_function_name(lib1, name, target_ptr);
108 if (GATE_FAILED(ret) && lib2)
109 {
110 ret = gate_library_get_function_name(lib2, name, target_ptr);
111 }
112 } while (0);
113
114 return ret;
115 }
116
117 # define gate_get_libssl_function(func_ptr, func_name) \
118 ret = load_libssl_function(&func_ptr, #func_name ); \
119 if(GATE_FAILED(ret)) { break; }
120
121 # define gate_get_libssl_function_alt(func_ptr, func_name, alt_func_name) \
122 ret = load_libssl_function(&func_ptr, #func_name ); \
123 if(GATE_FAILED(ret)) { ret = load_libssl_function(&func_ptr, #alt_func_name ); } \
124 if(GATE_FAILED(ret)) { break; }
125
126
127 # define gate_get_libssl_function_optional(func_ptr, func_name) \
128 load_libssl_function(&func_ptr, #func_name )
129
130 #else
131
132 # define gate_get_libssl_function_static(func_ptr, func_name) (func_ptr) = & (func_name)
133 # define gate_get_libssl_function(func_ptr, func_name) gate_get_libssl_function_static(func_ptr, func_name)
134 # define gate_get_libssl_function_optional(func_ptr, func_name) gate_get_libssl_function(func_ptr, func_name)
135 # define gate_get_libssl_function_alt(func_ptr, func_name, alt_func_name) gate_get_libssl_function(func_ptr, func_name)
136
137 #endif
138
139 static gate_libcrypto_api_t glob_libcrypto;
140 static gate_libssl_api_t glob_libssl;
141
142
143 3 static gate_result_t load_libcrypto()
144 {
145 static volatile gate_bool_t libcrypto_loaded = false;
146
147 3 gate_result_t ret = GATE_RESULT_OK;
148
149
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (!libcrypto_loaded)
150 {
151 do
152 {
153 /* crypto functions: */
154
155 1 gate_get_libssl_function_optional(glob_libcrypto.api_OPENSSL_cleanup, OPENSSL_cleanup);
156 1 gate_get_libssl_function_optional(glob_libcrypto.api_OPENSSL_init_crypto, OPENSSL_init_crypto);
157
158 1 gate_get_libssl_function(glob_libcrypto.api_ERR_load_BIO_strings, ERR_load_BIO_strings);
159 1 gate_get_libssl_function(glob_libcrypto.api_ERR_clear_error, ERR_clear_error);
160 1 gate_get_libssl_function(glob_libcrypto.api_ERR_remove_thread_state, ERR_remove_thread_state);
161
162 1 gate_get_libssl_function(glob_libcrypto.api_BIO_s_mem, BIO_s_mem);
163 1 gate_get_libssl_function(glob_libcrypto.api_BIO_new_mem_buf, BIO_new_mem_buf);
164 1 gate_get_libssl_function(glob_libcrypto.api_BIO_new, BIO_new);
165 1 gate_get_libssl_function(glob_libcrypto.api_BIO_new_file, BIO_new_file);
166 1 gate_get_libssl_function(glob_libcrypto.api_BIO_ctrl, BIO_ctrl);
167 1 gate_get_libssl_function(glob_libcrypto.api_BIO_free_all, BIO_free_all);
168 1 gate_get_libssl_function(glob_libcrypto.api_BIO_free, BIO_free);
169 1 gate_get_libssl_function(glob_libcrypto.api_BIO_read, BIO_read);
170 1 gate_get_libssl_function(glob_libcrypto.api_BIO_test_flags, BIO_test_flags);
171 1 gate_get_libssl_function(glob_libcrypto.api_BIO_write, BIO_write);
172 1 gate_get_libssl_function(glob_libcrypto.api_BIO_new_bio_pair, BIO_new_bio_pair);
173
174 1 gate_get_libssl_function(glob_libcrypto.api_DH_new, DH_new);
175 1 gate_get_libssl_function(glob_libcrypto.api_DH_free, DH_free);
176 1 gate_get_libssl_function(glob_libcrypto.api_DH_generate_parameters_ex, DH_generate_parameters_ex);
177 1 gate_get_libssl_function(glob_libcrypto.api_DH_check, DH_check);
178 1 gate_get_libssl_function(glob_libcrypto.api_DH_generate_key, DH_generate_key);
179
180 1 gate_get_libssl_function(glob_libcrypto.api_PEM_read_bio_RSAPrivateKey, PEM_read_bio_RSAPrivateKey);
181
182 1 gate_get_libssl_function(glob_libcrypto.api_RSA_new, RSA_new);
183 1 gate_get_libssl_function(glob_libcrypto.api_RSA_size, RSA_size);
184 1 gate_get_libssl_function(glob_libcrypto.api_RSA_set0_key, RSA_set0_key);
185 1 gate_get_libssl_function(glob_libcrypto.api_RSA_set0_factors, RSA_set0_factors);
186 1 gate_get_libssl_function(glob_libcrypto.api_RSA_set0_crt_params, RSA_set0_crt_params);
187 1 gate_get_libssl_function(glob_libcrypto.api_RSA_get0_key, RSA_get0_key);
188 1 gate_get_libssl_function(glob_libcrypto.api_RSA_get0_factors, RSA_get0_factors);
189 1 gate_get_libssl_function(glob_libcrypto.api_RSA_sign, RSA_sign);
190 1 gate_get_libssl_function(glob_libcrypto.api_RSA_verify, RSA_verify);
191 1 gate_get_libssl_function(glob_libcrypto.api_RSA_free, RSA_free);
192
193 1 gate_get_libssl_function(glob_libcrypto.api_PEM_read_bio_X509, PEM_read_bio_X509);
194 1 gate_get_libssl_function(glob_libcrypto.api_PEM_read_bio_DSAPrivateKey, PEM_read_bio_DSAPrivateKey);
195 1 gate_get_libssl_function(glob_libcrypto.api_PEM_read_bio_ECPrivateKey, PEM_read_bio_ECPrivateKey);
196 1 gate_get_libssl_function(glob_libcrypto.api_PEM_read_bio_PrivateKey, PEM_read_bio_PrivateKey);
197
198 1 gate_get_libssl_function(glob_libcrypto.api_X509_free, X509_free);
199 1 gate_get_libssl_function(glob_libcrypto.api_X509_get_serialNumber, X509_get_serialNumber);
200 1 gate_get_libssl_function(glob_libcrypto.api_X509_get_subject_name, X509_get_subject_name);
201 1 gate_get_libssl_function(glob_libcrypto.api_X509_get_issuer_name, X509_get_issuer_name);
202 1 gate_get_libssl_function(glob_libcrypto.api_X509_NAME_print_ex, X509_NAME_print_ex);
203 1 gate_get_libssl_function(glob_libcrypto.api_X509_NAME_oneline, X509_NAME_oneline);
204
205 1 gate_get_libssl_function(glob_libcrypto.api_ASN1_TIME_new, ASN1_TIME_new);
206 1 gate_get_libssl_function(glob_libcrypto.api_ASN1_TIME_set_string, ASN1_TIME_set_string);
207 1 gate_get_libssl_function(glob_libcrypto.api_ASN1_STRING_free, ASN1_STRING_free);
208 1 gate_get_libssl_function(glob_libcrypto.api_ASN1_TIME_print, ASN1_TIME_print);
209
210 1 gate_get_libssl_function(glob_libcrypto.api_HMAC_CTX_new, HMAC_CTX_new);
211 1 gate_get_libssl_function(glob_libcrypto.api_HMAC_CTX_free, HMAC_CTX_free);
212 1 gate_get_libssl_function(glob_libcrypto.api_HMAC_Init_ex, HMAC_Init_ex);
213 1 gate_get_libssl_function(glob_libcrypto.api_HMAC_Update, HMAC_Update);
214 1 gate_get_libssl_function(glob_libcrypto.api_HMAC_Final, HMAC_Final);
215
216 1 gate_get_libssl_function(glob_libcrypto.api_EVP_md5, EVP_md5);
217 1 gate_get_libssl_function(glob_libcrypto.api_EVP_md5_sha1, EVP_md5_sha1);
218 1 gate_get_libssl_function(glob_libcrypto.api_EVP_sha1, EVP_sha1);
219 1 gate_get_libssl_function(glob_libcrypto.api_EVP_sha256, EVP_sha256);
220 1 gate_get_libssl_function(glob_libcrypto.api_EVP_sha512, EVP_sha512);
221 1 gate_get_libssl_function(glob_libcrypto.api_EVP_ripemd160, EVP_ripemd160);
222 1 gate_get_libssl_function(glob_libcrypto.api_EVP_get_digestbyname, EVP_get_digestbyname);
223
224
225 1 gate_get_libssl_function(glob_libcrypto.api_EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_new);
226 1 gate_get_libssl_function(glob_libcrypto.api_EVP_CIPHER_CTX_free, EVP_CIPHER_CTX_free);
227 1 gate_get_libssl_function(glob_libcrypto.api_EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_ctrl);
228 1 gate_get_libssl_function(glob_libcrypto.api_EVP_CipherInit, EVP_CipherInit);
229 1 gate_get_libssl_function(glob_libcrypto.api_EVP_Cipher, EVP_Cipher);
230
231
232 1 gate_get_libssl_function(glob_libcrypto.api_EVP_des_ede3_cbc, EVP_des_ede3_cbc);
233 1 gate_get_libssl_function(glob_libcrypto.api_EVP_rc4, EVP_rc4);
234 1 gate_get_libssl_function(glob_libcrypto.api_EVP_bf_cbc, EVP_bf_cbc);
235 1 gate_get_libssl_function(glob_libcrypto.api_EVP_cast5_cbc, EVP_cast5_cbc);
236 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_128_cbc, EVP_aes_128_cbc);
237 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_128_ctr, EVP_aes_128_ctr);
238 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_128_gcm, EVP_aes_128_gcm);
239 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_192_cbc, EVP_aes_192_cbc);
240 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_192_ctr, EVP_aes_192_ctr);
241 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_256_cbc, EVP_aes_256_cbc);
242 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_256_ctr, EVP_aes_256_ctr);
243 1 gate_get_libssl_function(glob_libcrypto.api_EVP_aes_256_gcm, EVP_aes_256_gcm);
244
245 1 gate_get_libssl_function(glob_libcrypto.api_EVP_MD_CTX_new, EVP_MD_CTX_new);
246 1 gate_get_libssl_function(glob_libcrypto.api_EVP_MD_CTX_free, EVP_MD_CTX_free);
247
248 1 gate_get_libssl_function(glob_libcrypto.api_EVP_DigestInit, EVP_DigestInit);
249 1 gate_get_libssl_function(glob_libcrypto.api_EVP_DigestUpdate, EVP_DigestUpdate);
250 1 gate_get_libssl_function(glob_libcrypto.api_EVP_DigestFinal, EVP_DigestFinal);
251 1 gate_get_libssl_function(glob_libcrypto.api_EVP_DigestVerifyInit, EVP_DigestVerifyInit);
252 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_DigestVerify, EVP_DigestVerify);
253 1 gate_get_libssl_function(glob_libcrypto.api_EVP_DigestSignInit, EVP_DigestSignInit);
254 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_DigestSign, EVP_DigestSign);
255
256 1 gate_get_libssl_function_alt(glob_libcrypto.api_EVP_PKEY_id, EVP_PKEY_id, EVP_PKEY_get_id);
257 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_set1_RSA, EVP_PKEY_set1_RSA);
258 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_get1_RSA, EVP_PKEY_get1_RSA);
259 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_set1_DSA, EVP_PKEY_set1_DSA);
260 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_get1_DSA, EVP_PKEY_get1_DSA);
261 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_set1_EC_KEY, EVP_PKEY_set1_EC_KEY);
262 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_get1_EC_KEY, EVP_PKEY_get1_EC_KEY);
263 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_new, EVP_PKEY_new);
264 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_free, EVP_PKEY_free);
265 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_CTX_new, EVP_PKEY_CTX_new);
266 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_id);
267 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_CTX_free, EVP_PKEY_CTX_free);
268 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_PKEY_new_raw_private_key, EVP_PKEY_new_raw_private_key);
269 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_PKEY_new_raw_public_key, EVP_PKEY_new_raw_public_key);
270 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_PKEY_get_raw_private_key, EVP_PKEY_get_raw_private_key);
271 1 gate_get_libssl_function_optional(glob_libcrypto.api_EVP_PKEY_get_raw_public_key, EVP_PKEY_get_raw_public_key);
272 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_derive_init, EVP_PKEY_derive_init);
273 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_derive_set_peer, EVP_PKEY_derive_set_peer);
274 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_derive, EVP_PKEY_derive);
275 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_keygen_init, EVP_PKEY_keygen_init);
276 1 gate_get_libssl_function(glob_libcrypto.api_EVP_PKEY_keygen, EVP_PKEY_keygen);
277
278 1 gate_get_libssl_function(glob_libcrypto.api_DSA_SIG_new, DSA_SIG_new);
279 1 gate_get_libssl_function(glob_libcrypto.api_DSA_SIG_free, DSA_SIG_free);
280 1 gate_get_libssl_function(glob_libcrypto.api_DSA_SIG_get0, DSA_SIG_get0);
281 1 gate_get_libssl_function(glob_libcrypto.api_DSA_SIG_set0, DSA_SIG_set0);
282 1 gate_get_libssl_function(glob_libcrypto.api_DSA_do_sign, DSA_do_sign);
283 1 gate_get_libssl_function(glob_libcrypto.api_DSA_do_verify, DSA_do_verify);
284 1 gate_get_libssl_function(glob_libcrypto.api_DSA_new, DSA_new);
285 1 gate_get_libssl_function(glob_libcrypto.api_DSA_free, DSA_free);
286 1 gate_get_libssl_function(glob_libcrypto.api_DSA_get0_pqg, DSA_get0_pqg);
287 1 gate_get_libssl_function(glob_libcrypto.api_DSA_set0_pqg, DSA_set0_pqg);
288 1 gate_get_libssl_function(glob_libcrypto.api_DSA_get0_key, DSA_get0_key);
289 1 gate_get_libssl_function(glob_libcrypto.api_DSA_set0_key, DSA_set0_key);
290
291 1 gate_get_libssl_function(glob_libcrypto.api_EC_GROUP_get_curve_name, EC_GROUP_get_curve_name);
292 1 gate_get_libssl_function(glob_libcrypto.api_EC_GROUP_get_degree, EC_GROUP_get_degree);
293 1 gate_get_libssl_function(glob_libcrypto.api_EC_POINT_new, EC_POINT_new);
294 1 gate_get_libssl_function(glob_libcrypto.api_EC_POINT_free, EC_POINT_free);
295 1 gate_get_libssl_function(glob_libcrypto.api_EC_POINT_point2oct, EC_POINT_point2oct);
296 1 gate_get_libssl_function(glob_libcrypto.api_EC_POINT_oct2point, EC_POINT_oct2point);
297
298 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_new_by_curve_name, EC_KEY_new_by_curve_name);
299 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_free, EC_KEY_free);
300 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_get0_group, EC_KEY_get0_group);
301 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_set_private_key, EC_KEY_set_private_key);
302 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_get0_public_key, EC_KEY_get0_public_key);
303 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_set_public_key, EC_KEY_set_public_key);
304 1 gate_get_libssl_function(glob_libcrypto.api_EC_KEY_generate_key, EC_KEY_generate_key);
305
306
307 1 gate_get_libssl_function(glob_libcrypto.api_BN_value_one, BN_value_one);
308 1 gate_get_libssl_function(glob_libcrypto.api_BN_set_word, BN_set_word);
309 1 gate_get_libssl_function(glob_libcrypto.api_BN_CTX_new, BN_CTX_new);
310 1 gate_get_libssl_function(glob_libcrypto.api_BN_CTX_free, BN_CTX_free);
311 1 gate_get_libssl_function(glob_libcrypto.api_BN_rand, BN_rand);
312 1 gate_get_libssl_function(glob_libcrypto.api_BN_num_bits, BN_num_bits);
313 1 gate_get_libssl_function(glob_libcrypto.api_BN_new, BN_new);
314 1 gate_get_libssl_function(glob_libcrypto.api_BN_clear_free, BN_clear_free);
315 1 gate_get_libssl_function(glob_libcrypto.api_BN_bin2bn, BN_bin2bn);
316 1 gate_get_libssl_function(glob_libcrypto.api_BN_bn2bin, BN_bn2bin);
317 1 gate_get_libssl_function(glob_libcrypto.api_BN_sub, BN_sub);
318 1 gate_get_libssl_function(glob_libcrypto.api_BN_div, BN_div);
319 1 gate_get_libssl_function(glob_libcrypto.api_BN_mod_exp, BN_mod_exp);
320
321 1 gate_get_libssl_function(glob_libcrypto.api_ECDH_compute_key, ECDH_compute_key);
322 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_SIG_new, ECDSA_SIG_new);
323 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_SIG_free, ECDSA_SIG_free);
324 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_SIG_get0, ECDSA_SIG_get0);
325 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_SIG_set0, ECDSA_SIG_set0);
326 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_do_sign, ECDSA_do_sign);
327 1 gate_get_libssl_function(glob_libcrypto.api_ECDSA_do_verify, ECDSA_do_verify);
328
329 1 gate_get_libssl_function(glob_libcrypto.api_ENGINE_load_builtin_engines, ENGINE_load_builtin_engines);
330 1 gate_get_libssl_function(glob_libcrypto.api_ENGINE_register_all_complete, ENGINE_register_all_complete);
331
332 1 gate_get_libssl_function(glob_libcrypto.api_RAND_bytes, RAND_bytes);
333
334
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (glob_libcrypto.api_OPENSSL_init_crypto)
335 {
336 static uint64_t const init_flags = 0
337 /* | OPENSSL_INIT_NO_LOAD_CONFIG */
338 | OPENSSL_INIT_LOAD_CRYPTO_STRINGS
339 | OPENSSL_INIT_ADD_ALL_CIPHERS
340 | OPENSSL_INIT_ADD_ALL_DIGESTS
341 | OPENSSL_INIT_ENGINE_RDRAND
342 | OPENSSL_INIT_ENGINE_DYNAMIC
343 | OPENSSL_INIT_ENGINE_OPENSSL
344 | OPENSSL_INIT_ENGINE_CRYPTODEV
345 | OPENSSL_INIT_ENGINE_CAPI
346 | OPENSSL_INIT_ENGINE_PADLOCK
347 | OPENSSL_INIT_ENGINE_AFALG
348 ;
349 1 glob_libcrypto.api_OPENSSL_init_crypto(init_flags, NULL);
350 }
351
352 1 libcrypto_loaded = true;
353 } while (0);
354 }
355 3 return ret;
356 }
357
358
359
360 1 static gate_result_t load_libssl()
361 {
362 static volatile gate_bool_t libssl_loaded = false;
363
364 1 gate_result_t ret = GATE_RESULT_OK;
365
366
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!libssl_loaded)
367 {
368 do
369 {
370 /* ssl/tls functions: */
371
372 1 gate_get_libssl_function(glob_libssl.api_OPENSSL_init_ssl, OPENSSL_init_ssl);
373 /*gate_get_libssl_function(glob_libssl.api_SSL_load_error_strings, SSL_load_error_strings);*/
374 /*gate_get_libssl_function(glob_libssl.api_OPENSSL_add_all_algorithms_noconf, OPENSSL_add_all_algorithms_noconf);*/
375
376 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_new, SSL_CTX_new);
377 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_free, SSL_CTX_free);
378 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_ctrl, SSL_CTX_ctrl);
379 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_certificate, SSL_CTX_use_certificate);
380 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_PrivateKey, SSL_CTX_use_PrivateKey);
381 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_set_cipher_list, SSL_CTX_set_cipher_list);
382 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_RSAPrivateKey, SSL_CTX_use_RSAPrivateKey);
383 /*#ifndef GATE_NET_SSL_API_OPENSSL*/
384 1 gate_get_libssl_function(glob_libssl.api_SSL_CTX_set_alpn_select_cb, SSL_CTX_set_alpn_select_cb);
385 /*#endif*/
386
387 1 gate_get_libssl_function(glob_libssl.api_TLS_client_method, TLS_client_method);
388 #if defined(GATE_NET_SSL_OLDPROTOCOLS)
389 gate_get_libssl_function(glob_libssl.api_TLSv1_client_method, TLSv1_client_method);
390 gate_get_libssl_function(glob_libssl.api_TLSv1_1_client_method, TLSv1_1_client_method);
391 gate_get_libssl_function(glob_libssl.api_TLSv1_2_client_method, TLSv1_2_client_method);
392 #endif
393 1 gate_get_libssl_function_optional(glob_libssl.api_TLSv1_3_client_method, TLS_client_method);
394 1 gate_get_libssl_function_optional(glob_libssl.api_SSLv3_client_method, SSLv23_client_method);
395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (NULL == glob_libssl.api_TLSv1_3_client_method)
396 {
397 glob_libssl.api_TLSv1_3_client_method = glob_libssl.api_TLS_client_method;
398 }
399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (NULL == glob_libssl.api_SSLv3_client_method)
400 {
401 glob_libssl.api_SSLv3_client_method = glob_libssl.api_TLS_client_method;
402 }
403
404 1 gate_get_libssl_function(glob_libssl.api_TLS_server_method, TLS_server_method);
405 #if defined(GATE_NET_SSL_OLDPROTOCOLS)
406 gate_get_libssl_function(glob_libssl.api_TLSv1_server_method, TLSv1_server_method);
407 gate_get_libssl_function(glob_libssl.api_TLSv1_1_server_method, TLSv1_1_server_method);
408 gate_get_libssl_function(glob_libssl.api_TLSv1_2_server_method, TLSv1_2_server_method);
409 #endif
410 1 gate_get_libssl_function(glob_libssl.api_TLSv1_3_server_method, TLS_server_method);
411 1 gate_get_libssl_function_optional(glob_libssl.api_SSLv3_server_method, SSLv23_server_method);
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (NULL == glob_libssl.api_TLSv1_3_server_method)
413 {
414 glob_libssl.api_TLSv1_3_server_method = glob_libssl.api_TLS_server_method;
415 }
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (NULL == glob_libssl.api_SSLv3_server_method)
417 {
418 glob_libssl.api_SSLv3_server_method = glob_libssl.api_TLS_server_method;
419 }
420
421 1 gate_get_libssl_function(glob_libssl.api_SSL_new, SSL_new);
422 1 gate_get_libssl_function(glob_libssl.api_SSL_ctrl, SSL_ctrl);
423 1 gate_get_libssl_function(glob_libssl.api_SSL_set_fd, SSL_set_fd);
424 1 gate_get_libssl_function(glob_libssl.api_SSL_set_bio, SSL_set_bio);
425 1 gate_get_libssl_function(glob_libssl.api_SSL_accept, SSL_accept);
426 1 gate_get_libssl_function(glob_libssl.api_SSL_connect, SSL_connect);
427 1 gate_get_libssl_function(glob_libssl.api_SSL_read, SSL_read);
428 1 gate_get_libssl_function(glob_libssl.api_SSL_write, SSL_write);
429 1 gate_get_libssl_function(glob_libssl.api_SSL_get_error, SSL_get_error);
430 1 gate_get_libssl_function(glob_libssl.api_SSL_pending, SSL_pending);
431 1 gate_get_libssl_function(glob_libssl.api_SSL_set_connect_state, SSL_set_connect_state);
432 1 gate_get_libssl_function(glob_libssl.api_SSL_set_accept_state, SSL_set_accept_state);
433 #ifdef GATE_NET_SSL_API_OPENSSL
434 1 gate_get_libssl_function(glob_libssl.api_SSL_state, SSL_get_state);
435 #else
436 /* libreSSL uses another function name and implements "SSL_get_state" as a macro */
437 gate_get_libssl_function(glob_libssl.api_SSL_state, SSL_state);
438 #endif
439 1 gate_get_libssl_function(glob_libssl.api_SSL_do_handshake, SSL_do_handshake);
440 1 gate_get_libssl_function(glob_libssl.api_SSL_get_verify_result, SSL_get_verify_result);
441 1 gate_get_libssl_function(glob_libssl.api_SSL_shutdown, SSL_shutdown);
442 1 gate_get_libssl_function(glob_libssl.api_SSL_free, SSL_free);
443 1 gate_get_libssl_function(glob_libssl.api_SSL_select_next_proto, SSL_select_next_proto);
444 /*#ifndef GATE_NET_SSL_API_OPENSSL*/
445 1 gate_get_libssl_function(glob_libssl.api_SSL_get0_alpn_selected, SSL_get0_alpn_selected);
446 /*#endif*/
447
448 1 gate_get_libssl_function_alt(glob_libssl.api_SSL_get_peer_certificate, SSL_get_peer_certificate, SSL_get1_peer_certificate);
449 1 gate_get_libssl_function_alt(glob_libssl.api_SSL_get_certificate, SSL_get_certificate, SSL_get1_certificate);
450
451 1 gate_get_libssl_function(glob_libssl.api_BIO_new_ssl_connect, BIO_new_ssl_connect);
452
453 1 libssl_loaded = true;
454 } while (0);
455 }
456
457 1 return ret;
458 }
459
460
461
462 3 gate_result_t gate_libcrypto_load_api(gate_libcrypto_api_t* ptr_api_table)
463 {
464 3 gate_result_t result = load_libcrypto();
465
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
3 if (GATE_SUCCEEDED(result) && ptr_api_table)
466 {
467 2 *ptr_api_table = glob_libcrypto;
468 }
469 3 return result;
470 }
471
472
473 1 gate_result_t gate_libssl_load_api(gate_libssl_api_t* ptr_api_table)
474 {
475 1 gate_result_t result = gate_libcrypto_load_api(NULL);
476
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (GATE_SUCCEEDED(result))
477 {
478 1 result = load_libssl();
479
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if (GATE_SUCCEEDED(result) && ptr_api_table)
480 {
481 1 *ptr_api_table = glob_libssl;
482 }
483 }
484 1 return result;
485 }
486
487 #if defined(GATE_NET_SSL_SHAREDLIB)
488
489 /* CRYPTO FUNCTIONS */
490
491 int FIPS_mode(void) { return 0; }
492
493 const BIO_METHOD* BIO_s_mem(void) { return glob_libcrypto.api_BIO_s_mem(); }
494 BIO* BIO_new_mem_buf(void const* buf, int len) { return glob_libcrypto.api_BIO_new_mem_buf(buf, len); }
495 BIO* BIO_new(const BIO_METHOD* type) { return glob_libcrypto.api_BIO_new(type); }
496 BIO* BIO_new_file(const char* filename, const char* mode) { return glob_libcrypto.api_BIO_new_file(filename, mode); }
497 long BIO_ctrl(BIO* bp, int cmd, long larg, void* parg) { return glob_libcrypto.api_BIO_ctrl(bp, cmd, larg, parg); }
498 void BIO_free_all(BIO* a) { glob_libcrypto.api_BIO_free_all(a); }
499 int BIO_free(BIO* a) { return glob_libcrypto.api_BIO_free(a); }
500 int BIO_read(BIO* b, void* data, int len) { return glob_libcrypto.api_BIO_read(b, data, len); }
501 int BIO_test_flags(const BIO* b, int flags) { return glob_libcrypto.api_BIO_test_flags(b, flags); }
502 int BIO_write(BIO* b, const void* data, int len) { return glob_libcrypto.api_BIO_write(b, data, len); }
503 int BIO_new_bio_pair(BIO** bio1, size_t writebuf1, BIO** bio2, size_t writebuf2) { return glob_libcrypto.api_BIO_new_bio_pair(bio1, writebuf1, bio2, writebuf2); }
504
505 HMAC_CTX* HMAC_CTX_new(void) { return glob_libcrypto.api_HMAC_CTX_new(); }
506 void HMAC_CTX_free(HMAC_CTX* ctx) { glob_libcrypto.api_HMAC_CTX_free(ctx); }
507 int HMAC_Init_ex(HMAC_CTX* ctx, const void* key, int key_len, const EVP_MD* md, ENGINE* impl) { return glob_libcrypto.api_HMAC_Init_ex(ctx, key, key_len, md, impl); }
508 int HMAC_Update(HMAC_CTX* ctx, const unsigned char* data, size_t len) { return glob_libcrypto.api_HMAC_Update(ctx, data, len); }
509 int HMAC_Final(HMAC_CTX* ctx, unsigned char* md, unsigned int* len) { return glob_libcrypto.api_HMAC_Final(ctx, md, len); }
510 const EVP_MD* EVP_md5(void) { return glob_libcrypto.api_EVP_md5(); }
511 const EVP_MD* EVP_md5_sha1(void) { return glob_libcrypto.api_EVP_md5_sha1(); }
512 const EVP_MD* EVP_sha1(void) { return glob_libcrypto.api_EVP_sha1(); }
513 const EVP_MD* EVP_sha256(void) { return glob_libcrypto.api_EVP_sha256(); }
514 const EVP_MD* EVP_sha512(void) { return glob_libcrypto.api_EVP_sha512(); }
515 const EVP_MD* EVP_ripemd160(void) { return glob_libcrypto.api_EVP_ripemd160(); }
516 const EVP_MD* EVP_get_digestbyname(const char* name) { return glob_libcrypto.api_EVP_get_digestbyname(name); }
517
518
519 EVP_CIPHER_CTX* EVP_CIPHER_CTX_new(void) { return glob_libcrypto.api_EVP_CIPHER_CTX_new(); }
520 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX* ctx) { glob_libcrypto.api_EVP_CIPHER_CTX_free(ctx); }
521 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX* ctx, int cmd, int p1, void* p2) { return glob_libcrypto.api_EVP_CIPHER_CTX_ctrl(ctx, cmd, p1, p2); }
522 int EVP_CipherInit(EVP_CIPHER_CTX* ctx, const EVP_CIPHER* type, const unsigned char* key, const unsigned char* iv, int enc) { return glob_libcrypto.api_EVP_CipherInit(ctx, type, key, iv, enc); }
523 int EVP_Cipher(EVP_CIPHER_CTX* c, unsigned char* out, const unsigned char* in, unsigned int inl) { return glob_libcrypto.api_EVP_Cipher(c, out, in, inl); }
524
525 const EVP_CIPHER* EVP_des_ede3_cbc(void) { return glob_libcrypto.api_EVP_des_ede3_cbc(); }
526 const EVP_CIPHER* EVP_rc4(void) { return glob_libcrypto.api_EVP_rc4(); }
527 const EVP_CIPHER* EVP_bf_cbc(void) { return glob_libcrypto.api_EVP_bf_cbc(); }
528 const EVP_CIPHER* EVP_cast5_cbc(void) { return glob_libcrypto.api_EVP_cast5_cbc(); }
529 const EVP_CIPHER* EVP_aes_128_cbc(void) { return glob_libcrypto.api_EVP_aes_128_cbc(); }
530 const EVP_CIPHER* EVP_aes_128_ctr(void) { return glob_libcrypto.api_EVP_aes_128_ctr(); }
531 const EVP_CIPHER* EVP_aes_128_gcm(void) { return glob_libcrypto.api_EVP_aes_128_gcm(); }
532 const EVP_CIPHER* EVP_aes_192_cbc(void) { return glob_libcrypto.api_EVP_aes_192_cbc(); }
533 const EVP_CIPHER* EVP_aes_192_ctr(void) { return glob_libcrypto.api_EVP_aes_192_ctr(); }
534 const EVP_CIPHER* EVP_aes_256_cbc(void) { return glob_libcrypto.api_EVP_aes_256_cbc(); }
535 const EVP_CIPHER* EVP_aes_256_ctr(void) { return glob_libcrypto.api_EVP_aes_256_ctr(); }
536 const EVP_CIPHER* EVP_aes_256_gcm(void) { return glob_libcrypto.api_EVP_aes_256_gcm(); }
537
538 EVP_MD_CTX* EVP_MD_CTX_new(void) { return glob_libcrypto.api_EVP_MD_CTX_new(); }
539 void EVP_MD_CTX_free(EVP_MD_CTX* ctx) { glob_libcrypto.api_EVP_MD_CTX_free(ctx); }
540
541 int EVP_DigestInit(EVP_MD_CTX* ctx, const EVP_MD* type) { return glob_libcrypto.api_EVP_DigestInit(ctx, type); }
542 int EVP_DigestUpdate(EVP_MD_CTX* ctx, const void* d, size_t cnt) { return glob_libcrypto.api_EVP_DigestUpdate(ctx, d, cnt); }
543 int EVP_DigestFinal(EVP_MD_CTX* ctx, unsigned char* md, unsigned int* s) { return glob_libcrypto.api_EVP_DigestFinal(ctx, md, s); }
544 int EVP_DigestVerifyInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx, const EVP_MD* type, ENGINE* e, EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_DigestVerifyInit(ctx, pctx, type, e, pkey); }
545 int EVP_DigestSignInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx, const EVP_MD* type, ENGINE* e, EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_DigestSignInit(ctx, pctx, type, e, pkey); }
546 int EVP_DigestVerify(EVP_MD_CTX* ctx, const unsigned char* sigret, size_t siglen, const unsigned char* tbs, size_t tbslen)
547 {
548 if (!glob_libcrypto.api_EVP_DigestVerify) return 0;
549 return glob_libcrypto.api_EVP_DigestVerify(ctx, sigret, siglen, tbs, tbslen);
550 }
551 int EVP_DigestSign(EVP_MD_CTX* ctx, unsigned char* sigret, size_t* siglen, const unsigned char* tbs, size_t tbslen)
552 {
553 if (!glob_libcrypto.api_EVP_DigestSign) return 0;
554 return glob_libcrypto.api_EVP_DigestSign(ctx, sigret, siglen, tbs, tbslen);
555 }
556
557 int EVP_PKEY_id(const EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_id(pkey); }
558 int EVP_PKEY_set1_RSA(EVP_PKEY* pkey, RSA* key) { return glob_libcrypto.api_EVP_PKEY_set1_RSA(pkey, key); }
559 RSA* EVP_PKEY_get1_RSA(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_RSA(pkey); }
560 int EVP_PKEY_set1_DSA(EVP_PKEY* pkey, DSA* key) { return glob_libcrypto.api_EVP_PKEY_set1_DSA(pkey, key); }
561 DSA* EVP_PKEY_get1_DSA(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_DSA(pkey); }
562 int EVP_PKEY_set1_EC_KEY(EVP_PKEY* pkey, EC_KEY* key) { return glob_libcrypto.api_EVP_PKEY_set1_EC_KEY(pkey, key); }
563 EC_KEY* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_EC_KEY(pkey); }
564 EVP_PKEY* EVP_PKEY_new(void) { return glob_libcrypto.api_EVP_PKEY_new(); }
565 void EVP_PKEY_free(EVP_PKEY* key) { glob_libcrypto.api_EVP_PKEY_free(key); }
566 EVP_PKEY_CTX* EVP_PKEY_CTX_new(EVP_PKEY* pkey, ENGINE* e) { return glob_libcrypto.api_EVP_PKEY_CTX_new(pkey, e); }
567 EVP_PKEY_CTX* EVP_PKEY_CTX_new_id(int id, ENGINE* e) { return glob_libcrypto.api_EVP_PKEY_CTX_new_id(id, e); }
568 void EVP_PKEY_CTX_free(EVP_PKEY_CTX* ctx) { glob_libcrypto.api_EVP_PKEY_CTX_free(ctx); }
569 int EVP_PKEY_derive_init(EVP_PKEY_CTX* ctx) { return glob_libcrypto.api_EVP_PKEY_derive_init(ctx); }
570 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX* ctx, EVP_PKEY* peer) { return glob_libcrypto.api_EVP_PKEY_derive_set_peer(ctx, peer); }
571 int EVP_PKEY_derive(EVP_PKEY_CTX* ctx, unsigned char* key, size_t* keylen) { return glob_libcrypto.api_EVP_PKEY_derive(ctx, key, keylen); }
572 int EVP_PKEY_keygen_init(EVP_PKEY_CTX* ctx) { return glob_libcrypto.api_EVP_PKEY_keygen_init(ctx); }
573 int EVP_PKEY_keygen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey) { return glob_libcrypto.api_EVP_PKEY_keygen(ctx, ppkey); }
574 EVP_PKEY* EVP_PKEY_new_raw_private_key(int type, ENGINE* e, const unsigned char* key, size_t keylen)
575 {
576 if (!glob_libcrypto.api_EVP_PKEY_new_raw_private_key) return NULL;
577 return glob_libcrypto.api_EVP_PKEY_new_raw_private_key(type, e, key, keylen);
578 }
579 EVP_PKEY* EVP_PKEY_new_raw_public_key(int type, ENGINE* e, const unsigned char* key, size_t keylen)
580 {
581 if (!glob_libcrypto.api_EVP_PKEY_new_raw_public_key) return NULL;
582 return glob_libcrypto.api_EVP_PKEY_new_raw_public_key(type, e, key, keylen);
583 }
584 int EVP_PKEY_get_raw_private_key(const EVP_PKEY* pkey, unsigned char* priv, size_t* len)
585 {
586 if (!glob_libcrypto.api_EVP_PKEY_get_raw_private_key) return 0;
587 return glob_libcrypto.api_EVP_PKEY_get_raw_private_key(pkey, priv, len);
588 }
589 int EVP_PKEY_get_raw_public_key(const EVP_PKEY* pkey, unsigned char* pub, size_t* len)
590 {
591 if (!glob_libcrypto.api_EVP_PKEY_get_raw_public_key) return 0;
592 return glob_libcrypto.api_EVP_PKEY_get_raw_public_key(pkey, pub, len);
593 }
594
595
596 RSA* RSA_new(void) { return glob_libcrypto.api_RSA_new(); }
597 int RSA_size(const RSA* rsa) { return glob_libcrypto.api_RSA_size(rsa); }
598 int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) { return glob_libcrypto.api_RSA_set0_key(r, n, e, d); }
599 int RSA_set0_factors(RSA* r, BIGNUM* p, BIGNUM* q) { return glob_libcrypto.api_RSA_set0_factors(r, p, q); }
600 int RSA_set0_crt_params(RSA* r, BIGNUM* dmp1, BIGNUM* dmq1, BIGNUM* iqmp) { return glob_libcrypto.api_RSA_set0_crt_params(r, dmp1, dmq1, iqmp); }
601 void RSA_get0_key(const RSA* r, const BIGNUM** n, const BIGNUM** e, const BIGNUM** d) { glob_libcrypto.api_RSA_get0_key(r, n, e, d); }
602 void RSA_get0_factors(const RSA* r, const BIGNUM** p, const BIGNUM** q) { glob_libcrypto.api_RSA_get0_factors(r, p, q); }
603 int RSA_sign(int type, const unsigned char* m, unsigned int m_len, unsigned char* sigret, unsigned int* siglen, RSA* rsa) { return glob_libcrypto.api_RSA_sign(type, m, m_len, sigret, siglen, rsa); }
604 int RSA_verify(int type, const unsigned char* m, unsigned int m_len, unsigned char* sigbuf, unsigned int siglen, RSA* rsa) { return glob_libcrypto.api_RSA_verify(type, m, m_len, sigbuf, siglen, rsa); }
605 void RSA_free(RSA* r) { glob_libcrypto.api_RSA_free(r); }
606
607 DSA_SIG* DSA_SIG_new(void) { return glob_libcrypto.api_DSA_SIG_new(); }
608 void DSA_SIG_free(DSA_SIG* a) { glob_libcrypto.api_DSA_SIG_free(a); }
609 void DSA_SIG_get0(const DSA_SIG* sig, const BIGNUM** pr, const BIGNUM** ps) { glob_libcrypto.api_DSA_SIG_get0(sig, pr, ps); }
610 int DSA_SIG_set0(DSA_SIG* sig, BIGNUM* r, BIGNUM* s) { return glob_libcrypto.api_DSA_SIG_set0(sig, r, s); }
611 DSA_SIG* DSA_do_sign(const unsigned char* dgst, int dlen, DSA* dsa) { return glob_libcrypto.api_DSA_do_sign(dgst, dlen, dsa); }
612 int DSA_do_verify(const unsigned char* dgst, int dgst_len, DSA_SIG* sig, DSA* dsa) { return glob_libcrypto.api_DSA_do_verify(dgst, dgst_len, sig, dsa); }
613 DSA* DSA_new(void) { return glob_libcrypto.api_DSA_new(); }
614 void DSA_free(DSA* dsa) { glob_libcrypto.api_DSA_free(dsa); }
615 void DSA_get0_pqg(const DSA* d, const BIGNUM** p, const BIGNUM** q, const BIGNUM** g) { glob_libcrypto.api_DSA_get0_pqg(d, p, q, g); }
616 int DSA_set0_pqg(DSA* d, BIGNUM* p, BIGNUM* q, BIGNUM* g) { return glob_libcrypto.api_DSA_set0_pqg(d, p, q, g); }
617 void DSA_get0_key(const DSA* d, const BIGNUM** pub_key, const BIGNUM** priv_key) { glob_libcrypto.api_DSA_get0_key(d, pub_key, priv_key); }
618 int DSA_set0_key(DSA* d, BIGNUM* pub_key, BIGNUM* priv_key) { return glob_libcrypto.api_DSA_set0_key(d, pub_key, priv_key); }
619
620 int EC_GROUP_get_curve_name(const EC_GROUP* group) { return glob_libcrypto.api_EC_GROUP_get_curve_name(group); }
621 int EC_GROUP_get_degree(const EC_GROUP* group) { return glob_libcrypto.api_EC_GROUP_get_degree(group); }
622 EC_POINT* EC_POINT_new(const EC_GROUP* group) { return glob_libcrypto.api_EC_POINT_new(group); }
623 void EC_POINT_free(EC_POINT* point) { glob_libcrypto.api_EC_POINT_free(point); }
624 size_t EC_POINT_point2oct(const EC_GROUP* group, const EC_POINT* p, point_conversion_form_t form, unsigned char* buf, size_t len, BN_CTX* ctx) { return glob_libcrypto.api_EC_POINT_point2oct(group, p, form, buf, len, ctx); }
625 int EC_POINT_oct2point(const EC_GROUP* group, EC_POINT* p, const unsigned char* buf, size_t len, BN_CTX* ctx) { return glob_libcrypto.api_EC_POINT_oct2point(group, p, buf, len, ctx); }
626
627 EC_KEY* EC_KEY_new_by_curve_name(int nid) { return glob_libcrypto.api_EC_KEY_new_by_curve_name(nid); }
628 void EC_KEY_free(EC_KEY* key) { glob_libcrypto.api_EC_KEY_free(key); }
629 const EC_GROUP* EC_KEY_get0_group(const EC_KEY* key) { return glob_libcrypto.api_EC_KEY_get0_group(key); }
630 int EC_KEY_set_private_key(EC_KEY* key, const BIGNUM* priv_key) { return glob_libcrypto.api_EC_KEY_set_private_key(key, priv_key); }
631 const EC_POINT* EC_KEY_get0_public_key(const EC_KEY* key) { return glob_libcrypto.api_EC_KEY_get0_public_key(key); }
632 int EC_KEY_set_public_key(EC_KEY* key, const EC_POINT* pub) { return glob_libcrypto.api_EC_KEY_set_public_key(key, pub); }
633 int EC_KEY_generate_key(EC_KEY* key) { return glob_libcrypto.api_EC_KEY_generate_key(key); }
634
635 const BIGNUM* BN_value_one(void) { return glob_libcrypto.api_BN_value_one(); }
636 int BN_set_word(BIGNUM* a, BN_ULONG w) { return glob_libcrypto.api_BN_set_word(a, w); }
637 BN_CTX* BN_CTX_new(void) { return glob_libcrypto.api_BN_CTX_new(); }
638 void BN_CTX_free(BN_CTX* c) { glob_libcrypto.api_BN_CTX_free(c); }
639 int BN_rand(BIGNUM* rnd, int bits, int top, int bottom) { return glob_libcrypto.api_BN_rand(rnd, bits, top, bottom); }
640 int BN_num_bits(const BIGNUM* a) { return glob_libcrypto.api_BN_num_bits(a); }
641 BIGNUM* BN_new(void) { return glob_libcrypto.api_BN_new(); }
642 void BN_clear_free(BIGNUM* a) { glob_libcrypto.api_BN_clear_free(a); }
643 BIGNUM* BN_bin2bn(const unsigned char* s, int len, BIGNUM* ret) { return glob_libcrypto.api_BN_bin2bn(s, len, ret); }
644 int BN_bn2bin(const BIGNUM* a, unsigned char* to) { return glob_libcrypto.api_BN_bn2bin(a, to); }
645 int BN_sub(BIGNUM* r, const BIGNUM* a, const BIGNUM* b) { return glob_libcrypto.api_BN_sub(r, a, b); }
646 int BN_div(BIGNUM* dv, BIGNUM* rem, const BIGNUM* a, const BIGNUM* d, BN_CTX* ctx) { return glob_libcrypto.api_BN_div(dv, rem, a, d, ctx); }
647 int BN_mod_exp(BIGNUM* r, const BIGNUM* a, const BIGNUM* p, const BIGNUM* m, BN_CTX* ctx) { return glob_libcrypto.api_BN_mod_exp(r, a, p, m, ctx); }
648
649 int ECDH_compute_key(void* out, size_t outlen, const EC_POINT* public_key, const EC_KEY* ecdh, void* (*KDF)(const void* in, size_t inlen, void* out, size_t* outlen)) { return glob_libcrypto.api_ECDH_compute_key(out, outlen, public_key, ecdh, KDF); }
650 ECDSA_SIG* ECDSA_SIG_new(void) { return glob_libcrypto.api_ECDSA_SIG_new(); }
651 void ECDSA_SIG_free(ECDSA_SIG* sig) { glob_libcrypto.api_ECDSA_SIG_free(sig); }
652 void ECDSA_SIG_get0(const ECDSA_SIG* sig, const BIGNUM** pr, const BIGNUM** ps) { glob_libcrypto.api_ECDSA_SIG_get0(sig, pr, ps); }
653 int ECDSA_SIG_set0(ECDSA_SIG* sig, BIGNUM* r, BIGNUM* s) { return glob_libcrypto.api_ECDSA_SIG_set0(sig, r, s); }
654 ECDSA_SIG* ECDSA_do_sign(const unsigned char* dgst, int dgst_len, EC_KEY* eckey) { return glob_libcrypto.api_ECDSA_do_sign(dgst, dgst_len, eckey); }
655 int ECDSA_do_verify(const unsigned char* dgst, int dgst_len, const ECDSA_SIG* sig, EC_KEY* eckey) { return glob_libcrypto.api_ECDSA_do_verify(dgst, dgst_len, sig, eckey); }
656
657 RSA* PEM_read_bio_RSAPrivateKey(BIO* bp, RSA** x, pem_password_cb* cb, void* u) { return glob_libcrypto.api_PEM_read_bio_RSAPrivateKey(bp, x, cb, u); }
658 DSA* PEM_read_bio_DSAPrivateKey(BIO* bp, DSA** x, pem_password_cb* cb, void* u) { return glob_libcrypto.api_PEM_read_bio_DSAPrivateKey(bp, x, cb, u); }
659 EC_KEY* PEM_read_bio_ECPrivateKey(BIO* out, EC_KEY** x, pem_password_cb* cb, void* u) { return glob_libcrypto.api_PEM_read_bio_ECPrivateKey(out, x, cb, u); }
660 EVP_PKEY* PEM_read_bio_PrivateKey(BIO* bp, EVP_PKEY** x, pem_password_cb* cb, void* u) { return glob_libcrypto.api_PEM_read_bio_PrivateKey(bp, x, cb, u); }
661
662 void ENGINE_load_builtin_engines(void) { glob_libcrypto.api_ENGINE_load_builtin_engines(); }
663 int ENGINE_register_all_complete(void) { return glob_libcrypto.api_ENGINE_register_all_complete(); }
664
665 int RAND_bytes(unsigned char* buf, int num) { return glob_libcrypto.api_RAND_bytes(buf, num); }
666
667 #endif
668