tls.h (1023B)
1 /* see license file for copyright and license details */ 2 #ifndef TLS_H_ 3 #define TLS_H_ 4 5 #include <sys/types.h> 6 7 struct TlsSocket; 8 9 /* tls_connect takes an already connected socket fd and upgrades it to tls 10 * if check_cert is 0 certificate validation is bypassed 11 * returns a new tls socket or null on error */ 12 struct TlsSocket *tlss_connect(int fd, const char *host, int check_cert, int is_tls); 13 14 /* standard read and write wrapping either libtls, bearssl or plain fallback */ 15 ssize_t tlss_read(struct TlsSocket *s, void *buf, size_t len); 16 ssize_t tlss_write(struct TlsSocket *s, const void *buf, size_t len); 17 18 /* closes the tls connection and optionally closes the socket fd */ 19 void tlss_close(struct TlsSocket *s, int close_fd); 20 21 #ifdef ARUU_TLS_TESTING 22 int tlss_test_b64_decode( 23 const char *src, size_t src_len, unsigned char *dst, size_t dst_cap, size_t *dst_len 24 ); 25 int tlss_test_load_ca_certs(const char *path); 26 int tlss_test_sigpipe_setup(void); 27 int tlss_test_sigpipe_teardown(void); 28 #endif 29 30 #endif /* tls_h_ */