GCC Code Coverage Report


Directory: src/gate/
File: src/gate/net/platform/openssl_api.c
Date: 2025-12-12 23:40:09
Exec Total Coverage
Lines: 165 222 74.3%
Functions: 2 4 50.0%
Branches: 4 24 16.7%

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