diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2023-12-22 20:39:57 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2023-12-30 01:37:14 +0100 |
commit | 7357e0ee1e8ae1ee9259a3181e400db0d570362b (patch) | |
tree | 026805d25ea7500c160a113eae45c1a8019c7e6c /src/IO/tls_mbedtls.h | |
parent | d3d890f3b48cf6f3494ed0d6d06b37e5376cd188 (diff) |
Add support for OpenSSL, mbedTLS 2 and mbedTLS 3
Brings the previous OpenSSL implementation into src/IO/tls_openssl.c.
Now, the TLS functions have the implementation name as prefix, like
a_Tls_openssl_connect().
The generic interface at IO/tls.h hides the implementation which is
selected at configure time. The appropriate functions of that
implementation are called from IO/tls.c to IO/tls_<impl>.c. In this way,
support for more TLS libraries can easily be added.
In the case of mbedTLS, there are some incompatible changes from version
2 to 3, so we use some ifdefs to fix the differences.
Diffstat (limited to 'src/IO/tls_mbedtls.h')
-rw-r--r-- | src/IO/tls_mbedtls.h | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/src/IO/tls_mbedtls.h b/src/IO/tls_mbedtls.h index a3bf9ba5..4a679698 100644 --- a/src/IO/tls_mbedtls.h +++ b/src/IO/tls_mbedtls.h @@ -1,5 +1,19 @@ -#ifndef __TLS_H__ -#define __TLS_H__ +/* + * File: tls_mbedtls.h + * + * Copyright (C) 2011 Benjamin Johnson <obeythepenguin@users.sourceforge.net> + * (for the https code offered from dplus browser that formed the basis...) + * Copyright 2016 corvid + * Copyright (C) 2023 Rodrigo Arias Mallo <rodarima@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + */ + +#ifndef __TLS_MBEDTLS_H__ +#define __TLS_MBEDTLS_H__ #ifdef __cplusplus extern "C" { @@ -7,44 +21,19 @@ extern "C" { #include "../url.h" -#define TLS_CONNECT_NEVER -1 -#define TLS_CONNECT_NOT_YET 0 -#define TLS_CONNECT_READY 1 +void a_Tls_mbedtls_init(); +int a_Tls_mbedtls_certificate_is_clean(const DilloUrl *url); +int a_Tls_mbedtls_connect_ready(const DilloUrl *url); +void a_Tls_mbedtls_reset_server_state(const DilloUrl *url); +void a_Tls_mbedtls_connect(int fd, const DilloUrl *url); +void *a_Tls_mbedtls_connection(int fd); +void a_Tls_mbedtls_freeall(); +void a_Tls_mbedtls_close_by_fd(int fd); +int a_Tls_mbedtls_read(void *conn, void *buf, size_t len); +int a_Tls_mbedtls_write(void *conn, void *buf, size_t len); -void a_Tls_init(); - - -#ifdef ENABLE_SSL -int a_Tls_certificate_is_clean(const DilloUrl *url); -int a_Tls_connect_ready(const DilloUrl *url); -void a_Tls_reset_server_state(const DilloUrl *url); - -/* Use to initiate a TLS connection. */ -void a_Tls_connect(int fd, const DilloUrl *url); - -void *a_Tls_connection(int fd); - -void a_Tls_freeall(); - -void a_Tls_close_by_fd(int fd); -int a_Tls_read(void *conn, void *buf, size_t len); -int a_Tls_write(void *conn, void *buf, size_t len); -#else - -#define a_Tls_certificate_is_clean(host) 0 -#define a_Tls_connect_ready(url) TLS_CONNECT_NEVER -#define a_Tls_reset_server_state(url) ; -#define a_Tls_handshake(fd, url) ; -#define a_Tls_connect(fd, url) ; -#define a_Tls_connection(fd) NULL -#define a_Tls_freeall() ; -#define a_Tls_close_by_fd(fd) ; -#define a_Tls_read(conn, buf, len) 0 -#define a_Tls_write(conn, buf, len) 0 -#endif #ifdef __cplusplus } #endif -#endif /* __TLS_H__ */ - +#endif /* __TLS_MBEDTLS_H__ */ |