2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 /* explicit system call and C library trace function, for those who miss strace
9 #include "xioconfig.h" /* what features are enabled */
11 #if WITH_SYCLS && WITH_OPENSSL
13 #include "sysincludes.h"
24 #if HAVE_OPENSSL_INIT_SSL
25 /* OpenBSD 7.2 does not know OPENSSL_INIT_SETTING */
26 int sycOPENSSL_init_ssl(uint64_t opts
, const void *settings
) {
28 Debug2("OPENSSL_init_ssl("F_uint64_t
", %p)", opts
, settings
);
29 result
= OPENSSL_init_ssl(opts
, settings
);
30 Debug1("OPENSSL_init_ssl() -> %d", result
);
35 #if !(defined(HAVE_OPENSSL_INIT_SSL) && defined(HAVE_OPENSSL_INIT_new))
36 void sycSSL_load_error_strings(void) {
37 Debug("SSL_load_error_strings()");
38 SSL_load_error_strings();
39 Debug("SSL_load_error_strings() ->");
43 #if HAVE_SSL_library_init
44 int sycSSL_library_init(void) {
46 Debug("SSL_library_init()");
47 result
= SSL_library_init();
48 Debug1("SSL_library_init() -> %d", result
);
53 #if HAVE_TLS_client_method
54 const SSL_METHOD
*sycTLS_client_method(void) {
55 const SSL_METHOD
*result
;
56 Debug("TLS_client_method()");
57 result
= TLS_client_method();
58 Debug1("TLS_client_method() -> %p", result
);
63 #if HAVE_TLS_server_method
64 const SSL_METHOD
*sycTLS_server_method(void) {
65 const SSL_METHOD
*result
;
66 Debug("TLS_server_method()");
67 result
= TLS_server_method();
68 Debug1("TLS_server_method() -> %p", result
);
73 #if HAVE_SSLv2_client_method
74 const SSL_METHOD
*sycSSLv2_client_method(void) {
75 const SSL_METHOD
*result
;
76 Debug("SSLv2_client_method()");
77 result
= SSLv2_client_method();
78 Debug1("SSLv2_client_method() -> %p", result
);
83 #if HAVE_SSLv2_server_method
84 const SSL_METHOD
*sycSSLv2_server_method(void) {
85 const SSL_METHOD
*result
;
86 Debug("SSLv2_server_method()");
87 result
= SSLv2_server_method();
88 Debug1("SSLv2_server_method() -> %p", result
);
93 #if HAVE_SSLv3_client_method
94 const SSL_METHOD
*sycSSLv3_client_method(void) {
95 const SSL_METHOD
*result
;
96 Debug("SSLv3_client_method()");
97 result
= SSLv3_client_method();
98 Debug1("SSLv3_client_method() -> %p", result
);
103 #if HAVE_SSLv3_server_method
104 const SSL_METHOD
*sycSSLv3_server_method(void) {
105 const SSL_METHOD
*result
;
106 Debug("SSLv3_server_method()");
107 result
= SSLv3_server_method();
108 Debug1("SSLv3_server_method() -> %p", result
);
113 const SSL_METHOD
*sycSSLv23_client_method(void) {
114 const SSL_METHOD
*result
;
115 Debug("SSLv23_client_method()");
116 result
= SSLv23_client_method();
117 Debug1("SSLv23_client_method() -> %p", result
);
121 const SSL_METHOD
*sycSSLv23_server_method(void) {
122 const SSL_METHOD
*result
;
123 Debug("SSLv23_server_method()");
124 result
= SSLv23_server_method();
125 Debug1("SSLv23_server_method() -> %p", result
);
129 #if HAVE_TLSv1_client_method
130 const SSL_METHOD
*sycTLSv1_client_method(void) {
131 const SSL_METHOD
*result
;
132 Debug("TLSv1_client_method()");
133 result
= TLSv1_client_method();
134 Debug1("TLSv1_client_method() -> %p", result
);
139 #if HAVE_TLSv1_server_method
140 const SSL_METHOD
*sycTLSv1_server_method(void) {
141 const SSL_METHOD
*result
;
142 Debug("TLSv1_server_method()");
143 result
= TLSv1_server_method();
144 Debug1("TLSv1_server_method() -> %p", result
);
149 #if HAVE_TLSv1_1_client_method
150 const SSL_METHOD
*sycTLSv1_1_client_method(void) {
151 const SSL_METHOD
*result
;
152 Debug("TLSv1_1_client_method()");
153 result
= TLSv1_1_client_method();
154 Debug1("TLSv1_1_client_method() -> %p", result
);
159 #if HAVE_TLSv1_1_server_method
160 const SSL_METHOD
*sycTLSv1_1_server_method(void) {
161 const SSL_METHOD
*result
;
162 Debug("TLSv1_1_server_method()");
163 result
= TLSv1_1_server_method();
164 Debug1("TLSv1_1_server_method() -> %p", result
);
169 #if HAVE_TLSv1_2_client_method
170 const SSL_METHOD
*sycTLSv1_2_client_method(void) {
171 const SSL_METHOD
*result
;
172 Debug("TLSv1_2_client_method()");
173 result
= TLSv1_2_client_method();
174 Debug1("TLSv1_2_client_method() -> %p", result
);
179 #if HAVE_TLSv1_2_server_method
180 const SSL_METHOD
*sycTLSv1_2_server_method(void) {
181 const SSL_METHOD
*result
;
182 Debug("TLSv1_2_server_method()");
183 result
= TLSv1_2_server_method();
184 Debug1("TLSv1_2_server_method() -> %p", result
);
189 #if HAVE_DTLS_client_method
190 const SSL_METHOD
*sycDTLS_client_method(void) {
191 const SSL_METHOD
*result
;
192 Debug("DTLS_client_method()");
193 result
= DTLS_client_method();
194 Debug1("DTLS_client_method() -> %p", result
);
199 #if HAVE_DTLS_server_method
200 const SSL_METHOD
*sycDTLS_server_method(void) {
201 const SSL_METHOD
*result
;
202 Debug("DTLS_server_method()");
203 result
= DTLS_server_method();
204 Debug1("DTLS_server_method() -> %p", result
);
209 #if HAVE_DTLSv1_client_method
210 const SSL_METHOD
*sycDTLSv1_client_method(void) {
211 const SSL_METHOD
*result
;
212 Debug("DTLSv1_client_method()");
213 result
= DTLSv1_client_method();
214 Debug1("DTLSv1_client_method() -> %p", result
);
219 #if HAVE_DTLSv1_server_method
220 const SSL_METHOD
*sycDTLSv1_server_method(void) {
221 const SSL_METHOD
*result
;
222 Debug("DTLSv1_server_method()");
223 result
= DTLSv1_server_method();
224 Debug1("DTLSv1_server_method() -> %p", result
);
229 #if HAVE_DTLSv1_2_client_method
230 const SSL_METHOD
*sycDTLSv1_2_client_method(void) {
231 const SSL_METHOD
*result
;
232 Debug("DTLSv1_2_client_method()");
233 result
= DTLSv1_2_client_method();
234 Debug1("DTLSv1_2_client_method() -> %p", result
);
239 #if HAVE_DTLSv1_2_server_method
240 const SSL_METHOD
*sycDTLSv1_2_server_method(void) {
241 const SSL_METHOD
*result
;
242 Debug("DTLSv1_2_server_method()");
243 result
= DTLSv1_2_server_method();
244 Debug1("DTLSv1_2_server_method() -> %p", result
);
249 SSL_CTX
*sycSSL_CTX_new(const SSL_METHOD
*method
) {
251 Debug1("SSL_CTX_new(%p)", method
);
252 result
= SSL_CTX_new(method
);
253 Debug1("SSL_CTX_new() -> %p", result
);
257 SSL
*sycSSL_new(SSL_CTX
*ctx
) {
259 Debug1("SSL_new(%p)", ctx
);
260 result
= SSL_new(ctx
);
261 Debug1("SSL_new() -> %p", result
);
265 int sycSSL_CTX_load_verify_locations(SSL_CTX
*ctx
, const char *CAfile
,
266 const char *CApath
) {
268 Debug7("SSL_CTX_load_verify_locations(%p, %s%s%s, %s%s%s)", ctx
,
269 CAfile
?"\"":"", CAfile
?CAfile
:"", CAfile
?"\"":"",
270 CApath
?"\"":"", CApath
?CApath
:"", CApath
?"\"":"");
271 result
= SSL_CTX_load_verify_locations(ctx
, CAfile
, CApath
);
272 Debug1("SSL_CTX_load_verify_locations() -> %d", result
);
276 int sycSSL_CTX_use_certificate_file(SSL_CTX
*ctx
, const char *file
, int type
) {
278 Debug3("SSL_CTX_use_certificate_file(%p, \"%s\", %d)", ctx
, file
, type
);
279 result
= SSL_CTX_use_certificate_file(ctx
, file
, type
);
280 Debug1("SSL_CTX_use_certificate_file() -> %d", result
);
284 int sycSSL_CTX_use_certificate_chain_file(SSL_CTX
*ctx
, const char *file
) {
286 Debug2("SSL_CTX_use_certificate_chain_file(%p, \"%s\")", ctx
, file
);
287 result
= SSL_CTX_use_certificate_chain_file(ctx
, file
);
288 Debug1("SSL_CTX_use_certificate_chain_file() -> %d", result
);
292 int sycSSL_CTX_use_PrivateKey_file(SSL_CTX
*ctx
, const char *file
, int type
) {
294 Debug3("SSL_CTX_use_PrivateKey_file(%p, \"%s\", %d)", ctx
, file
, type
);
295 result
= SSL_CTX_use_PrivateKey_file(ctx
, file
, type
);
296 Debug1("SSL_CTX_use_PrivateKey_file() -> %d", result
);
300 void sycSSL_CTX_set_verify(SSL_CTX
*ctx
, int mode
,
301 int (*verify_callback
)(int, X509_STORE_CTX
*)) {
302 Debug3("SSL_CTX_set_verify(%p, %u, %p)", ctx
, mode
, verify_callback
);
303 SSL_CTX_set_verify(ctx
, mode
, verify_callback
);
304 Debug("SSL_CTX_set_verify() -> ");
307 int sycSSL_CTX_set_cipher_list(SSL_CTX
*ctx
, const char *str
) {
309 Debug2("SSL_CTX_set_cipher_list(%p, \"%s\")", ctx
, str
);
310 result
= SSL_CTX_set_cipher_list(ctx
, str
);
311 Debug1("SSL_CTX_set_cipher_list() -> %d", result
);
315 int sycSSL_CTX_set_tmp_dh(SSL_CTX
*ctx
, DH
*dh
) {
317 Debug2("SSL_CTX_set_tmp_dh(%p, %p)", ctx
, dh
);
318 result
= SSL_CTX_set_tmp_dh(ctx
, dh
);
319 Debug1("SSL_CTX_set_tmp_dh() -> %d", result
);
323 #if HAVE_SSL_CTX_set_tlsext_max_fragment_length || defined(SSL_CTX_set_tlsext_max_fragment_length)
324 int sycSSL_CTX_set_tlsext_max_fragment_length(SSL_CTX
*ctx
, uint8_t mode
) {
326 Debug2("SSL_CTX_set_tlsext_max_fragment_length(%p, %u)", ctx
, mode
);
327 result
= SSL_CTX_set_tlsext_max_fragment_length(ctx
, mode
);
328 Debug1("SSL_CTX_set_tlsext_max_fragment_length() -> %d", result
);
333 #if HAVE_SSL_CTX_set_max_send_fragment || defined(SSL_CTX_set_max_send_fragment)
334 int sycSSL_CTX_set_max_send_fragment(SSL_CTX
*ctx
, long msf
) {
336 Debug2("SSL_CTX_set_max_send_fragment(%p, %ld)", ctx
, msf
);
337 result
= SSL_CTX_set_max_send_fragment(ctx
, msf
);
338 Debug1("SSL_CTX_set_max_send_fragment() -> %d", result
);
343 int sycSSL_set_cipher_list(SSL
*ssl
, const char *str
) {
345 Debug2("SSL_set_cipher_list(%p, \"%s\")", ssl
, str
);
346 result
= SSL_set_cipher_list(ssl
, str
);
347 Debug1("SSL_set_cipher_list() -> %d", result
);
351 long sycSSL_get_verify_result(SSL
*ssl
) {
353 Debug1("SSL_get_verify_result(%p)", ssl
);
354 result
= SSL_get_verify_result(ssl
);
355 Debug1("SSL_get_verify_result() -> %lx", result
);
359 int sycSSL_set_fd(SSL
*ssl
, int fd
) {
361 Debug2("SSL_set_fd(%p, %d)", ssl
, fd
);
362 result
= SSL_set_fd(ssl
, fd
);
363 Debug1("SSL_set_fd() -> %d", result
);
367 int sycSSL_connect(SSL
*ssl
) {
369 Debug1("SSL_connect(%p)", ssl
);
370 result
= SSL_connect(ssl
);
371 Debug1("SSL_connect() -> %d", result
);
375 int sycSSL_accept(SSL
*ssl
) {
377 Debug1("SSL_accept(%p)", ssl
);
378 result
= SSL_accept(ssl
);
379 Debug1("SSL_accept() -> %d", result
);
383 int sycSSL_read(SSL
*ssl
, void *buf
, int num
) {
385 Debug3("SSL_read(%p, %p, %d)", ssl
, buf
, num
);
386 result
= SSL_read(ssl
, buf
, num
);
387 Debug1("SSL_read() -> %d", result
);
391 int sycSSL_pending(SSL
*ssl
) {
393 Debug1("SSL_pending(%p)", ssl
);
394 result
= SSL_pending(ssl
);
395 Debug1("SSL_pending() -> %d", result
);
399 int sycSSL_write(SSL
*ssl
, const void *buf
, int num
) {
401 Debug3("SSL_write(%p, %p, %d)", ssl
, buf
, num
);
402 result
= SSL_write(ssl
, buf
, num
);
403 Debug1("SSL_write() -> %d", result
);
407 X509
*sycSSL_get_peer_certificate(SSL
*ssl
) {
409 Debug1("SSL_get_peer_certificate(%p)", ssl
);
410 result
= SSL_get_peer_certificate(ssl
);
412 Debug1("SSL_get_peer_certificate() -> %p", result
);
414 Debug("SSL_get_peer_certificate() -> NULL");
419 int sycSSL_shutdown(SSL
*ssl
) {
421 Debug1("SSL_shutdown(%p)", ssl
);
422 result
= SSL_shutdown(ssl
);
423 Debug1("SSL_shutdown() -> %d", result
);
427 void sycSSL_CTX_free(SSL_CTX
*ctx
) {
428 Debug1("SSL_CTX_free(%p)", ctx
);
430 Debug("SSL_CTX_free() -> void");
434 void sycSSL_free(SSL
*ssl
) {
435 Debug1("SSL_free(%p)", ssl
);
437 Debug("SSL_free() -> void");
441 #if !defined(OPENSSL_NO_EGD) && HAVE_RAND_egd
442 int sycRAND_egd(const char *path
) {
444 Debug1("RAND_egd(\"%s\")", path
);
445 result
= RAND_egd(path
);
446 Debug1("RAND_egd() -> %d", result
);
451 DH
*sycPEM_read_bio_DHparams(BIO
*bp
, DH
**x
, pem_password_cb
*cb
, void *u
) {
453 Debug4("PEM_read_bio_DHparams(%p, %p, %p, %p)",
455 result
= PEM_read_bio_DHparams(bp
, x
, cb
, u
);
457 /*Debug2("PEM_read_bio_DHparams(, {%p},,) -> %p", *x, result);*/
458 Debug1("PEM_read_bio_DHparams() -> %p", result
);
460 Debug("PEM_read_bio_DHparams() -> NULL");
465 BIO
*sycBIO_new_file(const char *filename
, const char *mode
) {
467 Debug2("BIO_new_file(\"%s\", \"%s\")", filename
, mode
);
468 result
= BIO_new_file(filename
, mode
);
470 Debug1("BIO_new_file() -> %p", result
);
472 Debug("BIO_new_file() -> NULL");
478 int sycFIPS_mode_set(int onoff
) {
480 Debug1("FIPS_mode_set(%d)", onoff
);
481 result
= FIPS_mode_set(onoff
);
482 Debug1("FIPS_mode_set() -> %d", result
);
485 #endif /* WITH_FIPS */
487 #if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined(OPENSSL_NO_COMP)
488 const COMP_METHOD
*sycSSL_get_current_compression(SSL
*ssl
) {
489 const COMP_METHOD
*result
;
490 Debug1("SSL_get_current_compression(%p)", ssl
);
491 result
= SSL_get_current_compression(ssl
);
493 Debug1("SSL_get_current_compression() -> %p", result
);
495 Debug("SSL_get_current_compression() -> NULL");
500 const COMP_METHOD
*sycSSL_get_current_expansion(SSL
*ssl
) {
501 const COMP_METHOD
*result
;
502 Debug1("SSL_get_current_expansion(%p)", ssl
);
503 result
= SSL_get_current_expansion(ssl
);
505 Debug1("SSL_get_current_expansion() -> %p", result
);
507 Debug("SSL_get_current_expansion() -> NULL");
512 const char *sycSSL_COMP_get_name(const COMP_METHOD
*comp
) {
514 Debug1("SSL_COMP_get_name(%p)", comp
);
515 result
= SSL_COMP_get_name(comp
);
517 Debug1("SSL_COMP_get_name() -> \"%s\"", result
);
519 Debug("SSL_COMP_get_name() -> NULL");
525 #endif /* WITH_SYCLS && WITH_OPENSSL */