version 1.7.3.0
[socat.git] / sslcls.c
blob6ddc0772838fe6a2358ed6df136bdaa511565f82
1 /* source: sslcls.c */
2 /* Copyright Gerhard Rieger */
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 const SSL_METHOD *sycSSLv3_client_method(void) {
59 const SSL_METHOD *result;
60 Debug("SSLv3_client_method()");
61 result = SSLv3_client_method();
62 Debug1("SSLv3_client_method() -> %p", result);
63 return result;
66 const SSL_METHOD *sycSSLv3_server_method(void) {
67 const SSL_METHOD *result;
68 Debug("SSLv3_server_method()");
69 result = SSLv3_server_method();
70 Debug1("SSLv3_server_method() -> %p", result);
71 return result;
74 const SSL_METHOD *sycSSLv23_client_method(void) {
75 const SSL_METHOD *result;
76 Debug("SSLv23_client_method()");
77 result = SSLv23_client_method();
78 Debug1("SSLv23_client_method() -> %p", result);
79 return result;
82 const SSL_METHOD *sycSSLv23_server_method(void) {
83 const SSL_METHOD *result;
84 Debug("SSLv23_server_method()");
85 result = SSLv23_server_method();
86 Debug1("SSLv23_server_method() -> %p", result);
87 return result;
90 const SSL_METHOD *sycTLSv1_client_method(void) {
91 const SSL_METHOD *result;
92 Debug("TLSv1_client_method()");
93 result = TLSv1_client_method();
94 Debug1("TLSv1_client_method() -> %p", result);
95 return result;
98 const SSL_METHOD *sycTLSv1_server_method(void) {
99 const SSL_METHOD *result;
100 Debug("TLSv1_server_method()");
101 result = TLSv1_server_method();
102 Debug1("TLSv1_server_method() -> %p", result);
103 return result;
106 #if HAVE_TLSv1_1_client_method
107 const SSL_METHOD *sycTLSv1_1_client_method(void) {
108 const SSL_METHOD *result;
109 Debug("TLSv1_1_client_method()");
110 result = TLSv1_1_client_method();
111 Debug1("TLSv1_1_client_method() -> %p", result);
112 return result;
114 #endif
116 #if HAVE_TLSv1_1_server_method
117 const SSL_METHOD *sycTLSv1_1_server_method(void) {
118 const SSL_METHOD *result;
119 Debug("TLSv1_1_server_method()");
120 result = TLSv1_1_server_method();
121 Debug1("TLSv1_1_server_method() -> %p", result);
122 return result;
124 #endif
126 #if HAVE_TLSv1_2_client_method
127 const SSL_METHOD *sycTLSv1_2_client_method(void) {
128 const SSL_METHOD *result;
129 Debug("TLSv1_2_client_method()");
130 result = TLSv1_2_client_method();
131 Debug1("TLSv1_2_client_method() -> %p", result);
132 return result;
134 #endif
136 #if HAVE_TLSv1_2_server_method
137 const SSL_METHOD *sycTLSv1_2_server_method(void) {
138 const SSL_METHOD *result;
139 Debug("TLSv1_2_server_method()");
140 result = TLSv1_2_server_method();
141 Debug1("TLSv1_2_server_method() -> %p", result);
142 return result;
144 #endif
146 const SSL_METHOD *sycDTLSv1_client_method(void) {
147 const SSL_METHOD *result;
148 Debug("DTLSv1_client_method()");
149 result = DTLSv1_client_method();
150 Debug1("DTLSv1_client_method() -> %p", result);
151 return result;
154 const SSL_METHOD *sycDTLSv1_server_method(void) {
155 const SSL_METHOD *result;
156 Debug("DTLSv1_server_method()");
157 result = DTLSv1_server_method();
158 Debug1("DTLSv1_server_method() -> %p", result);
159 return result;
162 SSL_CTX *sycSSL_CTX_new(const SSL_METHOD *method) {
163 SSL_CTX *result;
164 Debug1("SSL_CTX_new(%p)", method);
165 result = SSL_CTX_new(method);
166 Debug1("SSL_CTX_new() -> %p", result);
167 return result;
170 SSL *sycSSL_new(SSL_CTX *ctx) {
171 SSL *result;
172 Debug1("SSL_new(%p)", ctx);
173 result = SSL_new(ctx);
174 Debug1("SSL_new() -> %p", result);
175 return result;
178 int sycSSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
179 const char *CApath) {
180 int result;
181 Debug7("SSL_CTX_load_verify_locations(%p, %s%s%s, %s%s%s)", ctx,
182 CAfile?"\"":"", CAfile?CAfile:"", CAfile?"\"":"",
183 CApath?"\"":"", CApath?CApath:"", CApath?"\"":"");
184 result = SSL_CTX_load_verify_locations(ctx, CAfile, CApath);
185 Debug1("SSL_CTX_load_verify_locations() -> %d", result);
186 return result;
189 int sycSSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) {
190 int result;
191 Debug3("SSL_CTX_use_certificate_file(%p, \"%s\", %d)", ctx, file, type);
192 result = SSL_CTX_use_certificate_file(ctx, file, type);
193 Debug1("SSL_CTX_use_certificate_file() -> %d", result);
194 return result;
197 int sycSSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) {
198 int result;
199 Debug2("SSL_CTX_use_certificate_chain_file(%p, \"%s\")", ctx, file);
200 result = SSL_CTX_use_certificate_chain_file(ctx, file);
201 Debug1("SSL_CTX_use_certificate_chain_file() -> %d", result);
202 return result;
205 int sycSSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
206 int result;
207 Debug3("SSL_CTX_use_PrivateKey_file(%p, \"%s\", %d)", ctx, file, type);
208 result = SSL_CTX_use_PrivateKey_file(ctx, file, type);
209 Debug1("SSL_CTX_use_PrivateKey_file() -> %d", result);
210 return result;
213 void sycSSL_CTX_set_verify(SSL_CTX *ctx, int mode,
214 int (*verify_callback)(int, X509_STORE_CTX *)) {
215 Debug3("SSL_CTX_set_verify(%p, %u, %p)", ctx, mode, verify_callback);
216 SSL_CTX_set_verify(ctx, mode, verify_callback);
217 Debug("SSL_CTX_set_verify() -> ");
220 int sycSSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
221 int result;
222 Debug2("SSL_CTX_set_cipher_list(%p, \"%s\")", ctx, str);
223 result = SSL_CTX_set_cipher_list(ctx, str);
224 Debug1("SSL_CTX_set_cipher_list() -> %d", result);
225 return result;
228 int sycSSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) {
229 int result;
230 Debug2("SSL_CTX_set_tmp_dh(%p, %p)", ctx, dh);
231 result = SSL_CTX_set_tmp_dh(ctx, dh);
232 Debug1("SSL_CTX_set_tmp_dh() -> %d", result);
233 return result;
236 int sycSSL_set_cipher_list(SSL *ssl, const char *str) {
237 int result;
238 Debug2("SSL_set_cipher_list(%p, \"%s\")", ssl, str);
239 result = SSL_set_cipher_list(ssl, str);
240 Debug1("SSL_set_cipher_list() -> %d", result);
241 return result;
244 long sycSSL_get_verify_result(SSL *ssl) {
245 long result;
246 Debug1("SSL_get_verify_result(%p)", ssl);
247 result = SSL_get_verify_result(ssl);
248 Debug1("SSL_get_verify_result() -> %lx", result);
249 return result;
252 int sycSSL_set_fd(SSL *ssl, int fd) {
253 int result;
254 Debug2("SSL_set_fd(%p, %d)", ssl, fd);
255 result = SSL_set_fd(ssl, fd);
256 Debug1("SSL_set_fd() -> %d", result);
257 return result;
260 int sycSSL_connect(SSL *ssl) {
261 int result;
262 Debug1("SSL_connect(%p)", ssl);
263 result = SSL_connect(ssl);
264 Debug1("SSL_connect() -> %d", result);
265 return result;
268 int sycSSL_accept(SSL *ssl) {
269 int result;
270 Debug1("SSL_accept(%p)", ssl);
271 result = SSL_accept(ssl);
272 Debug1("SSL_accept() -> %d", result);
273 return result;
276 int sycSSL_read(SSL *ssl, void *buf, int num) {
277 int result;
278 Debug3("SSL_read(%p, %p, %d)", ssl, buf, num);
279 result = SSL_read(ssl, buf, num);
280 Debug1("SSL_read() -> %d", result);
281 return result;
284 int sycSSL_pending(SSL *ssl) {
285 int result;
286 Debug1("SSL_pending(%p)", ssl);
287 result = SSL_pending(ssl);
288 Debug1("SSL_pending() -> %d", result);
289 return result;
292 int sycSSL_write(SSL *ssl, const void *buf, int num) {
293 int result;
294 Debug3("SSL_write(%p, %p, %d)", ssl, buf, num);
295 result = SSL_write(ssl, buf, num);
296 Debug1("SSL_write() -> %d", result);
297 return result;
300 X509 *sycSSL_get_peer_certificate(SSL *ssl) {
301 X509 *result;
302 Debug1("SSL_get_peer_certificate(%p)", ssl);
303 result = SSL_get_peer_certificate(ssl);
304 if (result) {
305 Debug1("SSL_get_peer_certificate() -> %p", result);
306 } else {
307 Debug("SSL_get_peer_certificate() -> NULL");
309 return result;
312 int sycSSL_shutdown(SSL *ssl) {
313 int result;
314 Debug1("SSL_shutdown(%p)", ssl);
315 result = SSL_shutdown(ssl);
316 Debug1("SSL_shutdown() -> %d", result);
317 return result;
320 void sycSSL_CTX_free(SSL_CTX *ctx) {
321 Debug1("SSL_CTX_free(%p)", ctx);
322 SSL_CTX_free(ctx);
323 Debug("SSL_CTX_free() -> void");
324 return;
327 void sycSSL_free(SSL *ssl) {
328 Debug1("SSL_free(%p)", ssl);
329 SSL_free(ssl);
330 Debug("SSL_free() -> void");
331 return;
334 int sycRAND_egd(const char *path) {
335 int result;
336 Debug1("RAND_egd(\"%s\")", path);
337 result = RAND_egd(path);
338 Debug1("RAND_egd() -> %d", result);
339 return result;
342 DH *sycPEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u) {
343 DH *result;
344 Debug4("PEM_read_bio_DHparams(%p, %p, %p, %p)",
345 bp, x, cb, u);
346 result = PEM_read_bio_DHparams(bp, x, cb, u);
347 if (result) {
348 /*Debug2("PEM_read_bio_DHparams(, {%p},,) -> %p", *x, result);*/
349 Debug1("PEM_read_bio_DHparams() -> %p", result);
350 } else {
351 Debug("PEM_read_bio_DHparams() -> NULL");
353 return result;
356 BIO *sycBIO_new_file(const char *filename, const char *mode) {
357 BIO *result;
358 Debug2("BIO_new_file(\"%s\", \"%s\")", filename, mode);
359 result = BIO_new_file(filename, mode);
360 if (result) {
361 Debug1("BIO_new_file() -> %p", result);
362 } else {
363 Debug("BIO_new_file() -> NULL");
365 return result;
368 #if WITH_FIPS
369 int sycFIPS_mode_set(int onoff) {
370 int result;
371 Debug1("FIPS_mode_set(%d)", onoff);
372 result = FIPS_mode_set(onoff);
373 Debug1("FIPS_mode_set() -> %d", result);
374 return result;
376 #endif /* WITH_FIPS */
378 #if OPENSSL_VERSION_NUMBER >= 0x00908000L
379 const COMP_METHOD *sycSSL_get_current_compression(SSL *ssl) {
380 const COMP_METHOD *result;
381 Debug1("SSL_get_current_compression(%p)", ssl);
382 result = SSL_get_current_compression(ssl);
383 if (result) {
384 Debug1("SSL_get_current_compression() -> %p", result);
385 } else {
386 Debug("SSL_get_current_compression() -> NULL");
388 return result;
391 const COMP_METHOD *sycSSL_get_current_expansion(SSL *ssl) {
392 const COMP_METHOD *result;
393 Debug1("SSL_get_current_expansion(%p)", ssl);
394 result = SSL_get_current_expansion(ssl);
395 if (result) {
396 Debug1("SSL_get_current_expansion() -> %p", result);
397 } else {
398 Debug("SSL_get_current_expansion() -> NULL");
400 return result;
403 const char *sycSSL_COMP_get_name(const COMP_METHOD *comp) {
404 const char *result;
405 Debug1("SSL_COMP_get_name(%p)", comp);
406 result = SSL_COMP_get_name(comp);
407 if (result) {
408 Debug1("SSL_COMP_get_name() -> \"%s\"", result);
409 } else {
410 Debug("SSL_COMP_get_name() -> NULL");
412 return result;
414 #endif
416 #endif /* WITH_SYCLS && WITH_OPENSSL */