More corrections to test.sh: language; netstat; reuseaddr; usleep; force IPv4; timeout
[socat.git] / sslcls.c
blobf9ce3890933683d50b7750e0aaef5e5bb5b6bba6
1 /* source: sslcls.c */
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
6 */
8 #include "config.h"
9 #include "xioconfig.h" /* what features are enabled */
11 #if WITH_SYCLS && WITH_OPENSSL
13 #include "sysincludes.h"
15 #include "mytypes.h"
16 #include "compat.h"
17 #include "errno.h"
19 #include "error.h"
20 #include "filan.h"
21 #include "sysutils.h"
22 #include "sycls.h"
24 void sycSSL_load_error_strings(void) {
25 Debug("SSL_load_error_strings()");
26 SSL_load_error_strings();
27 Debug("SSL_load_error_strings() ->");
30 int sycSSL_library_init(void) {
31 int result;
32 Debug("SSL_library_init()");
33 result = SSL_library_init();
34 Debug1("SSL_library_init() -> %d", result);
35 return result;
38 #if HAVE_SSLv2_client_method
39 const SSL_METHOD *sycSSLv2_client_method(void) {
40 const SSL_METHOD *result;
41 Debug("SSLv2_client_method()");
42 result = SSLv2_client_method();
43 Debug1("SSLv2_client_method() -> %p", result);
44 return result;
46 #endif
48 #if HAVE_SSLv2_server_method
49 const SSL_METHOD *sycSSLv2_server_method(void) {
50 const SSL_METHOD *result;
51 Debug("SSLv2_server_method()");
52 result = SSLv2_server_method();
53 Debug1("SSLv2_server_method() -> %p", result);
54 return result;
56 #endif
58 #if HAVE_SSLv3_client_method
59 const SSL_METHOD *sycSSLv3_client_method(void) {
60 const SSL_METHOD *result;
61 Debug("SSLv3_client_method()");
62 result = SSLv3_client_method();
63 Debug1("SSLv3_client_method() -> %p", result);
64 return result;
66 #endif
68 #if HAVE_SSLv3_server_method
69 const SSL_METHOD *sycSSLv3_server_method(void) {
70 const SSL_METHOD *result;
71 Debug("SSLv3_server_method()");
72 result = SSLv3_server_method();
73 Debug1("SSLv3_server_method() -> %p", result);
74 return result;
76 #endif
78 const SSL_METHOD *sycSSLv23_client_method(void) {
79 const SSL_METHOD *result;
80 Debug("SSLv23_client_method()");
81 result = SSLv23_client_method();
82 Debug1("SSLv23_client_method() -> %p", result);
83 return result;
86 const SSL_METHOD *sycSSLv23_server_method(void) {
87 const SSL_METHOD *result;
88 Debug("SSLv23_server_method()");
89 result = SSLv23_server_method();
90 Debug1("SSLv23_server_method() -> %p", result);
91 return result;
94 #if HAVE_TLSv1_client_method
95 const SSL_METHOD *sycTLSv1_client_method(void) {
96 const SSL_METHOD *result;
97 Debug("TLSv1_client_method()");
98 result = TLSv1_client_method();
99 Debug1("TLSv1_client_method() -> %p", result);
100 return result;
102 #endif
104 #if HAVE_TLSv1_server_method
105 const SSL_METHOD *sycTLSv1_server_method(void) {
106 const SSL_METHOD *result;
107 Debug("TLSv1_server_method()");
108 result = TLSv1_server_method();
109 Debug1("TLSv1_server_method() -> %p", result);
110 return result;
112 #endif
114 #if HAVE_TLSv1_1_client_method
115 const SSL_METHOD *sycTLSv1_1_client_method(void) {
116 const SSL_METHOD *result;
117 Debug("TLSv1_1_client_method()");
118 result = TLSv1_1_client_method();
119 Debug1("TLSv1_1_client_method() -> %p", result);
120 return result;
122 #endif
124 #if HAVE_TLSv1_1_server_method
125 const SSL_METHOD *sycTLSv1_1_server_method(void) {
126 const SSL_METHOD *result;
127 Debug("TLSv1_1_server_method()");
128 result = TLSv1_1_server_method();
129 Debug1("TLSv1_1_server_method() -> %p", result);
130 return result;
132 #endif
134 #if HAVE_TLSv1_2_client_method
135 const SSL_METHOD *sycTLSv1_2_client_method(void) {
136 const SSL_METHOD *result;
137 Debug("TLSv1_2_client_method()");
138 result = TLSv1_2_client_method();
139 Debug1("TLSv1_2_client_method() -> %p", result);
140 return result;
142 #endif
144 #if HAVE_TLSv1_2_server_method
145 const SSL_METHOD *sycTLSv1_2_server_method(void) {
146 const SSL_METHOD *result;
147 Debug("TLSv1_2_server_method()");
148 result = TLSv1_2_server_method();
149 Debug1("TLSv1_2_server_method() -> %p", result);
150 return result;
152 #endif
154 #if HAVE_DTLSv1_client_method
155 const SSL_METHOD *sycDTLSv1_client_method(void) {
156 const SSL_METHOD *result;
157 Debug("DTLSv1_client_method()");
158 result = DTLSv1_client_method();
159 Debug1("DTLSv1_client_method() -> %p", result);
160 return result;
162 #endif
164 #if HAVE_DTLSv1_server_method
165 const SSL_METHOD *sycDTLSv1_server_method(void) {
166 const SSL_METHOD *result;
167 Debug("DTLSv1_server_method()");
168 result = DTLSv1_server_method();
169 Debug1("DTLSv1_server_method() -> %p", result);
170 return result;
172 #endif
174 SSL_CTX *sycSSL_CTX_new(const SSL_METHOD *method) {
175 SSL_CTX *result;
176 Debug1("SSL_CTX_new(%p)", method);
177 result = SSL_CTX_new(method);
178 Debug1("SSL_CTX_new() -> %p", result);
179 return result;
182 SSL *sycSSL_new(SSL_CTX *ctx) {
183 SSL *result;
184 Debug1("SSL_new(%p)", ctx);
185 result = SSL_new(ctx);
186 Debug1("SSL_new() -> %p", result);
187 return result;
190 int sycSSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
191 const char *CApath) {
192 int result;
193 Debug7("SSL_CTX_load_verify_locations(%p, %s%s%s, %s%s%s)", ctx,
194 CAfile?"\"":"", CAfile?CAfile:"", CAfile?"\"":"",
195 CApath?"\"":"", CApath?CApath:"", CApath?"\"":"");
196 result = SSL_CTX_load_verify_locations(ctx, CAfile, CApath);
197 Debug1("SSL_CTX_load_verify_locations() -> %d", result);
198 return result;
201 int sycSSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) {
202 int result;
203 Debug3("SSL_CTX_use_certificate_file(%p, \"%s\", %d)", ctx, file, type);
204 result = SSL_CTX_use_certificate_file(ctx, file, type);
205 Debug1("SSL_CTX_use_certificate_file() -> %d", result);
206 return result;
209 int sycSSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) {
210 int result;
211 Debug2("SSL_CTX_use_certificate_chain_file(%p, \"%s\")", ctx, file);
212 result = SSL_CTX_use_certificate_chain_file(ctx, file);
213 Debug1("SSL_CTX_use_certificate_chain_file() -> %d", result);
214 return result;
217 int sycSSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
218 int result;
219 Debug3("SSL_CTX_use_PrivateKey_file(%p, \"%s\", %d)", ctx, file, type);
220 result = SSL_CTX_use_PrivateKey_file(ctx, file, type);
221 Debug1("SSL_CTX_use_PrivateKey_file() -> %d", result);
222 return result;
225 void sycSSL_CTX_set_verify(SSL_CTX *ctx, int mode,
226 int (*verify_callback)(int, X509_STORE_CTX *)) {
227 Debug3("SSL_CTX_set_verify(%p, %u, %p)", ctx, mode, verify_callback);
228 SSL_CTX_set_verify(ctx, mode, verify_callback);
229 Debug("SSL_CTX_set_verify() -> ");
232 int sycSSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
233 int result;
234 Debug2("SSL_CTX_set_cipher_list(%p, \"%s\")", ctx, str);
235 result = SSL_CTX_set_cipher_list(ctx, str);
236 Debug1("SSL_CTX_set_cipher_list() -> %d", result);
237 return result;
240 int sycSSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) {
241 int result;
242 Debug2("SSL_CTX_set_tmp_dh(%p, %p)", ctx, dh);
243 result = SSL_CTX_set_tmp_dh(ctx, dh);
244 Debug1("SSL_CTX_set_tmp_dh() -> %d", result);
245 return result;
248 int sycSSL_set_cipher_list(SSL *ssl, const char *str) {
249 int result;
250 Debug2("SSL_set_cipher_list(%p, \"%s\")", ssl, str);
251 result = SSL_set_cipher_list(ssl, str);
252 Debug1("SSL_set_cipher_list() -> %d", result);
253 return result;
256 long sycSSL_get_verify_result(SSL *ssl) {
257 long result;
258 Debug1("SSL_get_verify_result(%p)", ssl);
259 result = SSL_get_verify_result(ssl);
260 Debug1("SSL_get_verify_result() -> %lx", result);
261 return result;
264 int sycSSL_set_fd(SSL *ssl, int fd) {
265 int result;
266 Debug2("SSL_set_fd(%p, %d)", ssl, fd);
267 result = SSL_set_fd(ssl, fd);
268 Debug1("SSL_set_fd() -> %d", result);
269 return result;
272 int sycSSL_connect(SSL *ssl) {
273 int result;
274 Debug1("SSL_connect(%p)", ssl);
275 result = SSL_connect(ssl);
276 Debug1("SSL_connect() -> %d", result);
277 return result;
280 int sycSSL_accept(SSL *ssl) {
281 int result;
282 Debug1("SSL_accept(%p)", ssl);
283 result = SSL_accept(ssl);
284 Debug1("SSL_accept() -> %d", result);
285 return result;
288 int sycSSL_read(SSL *ssl, void *buf, int num) {
289 int result;
290 Debug3("SSL_read(%p, %p, %d)", ssl, buf, num);
291 result = SSL_read(ssl, buf, num);
292 Debug1("SSL_read() -> %d", result);
293 return result;
296 int sycSSL_pending(SSL *ssl) {
297 int result;
298 Debug1("SSL_pending(%p)", ssl);
299 result = SSL_pending(ssl);
300 Debug1("SSL_pending() -> %d", result);
301 return result;
304 int sycSSL_write(SSL *ssl, const void *buf, int num) {
305 int result;
306 Debug3("SSL_write(%p, %p, %d)", ssl, buf, num);
307 result = SSL_write(ssl, buf, num);
308 Debug1("SSL_write() -> %d", result);
309 return result;
312 X509 *sycSSL_get_peer_certificate(SSL *ssl) {
313 X509 *result;
314 Debug1("SSL_get_peer_certificate(%p)", ssl);
315 result = SSL_get_peer_certificate(ssl);
316 if (result) {
317 Debug1("SSL_get_peer_certificate() -> %p", result);
318 } else {
319 Debug("SSL_get_peer_certificate() -> NULL");
321 return result;
324 int sycSSL_shutdown(SSL *ssl) {
325 int result;
326 Debug1("SSL_shutdown(%p)", ssl);
327 result = SSL_shutdown(ssl);
328 Debug1("SSL_shutdown() -> %d", result);
329 return result;
332 void sycSSL_CTX_free(SSL_CTX *ctx) {
333 Debug1("SSL_CTX_free(%p)", ctx);
334 SSL_CTX_free(ctx);
335 Debug("SSL_CTX_free() -> void");
336 return;
339 void sycSSL_free(SSL *ssl) {
340 Debug1("SSL_free(%p)", ssl);
341 SSL_free(ssl);
342 Debug("SSL_free() -> void");
343 return;
346 #if !defined(OPENSSL_NO_EGD) && HAVE_RAND_egd
347 int sycRAND_egd(const char *path) {
348 int result;
349 Debug1("RAND_egd(\"%s\")", path);
350 result = RAND_egd(path);
351 Debug1("RAND_egd() -> %d", result);
352 return result;
354 #endif
356 DH *sycPEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u) {
357 DH *result;
358 Debug4("PEM_read_bio_DHparams(%p, %p, %p, %p)",
359 bp, x, cb, u);
360 result = PEM_read_bio_DHparams(bp, x, cb, u);
361 if (result) {
362 /*Debug2("PEM_read_bio_DHparams(, {%p},,) -> %p", *x, result);*/
363 Debug1("PEM_read_bio_DHparams() -> %p", result);
364 } else {
365 Debug("PEM_read_bio_DHparams() -> NULL");
367 return result;
370 BIO *sycBIO_new_file(const char *filename, const char *mode) {
371 BIO *result;
372 Debug2("BIO_new_file(\"%s\", \"%s\")", filename, mode);
373 result = BIO_new_file(filename, mode);
374 if (result) {
375 Debug1("BIO_new_file() -> %p", result);
376 } else {
377 Debug("BIO_new_file() -> NULL");
379 return result;
382 #if WITH_FIPS
383 int sycFIPS_mode_set(int onoff) {
384 int result;
385 Debug1("FIPS_mode_set(%d)", onoff);
386 result = FIPS_mode_set(onoff);
387 Debug1("FIPS_mode_set() -> %d", result);
388 return result;
390 #endif /* WITH_FIPS */
392 #if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined(OPENSSL_NO_COMP)
393 const COMP_METHOD *sycSSL_get_current_compression(SSL *ssl) {
394 const COMP_METHOD *result;
395 Debug1("SSL_get_current_compression(%p)", ssl);
396 result = SSL_get_current_compression(ssl);
397 if (result) {
398 Debug1("SSL_get_current_compression() -> %p", result);
399 } else {
400 Debug("SSL_get_current_compression() -> NULL");
402 return result;
405 const COMP_METHOD *sycSSL_get_current_expansion(SSL *ssl) {
406 const COMP_METHOD *result;
407 Debug1("SSL_get_current_expansion(%p)", ssl);
408 result = SSL_get_current_expansion(ssl);
409 if (result) {
410 Debug1("SSL_get_current_expansion() -> %p", result);
411 } else {
412 Debug("SSL_get_current_expansion() -> NULL");
414 return result;
417 const char *sycSSL_COMP_get_name(const COMP_METHOD *comp) {
418 const char *result;
419 Debug1("SSL_COMP_get_name(%p)", comp);
420 result = SSL_COMP_get_name(comp);
421 if (result) {
422 Debug1("SSL_COMP_get_name() -> \"%s\"", result);
423 } else {
424 Debug("SSL_COMP_get_name() -> NULL");
426 return result;
428 #endif
430 #endif /* WITH_SYCLS && WITH_OPENSSL */