47#include <StormByte/expected.hxx>
120 std::chrono::system_clock::now())};
145 std::chrono::system_clock::now())};
288 explicit
Session(
std::unique_ptr<Impl> impl) noexcept;
289 std::unique_ptr<Impl> m_impl;
StormByte::Expected< std::size_t, SessionError > WritePlaintext(std::span< const std::byte > plaintext)
Encrypt caller plaintext after successful handshake validation.
static constexpr std::size_t MaxInputChunk
Maximum ciphertext accepted by one FeedEncrypted call.
Definition session.hxx:278
std::string_view FailureDetail() const noexcept
Read the first fatal failure's explanation without logging or allocation.
SessionError Failure() const noexcept
Read the sticky fatal failure, if any.
Session() noexcept
Construct a failed, empty session.
StormByte::Expected< std::size_t, SessionError > ReadPlaintext(std::span< std::byte > output)
Decrypt available application bytes into the caller's buffer.
std::string_view NegotiatedALPN() const noexcept
Read the negotiated application protocol.
static StormByte::Expected< Session, SessionError > CreateClient(const ClientConfiguration &configuration)
Create a client with explicit identity, trust, time and TLS policy.
bool HandshakeComplete() const noexcept
Test whether the TLS handshake finished successfully.
StormByte::Expected< std::size_t, SessionError > FeedEncrypted(std::span< const std::byte > encrypted)
Copy ciphertext into the bounded input buffer and advance TLS.
static constexpr std::size_t MaxPendingCiphertext
Maximum ciphertext retained in either internal buffer.
Definition session.hxx:283
StormByte::Expected< std::size_t, SessionError > DrainEncrypted(std::span< std::byte > output)
Copy pending TLS protocol bytes into the caller's output buffer.
State Status() const noexcept
Read the current lifecycle state.
static StormByte::Expected< Session, SessionError > CreateServer(const ServerConfiguration &configuration)
Create a server that presents the configured certificate and key.
StormByte::Expected< void, SessionError > Shutdown()
Begin or advance orderly TLS shutdown.
One supported subjectAltName entry (a DNS name or an IP address).
Definition certificate.hxx:156
TLS 1.3 policy and buffer-driven session engine.
const char * DescribeSessionError(SessionError error) noexcept
Describe a typed setup or operation failure without accessing backend state.
Role
TLS endpoint role for a stream session.
Definition session.hxx:60
@ Client
Initiates a TLS handshake and authenticates a server.
Definition session.hxx:61
@ Server
Accepts a TLS handshake and presents a configured certificate.
Definition session.hxx:62
State
Observable lifecycle of a buffer-driven TLS session.
Definition session.hxx:69
@ Closed
TLS shutdown completed.
Definition session.hxx:73
@ Closing
A local or peer close-notify is being exchanged.
Definition session.hxx:72
@ Open
The handshake completed and application data may flow.
Definition session.hxx:71
@ Failed
A fatal protocol, validation or backend error occurred.
Definition session.hxx:74
@ Handshaking
The peer handshake is not yet complete.
Definition session.hxx:70
SessionError
Typed TLS session failures.
Definition session.hxx:81
@ BackendFailure
OpenSSL failed an operation or resource allocation.
Definition session.hxx:84
@ BufferLimit
A configured internal bound would be exceeded.
Definition session.hxx:87
@ PeerRejected
Peer certificate, trust path, identity or revocation was rejected.
Definition session.hxx:85
@ InvalidState
The requested operation is invalid for this session state.
Definition session.hxx:86
@ InvalidConfiguration
Invalid role, identity, certificate, key or trust configuration.
Definition session.hxx:82
@ UnsupportedPolicy
The selected TLS policy cannot be represented by this engine.
Definition session.hxx:83
TrustSource
Source of trust anchors for a client or mutual-TLS server.
Definition session.hxx:101
@ Bundled
The versioned StormByte public server-root bundle.
Definition session.hxx:102
@ Custom
Only the explicitly supplied certificate authorities.
Definition session.hxx:103
std::chrono::sys_seconds TimePoint
Point in time with second precision, as stored in certificates.
Definition certificate.hxx:75
Root namespace of the StormByte suite.
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > > Expected
Borrowed construction inputs for an authenticated TLS client.
Definition session.hxx:115
bool require_revocation
Require fresh Good evidence for each non-anchor certificate.
Definition session.hxx:121
std::span< const std::byte > private_key_password
Optional password for an encrypted client key.
Definition session.hxx:125
std::span< const std::byte > certificate_chain_pem
Optional client certificate chain for mutual TLS.
Definition session.hxx:123
X509::TimePoint validation_time
Certificate/evidence validation time.
Definition session.hxx:119
Configuration policy
Validated TLS 1.3 suites, groups and signature schemes.
Definition session.hxx:126
std::span< const X509::Certificate > trust_anchors
Custom anchors, never merged with bundled roots.
Definition session.hxx:118
std::span< const std::byte > private_key_pem
Optional matching client private key.
Definition session.hxx:124
TrustSource trust_source
Trust store policy.
Definition session.hxx:117
std::span< const X509::RevocationEvidence > revocation_evidence
Borrowed DER evidence copied at construction.
Definition session.hxx:122
X509::SubjectAltName identity
Required expected DNS or binary IP SAN.
Definition session.hxx:116
std::span< const std::byte > alpn_wire
Optional length-prefixed ALPN protocol list.
Definition session.hxx:127
Mutable input with independent ordered preference lists.
Definition policy.hxx:128
Borrowed construction inputs for a TLS server.
Definition session.hxx:138
std::span< const std::byte > private_key_pem
PEM private key matching the leaf certificate.
Definition session.hxx:140
std::span< const std::byte > certificate_chain_pem
PEM leaf and optional intermediate certificates.
Definition session.hxx:139
bool require_client_certificate
Require and validate a client certificate.
Definition session.hxx:142
Configuration policy
Validated TLS 1.3 suites, groups and signature schemes.
Definition session.hxx:146
std::span< const X509::Certificate > client_trust_anchors
Exclusive custom client CA anchors for mTLS.
Definition session.hxx:143
X509::TimePoint validation_time
Client certificate validation time.
Definition session.hxx:144
std::span< const std::byte > alpn_wire
Optional length-prefixed server protocol preference list.
Definition session.hxx:147
std::span< const std::byte > private_key_password
Optional PEM key password.
Definition session.hxx:141
#define STORMBYTE_CRYPTO_PUBLIC
Definition visibility.h:53