GCC Code Coverage Report


Directory: src/gate/
File: src/gate/net/platform/openssl_api.c
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 167 226 73.9%
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 1 ret = GATE_RESULT_FAILED;
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 | 0;
349 1 glob_libcrypto.api_OPENSSL_init_crypto(init_flags, NULL);
350 }
351
352 1 ret = GATE_RESULT_OK;
353 1 libcrypto_loaded = true;
354 } while (0);
355 }
356 1 return ret;
357 }
358
359
360
361 static gate_result_t load_libssl()
362 {
363 static volatile gate_bool_t libssl_loaded = false;
364
365 gate_result_t ret = GATE_RESULT_OK;
366
367 if (!libssl_loaded)
368 {
369 ret = GATE_RESULT_FAILED;
370 do
371 {
372 /* ssl/tls functions: */
373
374 gate_get_libssl_function(glob_libssl.api_OPENSSL_init_ssl, OPENSSL_init_ssl);
375 /*gate_get_libssl_function(glob_libssl.api_SSL_load_error_strings, SSL_load_error_strings);*/
376 /*gate_get_libssl_function(glob_libssl.api_OPENSSL_add_all_algorithms_noconf, OPENSSL_add_all_algorithms_noconf);*/
377
378 gate_get_libssl_function(glob_libssl.api_SSL_CTX_new, SSL_CTX_new);
379 gate_get_libssl_function(glob_libssl.api_SSL_CTX_free, SSL_CTX_free);
380 gate_get_libssl_function(glob_libssl.api_SSL_CTX_ctrl, SSL_CTX_ctrl);
381 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_certificate, SSL_CTX_use_certificate);
382 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_PrivateKey, SSL_CTX_use_PrivateKey);
383 gate_get_libssl_function(glob_libssl.api_SSL_CTX_set_cipher_list, SSL_CTX_set_cipher_list);
384 gate_get_libssl_function(glob_libssl.api_SSL_CTX_use_RSAPrivateKey, SSL_CTX_use_RSAPrivateKey);
385 /*#ifndef GATE_NET_SSL_API_OPENSSL*/
386 gate_get_libssl_function(glob_libssl.api_SSL_CTX_set_alpn_select_cb, SSL_CTX_set_alpn_select_cb);
387 /*#endif*/
388
389 gate_get_libssl_function(glob_libssl.api_TLS_client_method, TLS_client_method);
390 #if defined(GATE_NET_SSL_OLDPROTOCOLS)
391 gate_get_libssl_function(glob_libssl.api_TLSv1_client_method, TLSv1_client_method);
392 gate_get_libssl_function(glob_libssl.api_TLSv1_1_client_method, TLSv1_1_client_method);
393 gate_get_libssl_function(glob_libssl.api_TLSv1_2_client_method, TLSv1_2_client_method);
394 #endif
395 gate_get_libssl_function_optional(glob_libssl.api_TLSv1_3_client_method, TLS_client_method);
396 gate_get_libssl_function_optional(glob_libssl.api_SSLv3_client_method, SSLv23_client_method);
397 if (NULL == glob_libssl.api_TLSv1_3_client_method)
398 {
399 glob_libssl.api_TLSv1_3_client_method = glob_libssl.api_TLS_client_method;
400 }
401 if (NULL == glob_libssl.api_SSLv3_client_method)
402 {
403 glob_libssl.api_SSLv3_client_method = glob_libssl.api_TLS_client_method;
404 }
405
406 gate_get_libssl_function(glob_libssl.api_TLS_server_method, TLS_server_method);
407 #if defined(GATE_NET_SSL_OLDPROTOCOLS)
408 gate_get_libssl_function(glob_libssl.api_TLSv1_server_method, TLSv1_server_method);
409 gate_get_libssl_function(glob_libssl.api_TLSv1_1_server_method, TLSv1_1_server_method);
410 gate_get_libssl_function(glob_libssl.api_TLSv1_2_server_method, TLSv1_2_server_method);
411 #endif
412 gate_get_libssl_function(glob_libssl.api_TLSv1_3_server_method, TLS_server_method);
413 gate_get_libssl_function_optional(glob_libssl.api_SSLv3_server_method, SSLv23_server_method);
414 if (NULL == glob_libssl.api_TLSv1_3_server_method)
415 {
416 glob_libssl.api_TLSv1_3_server_method = glob_libssl.api_TLS_server_method;
417 }
418 if (NULL == glob_libssl.api_SSLv3_server_method)
419 {
420 glob_libssl.api_SSLv3_server_method = glob_libssl.api_TLS_server_method;
421 }
422
423 gate_get_libssl_function(glob_libssl.api_SSL_new, SSL_new);
424 gate_get_libssl_function(glob_libssl.api_SSL_ctrl, SSL_ctrl);
425 gate_get_libssl_function(glob_libssl.api_SSL_set_fd, SSL_set_fd);
426 gate_get_libssl_function(glob_libssl.api_SSL_set_bio, SSL_set_bio);
427 gate_get_libssl_function(glob_libssl.api_SSL_accept, SSL_accept);
428 gate_get_libssl_function(glob_libssl.api_SSL_connect, SSL_connect);
429 gate_get_libssl_function(glob_libssl.api_SSL_read, SSL_read);
430 gate_get_libssl_function(glob_libssl.api_SSL_write, SSL_write);
431 gate_get_libssl_function(glob_libssl.api_SSL_get_error, SSL_get_error);
432 gate_get_libssl_function(glob_libssl.api_SSL_pending, SSL_pending);
433 gate_get_libssl_function(glob_libssl.api_SSL_set_connect_state, SSL_set_connect_state);
434 gate_get_libssl_function(glob_libssl.api_SSL_set_accept_state, SSL_set_accept_state);
435 #ifdef GATE_NET_SSL_API_OPENSSL
436 gate_get_libssl_function(glob_libssl.api_SSL_state, SSL_get_state);
437 #else
438 /* libreSSL uses another function name and implements "SSL_get_state" as a macro */
439 gate_get_libssl_function(glob_libssl.api_SSL_state, SSL_state);
440 #endif
441 gate_get_libssl_function(glob_libssl.api_SSL_do_handshake, SSL_do_handshake);
442 gate_get_libssl_function(glob_libssl.api_SSL_get_verify_result, SSL_get_verify_result);
443 gate_get_libssl_function(glob_libssl.api_SSL_shutdown, SSL_shutdown);
444 gate_get_libssl_function(glob_libssl.api_SSL_free, SSL_free);
445 gate_get_libssl_function(glob_libssl.api_SSL_select_next_proto, SSL_select_next_proto);
446 /*#ifndef GATE_NET_SSL_API_OPENSSL*/
447 gate_get_libssl_function(glob_libssl.api_SSL_get0_alpn_selected, SSL_get0_alpn_selected);
448 /*#endif*/
449
450 gate_get_libssl_function(glob_libssl.api_SSL_get_peer_certificate, SSL_get_peer_certificate);
451 gate_get_libssl_function(glob_libssl.api_SSL_get_certificate, SSL_get_certificate);
452
453 gate_get_libssl_function(glob_libssl.api_BIO_new_ssl_connect, BIO_new_ssl_connect);
454
455 ret = GATE_RESULT_OK;
456 libssl_loaded = true;
457 } while (0);
458 }
459
460 return ret;
461 }
462
463
464
465 1 gate_result_t gate_libcrypto_load_api(gate_libcrypto_api_t* ptr_api_table)
466 {
467 1 gate_result_t result = load_libcrypto();
468
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)
469 {
470 1 *ptr_api_table = glob_libcrypto;
471 }
472 1 return result;
473 }
474
475
476 gate_result_t gate_libssl_load_api(gate_libssl_api_t* ptr_api_table)
477 {
478 gate_result_t result = gate_libcrypto_load_api(NULL);
479 if (GATE_SUCCEEDED(result))
480 {
481 result = load_libssl();
482 if (GATE_SUCCEEDED(result) && ptr_api_table)
483 {
484 *ptr_api_table = glob_libssl;
485 }
486 }
487 return result;
488 }
489
490 #if defined(GATE_NET_SSL_SHAREDLIB)
491
492 /* CRYPTO FUNCTIONS */
493
494 int FIPS_mode(void) { return 0; }
495
496 const BIO_METHOD* BIO_s_mem(void) { return glob_libcrypto.api_BIO_s_mem(); }
497 BIO* BIO_new_mem_buf(void const* buf, int len) { return glob_libcrypto.api_BIO_new_mem_buf(buf, len); }
498 BIO* BIO_new(const BIO_METHOD* type) { return glob_libcrypto.api_BIO_new(type); }
499 BIO* BIO_new_file(const char* filename, const char* mode) { return glob_libcrypto.api_BIO_new_file(filename, mode); }
500 long BIO_ctrl(BIO* bp, int cmd, long larg, void* parg) { return glob_libcrypto.api_BIO_ctrl(bp, cmd, larg, parg); }
501 void BIO_free_all(BIO* a) { glob_libcrypto.api_BIO_free_all(a); }
502 int BIO_free(BIO* a) { return glob_libcrypto.api_BIO_free(a); }
503 int BIO_read(BIO* b, void* data, int len) { return glob_libcrypto.api_BIO_read(b, data, len); }
504 int BIO_test_flags(const BIO* b, int flags) { return glob_libcrypto.api_BIO_test_flags(b, flags); }
505 int BIO_write(BIO* b, const void* data, int len) { return glob_libcrypto.api_BIO_write(b, data, len); }
506 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); }
507
508 HMAC_CTX* HMAC_CTX_new(void) { return glob_libcrypto.api_HMAC_CTX_new(); }
509 void HMAC_CTX_free(HMAC_CTX* ctx) { glob_libcrypto.api_HMAC_CTX_free(ctx); }
510 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); }
511 int HMAC_Update(HMAC_CTX* ctx, const unsigned char* data, size_t len) { return glob_libcrypto.api_HMAC_Update(ctx, data, len); }
512 int HMAC_Final(HMAC_CTX* ctx, unsigned char* md, unsigned int* len) { return glob_libcrypto.api_HMAC_Final(ctx, md, len); }
513 const EVP_MD* EVP_md5(void) { return glob_libcrypto.api_EVP_md5(); }
514 const EVP_MD* EVP_md5_sha1(void) { return glob_libcrypto.api_EVP_md5_sha1(); }
515 const EVP_MD* EVP_sha1(void) { return glob_libcrypto.api_EVP_sha1(); }
516 const EVP_MD* EVP_sha256(void) { return glob_libcrypto.api_EVP_sha256(); }
517 const EVP_MD* EVP_sha512(void) { return glob_libcrypto.api_EVP_sha512(); }
518 const EVP_MD* EVP_ripemd160(void) { return glob_libcrypto.api_EVP_ripemd160(); }
519 const EVP_MD* EVP_get_digestbyname(const char* name) { return glob_libcrypto.api_EVP_get_digestbyname(name); }
520
521
522 EVP_CIPHER_CTX* EVP_CIPHER_CTX_new(void) { return glob_libcrypto.api_EVP_CIPHER_CTX_new(); }
523 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX* ctx) { glob_libcrypto.api_EVP_CIPHER_CTX_free(ctx); }
524 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); }
525 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); }
526 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); }
527
528 const EVP_CIPHER* EVP_des_ede3_cbc(void) { return glob_libcrypto.api_EVP_des_ede3_cbc(); }
529 const EVP_CIPHER* EVP_rc4(void) { return glob_libcrypto.api_EVP_rc4(); }
530 const EVP_CIPHER* EVP_bf_cbc(void) { return glob_libcrypto.api_EVP_bf_cbc(); }
531 const EVP_CIPHER* EVP_cast5_cbc(void) { return glob_libcrypto.api_EVP_cast5_cbc(); }
532 const EVP_CIPHER* EVP_aes_128_cbc(void) { return glob_libcrypto.api_EVP_aes_128_cbc(); }
533 const EVP_CIPHER* EVP_aes_128_ctr(void) { return glob_libcrypto.api_EVP_aes_128_ctr(); }
534 const EVP_CIPHER* EVP_aes_128_gcm(void) { return glob_libcrypto.api_EVP_aes_128_gcm(); }
535 const EVP_CIPHER* EVP_aes_192_cbc(void) { return glob_libcrypto.api_EVP_aes_192_cbc(); }
536 const EVP_CIPHER* EVP_aes_192_ctr(void) { return glob_libcrypto.api_EVP_aes_192_ctr(); }
537 const EVP_CIPHER* EVP_aes_256_cbc(void) { return glob_libcrypto.api_EVP_aes_256_cbc(); }
538 const EVP_CIPHER* EVP_aes_256_ctr(void) { return glob_libcrypto.api_EVP_aes_256_ctr(); }
539 const EVP_CIPHER* EVP_aes_256_gcm(void) { return glob_libcrypto.api_EVP_aes_256_gcm(); }
540
541 EVP_MD_CTX* EVP_MD_CTX_new(void) { return glob_libcrypto.api_EVP_MD_CTX_new(); }
542 void EVP_MD_CTX_free(EVP_MD_CTX* ctx) { glob_libcrypto.api_EVP_MD_CTX_free(ctx); }
543
544 int EVP_DigestInit(EVP_MD_CTX* ctx, const EVP_MD* type) { return glob_libcrypto.api_EVP_DigestInit(ctx, type); }
545 int EVP_DigestUpdate(EVP_MD_CTX* ctx, const void* d, size_t cnt) { return glob_libcrypto.api_EVP_DigestUpdate(ctx, d, cnt); }
546 int EVP_DigestFinal(EVP_MD_CTX* ctx, unsigned char* md, unsigned int* s) { return glob_libcrypto.api_EVP_DigestFinal(ctx, md, s); }
547 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); }
548 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); }
549 int EVP_DigestVerify(EVP_MD_CTX* ctx, const unsigned char* sigret, size_t siglen, const unsigned char* tbs, size_t tbslen)
550 {
551 if (!glob_libcrypto.api_EVP_DigestVerify) return 0;
552 return glob_libcrypto.api_EVP_DigestVerify(ctx, sigret, siglen, tbs, tbslen);
553 }
554 int EVP_DigestSign(EVP_MD_CTX* ctx, unsigned char* sigret, size_t* siglen, const unsigned char* tbs, size_t tbslen)
555 {
556 if (!glob_libcrypto.api_EVP_DigestSign) return 0;
557 return glob_libcrypto.api_EVP_DigestSign(ctx, sigret, siglen, tbs, tbslen);
558 }
559
560 int EVP_PKEY_id(const EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_id(pkey); }
561 int EVP_PKEY_set1_RSA(EVP_PKEY* pkey, RSA* key) { return glob_libcrypto.api_EVP_PKEY_set1_RSA(pkey, key); }
562 RSA* EVP_PKEY_get1_RSA(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_RSA(pkey); }
563 int EVP_PKEY_set1_DSA(EVP_PKEY* pkey, DSA* key) { return glob_libcrypto.api_EVP_PKEY_set1_DSA(pkey, key); }
564 DSA* EVP_PKEY_get1_DSA(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_DSA(pkey); }
565 int EVP_PKEY_set1_EC_KEY(EVP_PKEY* pkey, EC_KEY* key) { return glob_libcrypto.api_EVP_PKEY_set1_EC_KEY(pkey, key); }
566 EC_KEY* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey) { return glob_libcrypto.api_EVP_PKEY_get1_EC_KEY(pkey); }
567 EVP_PKEY* EVP_PKEY_new(void) { return glob_libcrypto.api_EVP_PKEY_new(); }
568 void EVP_PKEY_free(EVP_PKEY* key) { glob_libcrypto.api_EVP_PKEY_free(key); }
569 EVP_PKEY_CTX* EVP_PKEY_CTX_new(EVP_PKEY* pkey, ENGINE* e) { return glob_libcrypto.api_EVP_PKEY_CTX_new(pkey, e); }
570 EVP_PKEY_CTX* EVP_PKEY_CTX_new_id(int id, ENGINE* e) { return glob_libcrypto.api_EVP_PKEY_CTX_new_id(id, e); }
571 void EVP_PKEY_CTX_free(EVP_PKEY_CTX* ctx) { glob_libcrypto.api_EVP_PKEY_CTX_free(ctx); }
572 int EVP_PKEY_derive_init(EVP_PKEY_CTX* ctx) { return glob_libcrypto.api_EVP_PKEY_derive_init(ctx); }
573 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX* ctx, EVP_PKEY* peer) { return glob_libcrypto.api_EVP_PKEY_derive_set_peer(ctx, peer); }
574 int EVP_PKEY_derive(EVP_PKEY_CTX* ctx, unsigned char* key, size_t* keylen) { return glob_libcrypto.api_EVP_PKEY_derive(ctx, key, keylen); }
575 int EVP_PKEY_keygen_init(EVP_PKEY_CTX* ctx) { return glob_libcrypto.api_EVP_PKEY_keygen_init(ctx); }
576 int EVP_PKEY_keygen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey) { return glob_libcrypto.api_EVP_PKEY_keygen(ctx, ppkey); }
577 EVP_PKEY* EVP_PKEY_new_raw_private_key(int type, ENGINE* e, const unsigned char* key, size_t keylen)
578 {
579 if (!glob_libcrypto.api_EVP_PKEY_new_raw_private_key) return NULL;
580 return glob_libcrypto.api_EVP_PKEY_new_raw_private_key(type, e, key, keylen);
581 }
582 EVP_PKEY* EVP_PKEY_new_raw_public_key(int type, ENGINE* e, const unsigned char* key, size_t keylen)
583 {
584 if (!glob_libcrypto.api_EVP_PKEY_new_raw_public_key) return NULL;
585 return glob_libcrypto.api_EVP_PKEY_new_raw_public_key(type, e, key, keylen);
586 }
587 int EVP_PKEY_get_raw_private_key(const EVP_PKEY* pkey, unsigned char* priv, size_t* len)
588 {
589 if (!glob_libcrypto.api_EVP_PKEY_get_raw_private_key) return 0;
590 return glob_libcrypto.api_EVP_PKEY_get_raw_private_key(pkey, priv, len);
591 }
592 int EVP_PKEY_get_raw_public_key(const EVP_PKEY* pkey, unsigned char* pub, size_t* len)
593 {
594 if (!glob_libcrypto.api_EVP_PKEY_get_raw_public_key) return 0;
595 return glob_libcrypto.api_EVP_PKEY_get_raw_public_key(pkey, pub, len);
596 }
597
598
599 RSA* RSA_new(void) { return glob_libcrypto.api_RSA_new(); }
600 int RSA_size(const RSA* rsa) { return glob_libcrypto.api_RSA_size(rsa); }
601 int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) { return glob_libcrypto.api_RSA_set0_key(r, n, e, d); }
602 int RSA_set0_factors(RSA* r, BIGNUM* p, BIGNUM* q) { return glob_libcrypto.api_RSA_set0_factors(r, p, q); }
603 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); }
604 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); }
605 void RSA_get0_factors(const RSA* r, const BIGNUM** p, const BIGNUM** q) { glob_libcrypto.api_RSA_get0_factors(r, p, q); }
606 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); }
607 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); }
608 void RSA_free(RSA* r) { glob_libcrypto.api_RSA_free(r); }
609
610 DSA_SIG* DSA_SIG_new(void) { return glob_libcrypto.api_DSA_SIG_new(); }
611 void DSA_SIG_free(DSA_SIG* a) { glob_libcrypto.api_DSA_SIG_free(a); }
612 void DSA_SIG_get0(const DSA_SIG* sig, const BIGNUM** pr, const BIGNUM** ps) { glob_libcrypto.api_DSA_SIG_get0(sig, pr, ps); }
613 int DSA_SIG_set0(DSA_SIG* sig, BIGNUM* r, BIGNUM* s) { return glob_libcrypto.api_DSA_SIG_set0(sig, r, s); }
614 DSA_SIG* DSA_do_sign(const unsigned char* dgst, int dlen, DSA* dsa) { return glob_libcrypto.api_DSA_do_sign(dgst, dlen, dsa); }
615 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); }
616 DSA* DSA_new(void) { return glob_libcrypto.api_DSA_new(); }
617 void DSA_free(DSA* dsa) { glob_libcrypto.api_DSA_free(dsa); }
618 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); }
619 int DSA_set0_pqg(DSA* d, BIGNUM* p, BIGNUM* q, BIGNUM* g) { return glob_libcrypto.api_DSA_set0_pqg(d, p, q, g); }
620 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); }
621 int DSA_set0_key(DSA* d, BIGNUM* pub_key, BIGNUM* priv_key) { return glob_libcrypto.api_DSA_set0_key(d, pub_key, priv_key); }
622
623 int EC_GROUP_get_curve_name(const EC_GROUP* group) { return glob_libcrypto.api_EC_GROUP_get_curve_name(group); }
624 int EC_GROUP_get_degree(const EC_GROUP* group) { return glob_libcrypto.api_EC_GROUP_get_degree(group); }
625 EC_POINT* EC_POINT_new(const EC_GROUP* group) { return glob_libcrypto.api_EC_POINT_new(group); }
626 void EC_POINT_free(EC_POINT* point) { glob_libcrypto.api_EC_POINT_free(point); }
627 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); }
628 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); }
629
630 EC_KEY* EC_KEY_new_by_curve_name(int nid) { return glob_libcrypto.api_EC_KEY_new_by_curve_name(nid); }
631 void EC_KEY_free(EC_KEY* key) { glob_libcrypto.api_EC_KEY_free(key); }
632 const EC_GROUP* EC_KEY_get0_group(const EC_KEY* key) { return glob_libcrypto.api_EC_KEY_get0_group(key); }
633 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); }
634 const EC_POINT* EC_KEY_get0_public_key(const EC_KEY* key) { return glob_libcrypto.api_EC_KEY_get0_public_key(key); }
635 int EC_KEY_set_public_key(EC_KEY* key, const EC_POINT* pub) { return glob_libcrypto.api_EC_KEY_set_public_key(key, pub); }
636 int EC_KEY_generate_key(EC_KEY* key) { return glob_libcrypto.api_EC_KEY_generate_key(key); }
637
638 const BIGNUM* BN_value_one(void) { return glob_libcrypto.api_BN_value_one(); }
639 int BN_set_word(BIGNUM* a, BN_ULONG w) { return glob_libcrypto.api_BN_set_word(a, w); }
640 BN_CTX* BN_CTX_new(void) { return glob_libcrypto.api_BN_CTX_new(); }
641 void BN_CTX_free(BN_CTX* c) { glob_libcrypto.api_BN_CTX_free(c); }
642 int BN_rand(BIGNUM* rnd, int bits, int top, int bottom) { return glob_libcrypto.api_BN_rand(rnd, bits, top, bottom); }
643 int BN_num_bits(const BIGNUM* a) { return glob_libcrypto.api_BN_num_bits(a); }
644 BIGNUM* BN_new(void) { return glob_libcrypto.api_BN_new(); }
645 void BN_clear_free(BIGNUM* a) { glob_libcrypto.api_BN_clear_free(a); }
646 BIGNUM* BN_bin2bn(const unsigned char* s, int len, BIGNUM* ret) { return glob_libcrypto.api_BN_bin2bn(s, len, ret); }
647 int BN_bn2bin(const BIGNUM* a, unsigned char* to) { return glob_libcrypto.api_BN_bn2bin(a, to); }
648 int BN_sub(BIGNUM* r, const BIGNUM* a, const BIGNUM* b) { return glob_libcrypto.api_BN_sub(r, a, b); }
649 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); }
650 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); }
651
652 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); }
653 ECDSA_SIG* ECDSA_SIG_new(void) { return glob_libcrypto.api_ECDSA_SIG_new(); }
654 void ECDSA_SIG_free(ECDSA_SIG* sig) { glob_libcrypto.api_ECDSA_SIG_free(sig); }
655 void ECDSA_SIG_get0(const ECDSA_SIG* sig, const BIGNUM** pr, const BIGNUM** ps) { glob_libcrypto.api_ECDSA_SIG_get0(sig, pr, ps); }
656 int ECDSA_SIG_set0(ECDSA_SIG* sig, BIGNUM* r, BIGNUM* s) { return glob_libcrypto.api_ECDSA_SIG_set0(sig, r, s); }
657 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); }
658 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); }
659
660 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); }
661 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); }
662 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); }
663 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); }
664
665 void ENGINE_load_builtin_engines(void) { glob_libcrypto.api_ENGINE_load_builtin_engines(); }
666 int ENGINE_register_all_complete(void) { return glob_libcrypto.api_ENGINE_register_all_complete(); }
667
668 int RAND_bytes(unsigned char* buf, int num) { return glob_libcrypto.api_RAND_bytes(buf, num); }
669
670 #endif
671