add listen-timeout to function as an accept timeout
[socat/sam.git] / sslcls.c
blob46410446cc26a3d31132dadda87662ad720f32d2
1 /* source: sslcls.c */
2 /* Copyright Gerhard Rieger 2001-2007 */
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 SSL_METHOD *sycSSLv2_client_method(void) {
39 SSL_METHOD *result;
40 Debug("SSLv2_client_method()");
41 result = SSLv2_client_method();
42 Debug1("SSLv2_client_method() -> %p", result);
43 return result;
46 SSL_METHOD *sycSSLv2_server_method(void) {
47 SSL_METHOD *result;
48 Debug("SSLv2_server_method()");
49 result = SSLv2_server_method();
50 Debug1("SSLv2_server_method() -> %p", result);
51 return result;
54 SSL_METHOD *sycSSLv3_client_method(void) {
55 SSL_METHOD *result;
56 Debug("SSLv3_client_method()");
57 result = SSLv3_client_method();
58 Debug1("SSLv3_client_method() -> %p", result);
59 return result;
62 SSL_METHOD *sycSSLv3_server_method(void) {
63 SSL_METHOD *result;
64 Debug("SSLv3_server_method()");
65 result = SSLv3_server_method();
66 Debug1("SSLv3_server_method() -> %p", result);
67 return result;
70 SSL_METHOD *sycSSLv23_client_method(void) {
71 SSL_METHOD *result;
72 Debug("SSLv23_client_method()");
73 result = SSLv23_client_method();
74 Debug1("SSLv23_client_method() -> %p", result);
75 return result;
78 SSL_METHOD *sycSSLv23_server_method(void) {
79 SSL_METHOD *result;
80 Debug("SSLv23_server_method()");
81 result = SSLv23_server_method();
82 Debug1("SSLv23_server_method() -> %p", result);
83 return result;
86 SSL_METHOD *sycTLSv1_client_method(void) {
87 SSL_METHOD *result;
88 Debug("TLSv1_client_method()");
89 result = TLSv1_client_method();
90 Debug1("TLSv1_client_method() -> %p", result);
91 return result;
94 SSL_METHOD *sycTLSv1_server_method(void) {
95 SSL_METHOD *result;
96 Debug("TLSv1_server_method()");
97 result = TLSv1_server_method();
98 Debug1("TLSv1_server_method() -> %p", result);
99 return result;
102 SSL_CTX *sycSSL_CTX_new(SSL_METHOD *method) {
103 SSL_CTX *result;
104 Debug1("SSL_CTX_new(%p)", method);
105 result = SSL_CTX_new(method);
106 Debug1("SSL_CTX_new() -> %p", result);
107 return result;
110 SSL *sycSSL_new(SSL_CTX *ctx) {
111 SSL *result;
112 Debug1("SSL_new(%p)", ctx);
113 result = SSL_new(ctx);
114 Debug1("SSL_new() -> %p", result);
115 return result;
118 int sycSSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
119 const char *CApath) {
120 int result;
121 Debug7("SSL_CTX_load_verify_locations(%p, %s%s%s, %s%s%s)", ctx,
122 CAfile?"\"":"", CAfile?CAfile:NULL, CAfile?"\"":"",
123 CApath?"\"":"", CApath?CApath:NULL, CApath?"\"":"");
124 result = SSL_CTX_load_verify_locations(ctx, CAfile, CApath);
125 Debug1("SSL_CTX_load_verify_locations() -> %d", result);
126 return result;
129 int sycSSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) {
130 int result;
131 Debug3("SSL_CTX_use_certificate_file(%p, \"%s\", %d)", ctx, file, type);
132 result = SSL_CTX_use_certificate_file(ctx, file, type);
133 Debug1("SSL_CTX_use_certificate_file() -> %d", result);
134 return result;
137 int sycSSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) {
138 int result;
139 Debug2("SSL_CTX_use_certificate_chain_file(%p, \"%s\")", ctx, file);
140 result = SSL_CTX_use_certificate_chain_file(ctx, file);
141 Debug1("SSL_CTX_use_certificate_chain_file() -> %d", result);
142 return result;
145 int sycSSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
146 int result;
147 Debug3("SSL_CTX_use_PrivateKey_file(%p, \"%s\", %d)", ctx, file, type);
148 result = SSL_CTX_use_PrivateKey_file(ctx, file, type);
149 Debug1("SSL_CTX_use_PrivateKey_file() -> %d", result);
150 return result;
153 void sycSSL_CTX_set_verify(SSL_CTX *ctx, int mode,
154 int (*verify_callback)(int, X509_STORE_CTX *)) {
155 Debug3("SSL_CTX_set_verify(%p, %u, %p)", ctx, mode, verify_callback);
156 SSL_CTX_set_verify(ctx, mode, verify_callback);
157 Debug("SSL_CTX_set_verify() -> ");
160 int sycSSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
161 int result;
162 Debug2("SSL_CTX_set_cipher_list(%p, \"%s\")", ctx, str);
163 result = SSL_CTX_set_cipher_list(ctx, str);
164 Debug1("SSL_CTX_set_cipher_list() -> %d", result);
165 return result;
168 int sycSSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) {
169 int result;
170 Debug2("SSL_CTX_set_tmp_dh(%p, %p)", ctx, dh);
171 result = SSL_CTX_set_tmp_dh(ctx, dh);
172 Debug1("SSL_CTX_set_tmp_dh() -> %d", result);
173 return result;
176 int sycSSL_set_cipher_list(SSL *ssl, const char *str) {
177 int result;
178 Debug2("SSL_set_cipher_list(%p, \"%s\")", ssl, str);
179 result = SSL_set_cipher_list(ssl, str);
180 Debug1("SSL_set_cipher_list() -> %d", result);
181 return result;
184 long sycSSL_get_verify_result(SSL *ssl) {
185 long result;
186 Debug1("SSL_get_verify_result(%p)", ssl);
187 result = SSL_get_verify_result(ssl);
188 Debug1("SSL_get_verify_result() -> %lx", result);
189 return result;
192 int sycSSL_set_fd(SSL *ssl, int fd) {
193 int result;
194 Debug2("SSL_set_fd(%p, %d)", ssl, fd);
195 result = SSL_set_fd(ssl, fd);
196 Debug1("SSL_set_fd() -> %d", result);
197 return result;
200 int sycSSL_connect(SSL *ssl) {
201 int result;
202 Debug1("SSL_connect(%p)", ssl);
203 result = SSL_connect(ssl);
204 Debug1("SSL_connect() -> %d", result);
205 return result;
208 int sycSSL_accept(SSL *ssl) {
209 int result;
210 Debug1("SSL_accept(%p)", ssl);
211 result = SSL_accept(ssl);
212 Debug1("SSL_accept() -> %d", result);
213 return result;
216 int sycSSL_read(SSL *ssl, void *buf, int num) {
217 int result;
218 Debug3("SSL_read(%p, %p, %d)", ssl, buf, num);
219 result = SSL_read(ssl, buf, num);
220 Debug1("SSL_read() -> %d", result);
221 return result;
224 int sycSSL_pending(SSL *ssl) {
225 int result;
226 Debug1("SSL_pending(%p)", ssl);
227 result = SSL_pending(ssl);
228 Debug1("SSL_pending() -> %d", result);
229 return result;
232 int sycSSL_write(SSL *ssl, const void *buf, int num) {
233 int result;
234 Debug3("SSL_write(%p, %p, %d)", ssl, buf, num);
235 result = SSL_write(ssl, buf, num);
236 Debug1("SSL_write() -> %d", result);
237 return result;
240 X509 *sycSSL_get_peer_certificate(SSL *ssl) {
241 X509 *result;
242 Debug1("SSL_get_peer_certificate(%p)", ssl);
243 result = SSL_get_peer_certificate(ssl);
244 if (result) {
245 Debug1("SSL_get_peer_certificate() -> %p", result);
246 } else {
247 Debug("SSL_get_peer_certificate() -> NULL");
249 return result;
252 int sycSSL_shutdown(SSL *ssl) {
253 int result;
254 Debug1("SSL_shutdown(%p)", ssl);
255 result = SSL_shutdown(ssl);
256 Debug1("SSL_shutdown() -> %d", result);
257 return result;
260 void sycSSL_CTX_free(SSL_CTX *ctx) {
261 Debug1("SSL_CTX_free(%p)", ctx);
262 SSL_CTX_free(ctx);
263 Debug("SSL_CTX_free() -> void");
264 return;
267 void sycSSL_free(SSL *ssl) {
268 Debug1("SSL_free(%p)", ssl);
269 SSL_free(ssl);
270 Debug("SSL_free() -> void");
271 return;
274 int sycRAND_egd(const char *path) {
275 int result;
276 Debug1("RAND_egd(\"%s\")", path);
277 result = RAND_egd(path);
278 Debug1("RAND_egd() -> %d", result);
279 return result;
282 DH *sycPEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u) {
283 DH *result;
284 Debug4("PEM_read_bio_DHparams(%p, %p, %p, %p)",
285 bp, x, cb, u);
286 result = PEM_read_bio_DHparams(bp, x, cb, u);
287 if (result) {
288 /*Debug2("PEM_read_bio_DHparams(, {%p},,) -> %p", *x, result);*/
289 Debug1("PEM_read_bio_DHparams() -> %p", result);
290 } else {
291 Debug("PEM_read_bio_DHparams() -> NULL");
293 return result;
296 BIO *sycBIO_new_file(const char *filename, const char *mode) {
297 BIO *result;
298 Debug2("BIO_new_file(\"%s\", \"%s\")", filename, mode);
299 result = BIO_new_file(filename, mode);
300 if (result) {
301 Debug1("BIO_new_file() -> %p", result);
302 } else {
303 Debug("BIO_new_file() -> NULL");
305 return result;
308 #if WITH_FIPS
309 int sycFIPS_mode_set(int onoff) {
310 int result;
311 Debug1("FIPS_mode_set(%d)", onoff);
312 result = FIPS_mode_set(onoff);
313 Debug1("FIPS_mode_set() -> %d", result);
314 return result;
316 #endif /* WITH_FIPS */
318 #endif /* WITH_SYCLS && WITH_OPENSSL */