OpenSSL-backed TLS 1.3 stream engine driven only by caller buffers. More...
#include <StormByte/crypto/tls/session.hxx>
Public Member Functions | |
| Session () noexcept | |
| Construct a failed, empty session. | |
| Session (Session &&other) noexcept | |
| Transfer session state. | |
| ~Session () noexcept | |
| Destroy the TLS state and its private OpenSSL resources. | |
| Session & | operator= (Session &&other) noexcept |
| Transfer session state. | |
| Session (const Session &)=delete | |
| Session & | operator= (const Session &)=delete |
| StormByte::Expected< std::size_t, SessionError > | FeedEncrypted (std::span< const std::byte > encrypted) |
| Copy ciphertext into the bounded input buffer and advance TLS. | |
| StormByte::Expected< std::size_t, SessionError > | DrainEncrypted (std::span< std::byte > output) |
| Copy pending TLS protocol bytes into the caller's output buffer. | |
| StormByte::Expected< std::size_t, SessionError > | WritePlaintext (std::span< const std::byte > plaintext) |
| Encrypt caller plaintext after successful handshake validation. | |
| StormByte::Expected< std::size_t, SessionError > | ReadPlaintext (std::span< std::byte > output) |
| Decrypt available application bytes into the caller's buffer. | |
| StormByte::Expected< void, SessionError > | Shutdown () |
| Begin or advance orderly TLS shutdown. | |
| State | Status () const noexcept |
| Read the current lifecycle state. | |
| SessionError | Failure () const noexcept |
| Read the sticky fatal failure, if any. | |
| std::string_view | FailureDetail () const noexcept |
| Read the first fatal failure's explanation without logging or allocation. | |
| bool | HandshakeComplete () const noexcept |
| Test whether the TLS handshake finished successfully. | |
| std::string_view | NegotiatedALPN () const noexcept |
| Read the negotiated application protocol. | |
Static Public Member Functions | |
| static StormByte::Expected< Session, SessionError > | CreateClient (const ClientConfiguration &configuration) |
| Create a client with explicit identity, trust, time and TLS policy. | |
| static StormByte::Expected< Session, SessionError > | CreateServer (const ServerConfiguration &configuration) |
| Create a server that presents the configured certificate and key. | |
Static Public Attributes | |
| static constexpr std::size_t | MaxInputChunk = 64 * 1024 |
| Maximum ciphertext accepted by one FeedEncrypted call. | |
| static constexpr std::size_t | MaxPendingCiphertext = 1024 * 1024 |
| Maximum ciphertext retained in either internal buffer. | |
OpenSSL-backed TLS 1.3 stream engine driven only by caller buffers.
Crypto performs no socket, DNS, HTTP, filesystem or clock I/O. Callers feed received ciphertext with FeedEncrypted, drain pending protocol bytes with DrainEncrypted, and exchange application bytes with WritePlaintext and ReadPlaintext. Methods report partial progress so the caller retains ownership of transport scheduling, deadlines, cancellation and retries. OpenSSL types are private to the implementation and are not part of this API.
Each session is single-threaded; callers must serialize all operations on it.
|
noexcept |
Construct a failed, empty session.
|
noexcept |
Transfer session state.
| other | Source session; it becomes empty. |
|
noexcept |
Destroy the TLS state and its private OpenSSL resources.
|
delete |
|
static |
Create a client with explicit identity, trust, time and TLS policy.
| configuration | Borrowed options copied or consumed during this call. |
| StormByte::Safe::AllocationError | Safe-owned configuration cannot be copied. |
|
static |
Create a server that presents the configured certificate and key.
| configuration | Borrowed certificate/key and policy options. |
| StormByte::Safe::AllocationError | Safe-owned configuration cannot be copied. |
| StormByte::Expected< std::size_t, SessionError > StormByte::Crypto::TLS::Session::DrainEncrypted | ( | std::span< std::byte > | output | ) |
Copy pending TLS protocol bytes into the caller's output buffer.
| output | Destination for ciphertext. |
|
noexcept |
Read the sticky fatal failure, if any.
|
noexcept |
Read the first fatal failure's explanation without logging or allocation.
| StormByte::Expected< std::size_t, SessionError > StormByte::Crypto::TLS::Session::FeedEncrypted | ( | std::span< const std::byte > | encrypted | ) |
Copy ciphertext into the bounded input buffer and advance TLS.
| encrypted | Caller-owned network bytes. |
| No | exception is raised for peer-controlled protocol errors; they set Failed. |
|
noexcept |
|
noexcept |
Read the negotiated application protocol.
Transfer session state.
| other | Source session; it becomes empty. |
| StormByte::Expected< std::size_t, SessionError > StormByte::Crypto::TLS::Session::ReadPlaintext | ( | std::span< std::byte > | output | ) |
Decrypt available application bytes into the caller's buffer.
| output | Destination for plaintext. |
| StormByte::Expected< void, SessionError > StormByte::Crypto::TLS::Session::Shutdown | ( | ) |
Begin or advance orderly TLS shutdown.
|
noexcept |
Read the current lifecycle state.
| StormByte::Expected< std::size_t, SessionError > StormByte::Crypto::TLS::Session::WritePlaintext | ( | std::span< const std::byte > | plaintext | ) |
Encrypt caller plaintext after successful handshake validation.
| plaintext | Application bytes. |
|
staticconstexpr |
Maximum ciphertext accepted by one FeedEncrypted call.
|
staticconstexpr |
Maximum ciphertext retained in either internal buffer.