You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

430 lines
11 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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 */
  4. /* explicit system call and C library trace function, for those who miss strace
  5. */
  6. #include "config.h"
  7. #include "xioconfig.h" /* what features are enabled */
  8. #if WITH_SYCLS && WITH_OPENSSL
  9. #include "sysincludes.h"
  10. #include "mytypes.h"
  11. #include "compat.h"
  12. #include "errno.h"
  13. #include "error.h"
  14. #include "filan.h"
  15. #include "sysutils.h"
  16. #include "sycls.h"
  17. void sycSSL_load_error_strings(void) {
  18. Debug("SSL_load_error_strings()");
  19. SSL_load_error_strings();
  20. Debug("SSL_load_error_strings() ->");
  21. }
  22. int sycSSL_library_init(void) {
  23. int result;
  24. Debug("SSL_library_init()");
  25. result = SSL_library_init();
  26. Debug1("SSL_library_init() -> %d", result);
  27. return result;
  28. }
  29. #if HAVE_SSLv2_client_method
  30. const SSL_METHOD *sycSSLv2_client_method(void) {
  31. const SSL_METHOD *result;
  32. Debug("SSLv2_client_method()");
  33. result = SSLv2_client_method();
  34. Debug1("SSLv2_client_method() -> %p", result);
  35. return result;
  36. }
  37. #endif
  38. #if HAVE_SSLv2_server_method
  39. const SSL_METHOD *sycSSLv2_server_method(void) {
  40. const SSL_METHOD *result;
  41. Debug("SSLv2_server_method()");
  42. result = SSLv2_server_method();
  43. Debug1("SSLv2_server_method() -> %p", result);
  44. return result;
  45. }
  46. #endif
  47. #if HAVE_SSLv3_client_method
  48. const SSL_METHOD *sycSSLv3_client_method(void) {
  49. const SSL_METHOD *result;
  50. Debug("SSLv3_client_method()");
  51. result = SSLv3_client_method();
  52. Debug1("SSLv3_client_method() -> %p", result);
  53. return result;
  54. }
  55. #endif
  56. #if HAVE_SSLv3_server_method
  57. const SSL_METHOD *sycSSLv3_server_method(void) {
  58. const SSL_METHOD *result;
  59. Debug("SSLv3_server_method()");
  60. result = SSLv3_server_method();
  61. Debug1("SSLv3_server_method() -> %p", result);
  62. return result;
  63. }
  64. #endif
  65. const SSL_METHOD *sycSSLv23_client_method(void) {
  66. const SSL_METHOD *result;
  67. Debug("SSLv23_client_method()");
  68. result = SSLv23_client_method();
  69. Debug1("SSLv23_client_method() -> %p", result);
  70. return result;
  71. }
  72. const SSL_METHOD *sycSSLv23_server_method(void) {
  73. const SSL_METHOD *result;
  74. Debug("SSLv23_server_method()");
  75. result = SSLv23_server_method();
  76. Debug1("SSLv23_server_method() -> %p", result);
  77. return result;
  78. }
  79. #if HAVE_TLSv1_client_method
  80. const SSL_METHOD *sycTLSv1_client_method(void) {
  81. const SSL_METHOD *result;
  82. Debug("TLSv1_client_method()");
  83. result = TLSv1_client_method();
  84. Debug1("TLSv1_client_method() -> %p", result);
  85. return result;
  86. }
  87. #endif
  88. #if HAVE_TLSv1_server_method
  89. const SSL_METHOD *sycTLSv1_server_method(void) {
  90. const SSL_METHOD *result;
  91. Debug("TLSv1_server_method()");
  92. result = TLSv1_server_method();
  93. Debug1("TLSv1_server_method() -> %p", result);
  94. return result;
  95. }
  96. #endif
  97. #if HAVE_TLSv1_1_client_method
  98. const SSL_METHOD *sycTLSv1_1_client_method(void) {
  99. const SSL_METHOD *result;
  100. Debug("TLSv1_1_client_method()");
  101. result = TLSv1_1_client_method();
  102. Debug1("TLSv1_1_client_method() -> %p", result);
  103. return result;
  104. }
  105. #endif
  106. #if HAVE_TLSv1_1_server_method
  107. const SSL_METHOD *sycTLSv1_1_server_method(void) {
  108. const SSL_METHOD *result;
  109. Debug("TLSv1_1_server_method()");
  110. result = TLSv1_1_server_method();
  111. Debug1("TLSv1_1_server_method() -> %p", result);
  112. return result;
  113. }
  114. #endif
  115. #if HAVE_TLSv1_2_client_method
  116. const SSL_METHOD *sycTLSv1_2_client_method(void) {
  117. const SSL_METHOD *result;
  118. Debug("TLSv1_2_client_method()");
  119. result = TLSv1_2_client_method();
  120. Debug1("TLSv1_2_client_method() -> %p", result);
  121. return result;
  122. }
  123. #endif
  124. #if HAVE_TLSv1_2_server_method
  125. const SSL_METHOD *sycTLSv1_2_server_method(void) {
  126. const SSL_METHOD *result;
  127. Debug("TLSv1_2_server_method()");
  128. result = TLSv1_2_server_method();
  129. Debug1("TLSv1_2_server_method() -> %p", result);
  130. return result;
  131. }
  132. #endif
  133. #if HAVE_DTLSv1_client_method
  134. const SSL_METHOD *sycDTLSv1_client_method(void) {
  135. const SSL_METHOD *result;
  136. Debug("DTLSv1_client_method()");
  137. result = DTLSv1_client_method();
  138. Debug1("DTLSv1_client_method() -> %p", result);
  139. return result;
  140. }
  141. #endif
  142. #if HAVE_DTLSv1_server_method
  143. const SSL_METHOD *sycDTLSv1_server_method(void) {
  144. const SSL_METHOD *result;
  145. Debug("DTLSv1_server_method()");
  146. result = DTLSv1_server_method();
  147. Debug1("DTLSv1_server_method() -> %p", result);
  148. return result;
  149. }
  150. #endif
  151. SSL_CTX *sycSSL_CTX_new(const SSL_METHOD *method) {
  152. SSL_CTX *result;
  153. Debug1("SSL_CTX_new(%p)", method);
  154. result = SSL_CTX_new(method);
  155. Debug1("SSL_CTX_new() -> %p", result);
  156. return result;
  157. }
  158. SSL *sycSSL_new(SSL_CTX *ctx) {
  159. SSL *result;
  160. Debug1("SSL_new(%p)", ctx);
  161. result = SSL_new(ctx);
  162. Debug1("SSL_new() -> %p", result);
  163. return result;
  164. }
  165. int sycSSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
  166. const char *CApath) {
  167. int result;
  168. Debug7("SSL_CTX_load_verify_locations(%p, %s%s%s, %s%s%s)", ctx,
  169. CAfile?"\"":"", CAfile?CAfile:"", CAfile?"\"":"",
  170. CApath?"\"":"", CApath?CApath:"", CApath?"\"":"");
  171. result = SSL_CTX_load_verify_locations(ctx, CAfile, CApath);
  172. Debug1("SSL_CTX_load_verify_locations() -> %d", result);
  173. return result;
  174. }
  175. int sycSSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) {
  176. int result;
  177. Debug3("SSL_CTX_use_certificate_file(%p, \"%s\", %d)", ctx, file, type);
  178. result = SSL_CTX_use_certificate_file(ctx, file, type);
  179. Debug1("SSL_CTX_use_certificate_file() -> %d", result);
  180. return result;
  181. }
  182. int sycSSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) {
  183. int result;
  184. Debug2("SSL_CTX_use_certificate_chain_file(%p, \"%s\")", ctx, file);
  185. result = SSL_CTX_use_certificate_chain_file(ctx, file);
  186. Debug1("SSL_CTX_use_certificate_chain_file() -> %d", result);
  187. return result;
  188. }
  189. int sycSSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
  190. int result;
  191. Debug3("SSL_CTX_use_PrivateKey_file(%p, \"%s\", %d)", ctx, file, type);
  192. result = SSL_CTX_use_PrivateKey_file(ctx, file, type);
  193. Debug1("SSL_CTX_use_PrivateKey_file() -> %d", result);
  194. return result;
  195. }
  196. void sycSSL_CTX_set_verify(SSL_CTX *ctx, int mode,
  197. int (*verify_callback)(int, X509_STORE_CTX *)) {
  198. Debug3("SSL_CTX_set_verify(%p, %u, %p)", ctx, mode, verify_callback);
  199. SSL_CTX_set_verify(ctx, mode, verify_callback);
  200. Debug("SSL_CTX_set_verify() -> ");
  201. }
  202. int sycSSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
  203. int result;
  204. Debug2("SSL_CTX_set_cipher_list(%p, \"%s\")", ctx, str);
  205. result = SSL_CTX_set_cipher_list(ctx, str);
  206. Debug1("SSL_CTX_set_cipher_list() -> %d", result);
  207. return result;
  208. }
  209. int sycSSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) {
  210. int result;
  211. Debug2("SSL_CTX_set_tmp_dh(%p, %p)", ctx, dh);
  212. result = SSL_CTX_set_tmp_dh(ctx, dh);
  213. Debug1("SSL_CTX_set_tmp_dh() -> %d", result);
  214. return result;
  215. }
  216. int sycSSL_set_cipher_list(SSL *ssl, const char *str) {
  217. int result;
  218. Debug2("SSL_set_cipher_list(%p, \"%s\")", ssl, str);
  219. result = SSL_set_cipher_list(ssl, str);
  220. Debug1("SSL_set_cipher_list() -> %d", result);
  221. return result;
  222. }
  223. long sycSSL_get_verify_result(SSL *ssl) {
  224. long result;
  225. Debug1("SSL_get_verify_result(%p)", ssl);
  226. result = SSL_get_verify_result(ssl);
  227. Debug1("SSL_get_verify_result() -> %lx", result);
  228. return result;
  229. }
  230. int sycSSL_set_fd(SSL *ssl, int fd) {
  231. int result;
  232. Debug2("SSL_set_fd(%p, %d)", ssl, fd);
  233. result = SSL_set_fd(ssl, fd);
  234. Debug1("SSL_set_fd() -> %d", result);
  235. return result;
  236. }
  237. int sycSSL_connect(SSL *ssl) {
  238. int result;
  239. Debug1("SSL_connect(%p)", ssl);
  240. result = SSL_connect(ssl);
  241. Debug1("SSL_connect() -> %d", result);
  242. return result;
  243. }
  244. int sycSSL_accept(SSL *ssl) {
  245. int result;
  246. Debug1("SSL_accept(%p)", ssl);
  247. result = SSL_accept(ssl);
  248. Debug1("SSL_accept() -> %d", result);
  249. return result;
  250. }
  251. int sycSSL_read(SSL *ssl, void *buf, int num) {
  252. int result;
  253. Debug3("SSL_read(%p, %p, %d)", ssl, buf, num);
  254. result = SSL_read(ssl, buf, num);
  255. Debug1("SSL_read() -> %d", result);
  256. return result;
  257. }
  258. int sycSSL_pending(SSL *ssl) {
  259. int result;
  260. Debug1("SSL_pending(%p)", ssl);
  261. result = SSL_pending(ssl);
  262. Debug1("SSL_pending() -> %d", result);
  263. return result;
  264. }
  265. int sycSSL_write(SSL *ssl, const void *buf, int num) {
  266. int result;
  267. Debug3("SSL_write(%p, %p, %d)", ssl, buf, num);
  268. result = SSL_write(ssl, buf, num);
  269. Debug1("SSL_write() -> %d", result);
  270. return result;
  271. }
  272. X509 *sycSSL_get_peer_certificate(SSL *ssl) {
  273. X509 *result;
  274. Debug1("SSL_get_peer_certificate(%p)", ssl);
  275. result = SSL_get_peer_certificate(ssl);
  276. if (result) {
  277. Debug1("SSL_get_peer_certificate() -> %p", result);
  278. } else {
  279. Debug("SSL_get_peer_certificate() -> NULL");
  280. }
  281. return result;
  282. }
  283. int sycSSL_shutdown(SSL *ssl) {
  284. int result;
  285. Debug1("SSL_shutdown(%p)", ssl);
  286. result = SSL_shutdown(ssl);
  287. Debug1("SSL_shutdown() -> %d", result);
  288. return result;
  289. }
  290. void sycSSL_CTX_free(SSL_CTX *ctx) {
  291. Debug1("SSL_CTX_free(%p)", ctx);
  292. SSL_CTX_free(ctx);
  293. Debug("SSL_CTX_free() -> void");
  294. return;
  295. }
  296. void sycSSL_free(SSL *ssl) {
  297. Debug1("SSL_free(%p)", ssl);
  298. SSL_free(ssl);
  299. Debug("SSL_free() -> void");
  300. return;
  301. }
  302. #if !defined(OPENSSL_NO_EGD) && HAVE_RAND_egd
  303. int sycRAND_egd(const char *path) {
  304. int result;
  305. Debug1("RAND_egd(\"%s\")", path);
  306. result = RAND_egd(path);
  307. Debug1("RAND_egd() -> %d", result);
  308. return result;
  309. }
  310. #endif
  311. DH *sycPEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u) {
  312. DH *result;
  313. Debug4("PEM_read_bio_DHparams(%p, %p, %p, %p)",
  314. bp, x, cb, u);
  315. result = PEM_read_bio_DHparams(bp, x, cb, u);
  316. if (result) {
  317. /*Debug2("PEM_read_bio_DHparams(, {%p},,) -> %p", *x, result);*/
  318. Debug1("PEM_read_bio_DHparams() -> %p", result);
  319. } else {
  320. Debug("PEM_read_bio_DHparams() -> NULL");
  321. }
  322. return result;
  323. }
  324. BIO *sycBIO_new_file(const char *filename, const char *mode) {
  325. BIO *result;
  326. Debug2("BIO_new_file(\"%s\", \"%s\")", filename, mode);
  327. result = BIO_new_file(filename, mode);
  328. if (result) {
  329. Debug1("BIO_new_file() -> %p", result);
  330. } else {
  331. Debug("BIO_new_file() -> NULL");
  332. }
  333. return result;
  334. }
  335. #if WITH_FIPS
  336. int sycFIPS_mode_set(int onoff) {
  337. int result;
  338. Debug1("FIPS_mode_set(%d)", onoff);
  339. result = FIPS_mode_set(onoff);
  340. Debug1("FIPS_mode_set() -> %d", result);
  341. return result;
  342. }
  343. #endif /* WITH_FIPS */
  344. #if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined(OPENSSL_NO_COMP)
  345. const COMP_METHOD *sycSSL_get_current_compression(SSL *ssl) {
  346. const COMP_METHOD *result;
  347. Debug1("SSL_get_current_compression(%p)", ssl);
  348. result = SSL_get_current_compression(ssl);
  349. if (result) {
  350. Debug1("SSL_get_current_compression() -> %p", result);
  351. } else {
  352. Debug("SSL_get_current_compression() -> NULL");
  353. }
  354. return result;
  355. }
  356. const COMP_METHOD *sycSSL_get_current_expansion(SSL *ssl) {
  357. const COMP_METHOD *result;
  358. Debug1("SSL_get_current_expansion(%p)", ssl);
  359. result = SSL_get_current_expansion(ssl);
  360. if (result) {
  361. Debug1("SSL_get_current_expansion() -> %p", result);
  362. } else {
  363. Debug("SSL_get_current_expansion() -> NULL");
  364. }
  365. return result;
  366. }
  367. const char *sycSSL_COMP_get_name(const COMP_METHOD *comp) {
  368. const char *result;
  369. Debug1("SSL_COMP_get_name(%p)", comp);
  370. result = SSL_COMP_get_name(comp);
  371. if (result) {
  372. Debug1("SSL_COMP_get_name() -> \"%s\"", result);
  373. } else {
  374. Debug("SSL_COMP_get_name() -> NULL");
  375. }
  376. return result;
  377. }
  378. #endif
  379. #endif /* WITH_SYCLS && WITH_OPENSSL */