oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::tls::Session Class Reference

RAII wrapper around an oveRTOS TLS session. More...

#include <net_tls.hpp>

Public Member Functions

 Session (const Session &)=delete
 
Sessionoperator= (const Session &)=delete
 
 Session (Session &&)=delete
 
Sessionoperator= (Session &&)=delete
 
Result< void > handshake (ove_socket_t sock, const Config &cfg={}) noexcept
 Perform TLS handshake over an established TCP socket.
 
Result< size_t > send (const void *data, size_t len) noexcept
 Send encrypted bytes over the TLS session.
 
Result< size_t > recv (void *buf, size_t len) noexcept
 Receive decrypted bytes from the TLS session.
 
void close ()
 Close the TLS session (sends close_notify and tears down state).
 

Detailed Description

RAII wrapper around an oveRTOS TLS session.

Initialises mbedTLS contexts on construction, frees them on destruction. Use handshake() to establish a TLS connection over an existing TCP socket.

Member Function Documentation

◆ handshake()

Result< void > ove::tls::Session::handshake ( ove_socket_t  sock,
const Config cfg = {} 
)
inlinenoexcept

Perform TLS handshake over an established TCP socket.

Returns
Empty Result<void> on success; unexpected Error on failure (cert validation, network error, etc.).

◆ send()

Result< size_t > ove::tls::Session::send ( const void *  data,
size_t  len 
)
inlinenoexcept

Send encrypted bytes over the TLS session.

Parameters
[in]dataBuffer to send.
[in]lenBuffer length in bytes.
Returns
On success, the number of bytes actually sent. On failure, an unexpected Error.

◆ recv()

Result< size_t > ove::tls::Session::recv ( void *  buf,
size_t  len 
)
inlinenoexcept

Receive decrypted bytes from the TLS session.

Parameters
[out]bufDestination buffer.
[in]lenBuffer capacity in bytes.
Returns
On success, the number of bytes received. On failure, an unexpected Error (Error::NetClosed for a clean TLS shutdown).

The documentation for this class was generated from the following file: