ssl.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef SSL_H_INCLUDED
  2. #define SSL_H_INCLUDED
  3. /*********************************************************************
  4. *
  5. * File : $Source: $
  6. *
  7. * Purpose : File with TLS/SSL extension. Contains methods for
  8. * creating, using and closing TLS/SSL connections.
  9. *
  10. * Copyright : Written by and Copyright (c) 2017 Vaclav Svec. FIT CVUT.
  11. *
  12. * This program is free software; you can redistribute it
  13. * and/or modify it under the terms of the GNU General
  14. * Public License as published by the Free Software
  15. * Foundation; either version 2 of the License, or (at
  16. * your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will
  19. * be useful, but WITHOUT ANY WARRANTY; without even the
  20. * implied warranty of MERCHANTABILITY or FITNESS FOR A
  21. * PARTICULAR PURPOSE. See the GNU General Public
  22. * License for more details.
  23. *
  24. * The GNU General Public License should be included with
  25. * this file. If not, you can view it at
  26. * http://www.gnu.org/copyleft/gpl.html
  27. * or write to the Free Software Foundation, Inc., 59
  28. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. *
  30. *********************************************************************/
  31. #include "project.h"
  32. /* Boolean functions to get information about TLS/SSL connections */
  33. extern int client_use_ssl(const struct client_state *csp);
  34. extern int server_use_ssl(const struct client_state *csp);
  35. extern size_t is_ssl_pending(struct ssl_attr *ssl_attr);
  36. extern int tunnel_established_successfully(const char *response, unsigned int response_len);
  37. /* Functions for sending and receiving data over TLS/SSL connections */
  38. extern int ssl_send_data(struct ssl_attr *ssl_attr, const unsigned char *buf, size_t len);
  39. extern int ssl_send_data_delayed(struct ssl_attr *ssl_attr, const unsigned char *buf,
  40. size_t len, unsigned int delay);
  41. extern int ssl_recv_data(struct ssl_attr *ssl_attr, unsigned char *buf, size_t maxLen);
  42. extern long ssl_flush_socket(struct ssl_attr *ssl_attr, struct iob *iob);
  43. extern void ssl_send_certificate_error(struct client_state *csp);
  44. /* Functions for opening and closing TLS/SSL connections */
  45. extern int create_client_ssl_connection(struct client_state *csp);
  46. extern int create_server_ssl_connection(struct client_state *csp);
  47. extern void close_client_and_server_ssl_connections(struct client_state *csp);
  48. extern void close_server_ssl_connection(struct client_state *csp);
  49. extern void close_client_ssl_connection(struct client_state *csp);
  50. /* misc helper functions */
  51. extern int ssl_base64_encode(unsigned char *dst, size_t dlen, size_t *olen,
  52. const unsigned char *src, size_t slen );
  53. extern void ssl_crt_verify_info(char *buf, size_t size, struct client_state *csp);
  54. extern void ssl_release(void);
  55. #endif /* ndef SSL_H_INCLUDED */