16#include <ove/net_tls.h>
21#ifdef CONFIG_OVE_NET_TLS
59#ifdef CONFIG_OVE_ZERO_HEAP
60 int err = ove_tls_init(&handle_, &storage_);
62 int err = ove_tls_create(&handle_);
64 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
71#ifdef CONFIG_OVE_ZERO_HEAP
72 ove_tls_deinit(handle_);
74 ove_tls_destroy(handle_);
92 ove_tls_config_t c{cfg.ca_cert, cfg.ca_cert_len, cfg.hostname,
93 cfg.client_cert, cfg.client_cert_len, cfg.client_key,
95 return from_rc(ove_tls_handshake(handle_, sock, &c));
109 const int rc = ove_tls_send(handle_, data, len, &sent);
125 const int rc = ove_tls_recv(handle_, buf, len, &received);
132 ove_tls_close(handle_);
137#ifdef CONFIG_OVE_ZERO_HEAP
138 ove_tls_storage_t storage_{};
RAII wrapper around an oveRTOS TLS session.
Definition net_tls.hpp:55
Result< size_t > send(const void *data, size_t len) noexcept
Send encrypted bytes over the TLS session.
Definition net_tls.hpp:106
void close()
Close the TLS session (sends close_notify and tears down state).
Definition net_tls.hpp:130
Result< size_t > recv(void *buf, size_t len) noexcept
Receive decrypted bytes from the TLS session.
Definition net_tls.hpp:122
Result< void > handshake(ove_socket_t sock, const Config &cfg={}) noexcept
Perform TLS handshake over an established TCP socket.
Definition net_tls.hpp:90
Strong ove::Error type, Result<T> alias, and std::error_code interop for the oveRTOS C++ binding.
TLS session wrapper over mbedTLS. Provides handshake, send, recv, and close on top of a connected ove...
Definition net_tls.hpp:24
Result< void > from_rc(int rc) noexcept
Lifts a substrate rc-code into a Result<void>.
Definition error.hpp:254
std::expected< T, Error > Result
std::expected-based result alias.
Definition error.hpp:139
RAII networking: sockets, network interface, DNS.
TLS session configuration.
Definition net_tls.hpp:37
size_t client_cert_len
Definition net_tls.hpp:42
const unsigned char * client_key
Definition net_tls.hpp:43
const unsigned char * ca_cert
Definition net_tls.hpp:38
size_t client_key_len
Definition net_tls.hpp:44
const char * hostname
Definition net_tls.hpp:40
const unsigned char * client_cert
Definition net_tls.hpp:41
size_t ca_cert_len
Definition net_tls.hpp:39
Common type definitions and concepts for the C++ wrapper layer.