|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
QUIC-TLS integration handler (RFC 9001) More...
#include <crypto.h>

Classes | |
| struct | impl |
Public Types | |
| using | session_ticket_callback_t |
| Callback type for receiving session tickets. | |
Public Member Functions | |
| quic_crypto () | |
| Default constructor. | |
| ~quic_crypto () | |
| Destructor (cleans up OpenSSL resources) | |
| quic_crypto (const quic_crypto &)=delete | |
| quic_crypto & | operator= (const quic_crypto &)=delete |
| quic_crypto (quic_crypto &&other) noexcept | |
| quic_crypto & | operator= (quic_crypto &&other) noexcept |
| auto | init_client (const std::string &server_name) -> VoidResult |
| Initialize as client. | |
| auto | init_server (const std::string &cert_file, const std::string &key_file) -> VoidResult |
| Initialize as server. | |
| auto | derive_initial_secrets (const connection_id &dest_cid) -> VoidResult |
| Derive initial secrets from destination connection ID. | |
| auto | process_crypto_data (encryption_level level, std::span< const uint8_t > data) -> Result< std::vector< uint8_t > > |
| Process incoming CRYPTO frame data. | |
| auto | start_handshake () -> Result< std::vector< uint8_t > > |
| Start the handshake (generate initial CRYPTO data) | |
| auto | is_handshake_complete () const noexcept -> bool |
| Check if the handshake is complete. | |
| auto | current_level () const noexcept -> encryption_level |
| Get current encryption level. | |
| auto | get_write_keys (encryption_level level) const -> Result< quic_keys > |
| Get write keys for an encryption level. | |
| auto | get_read_keys (encryption_level level) const -> Result< quic_keys > |
| Get read keys for an encryption level. | |
| void | set_keys (encryption_level level, const quic_keys &read_keys, const quic_keys &write_keys) |
| Set keys for an encryption level (used during handshake) | |
| auto | update_keys () -> VoidResult |
| Perform a key update (1-RTT only) | |
| auto | get_alpn () const -> std::string |
| Get the negotiated ALPN protocol. | |
| auto | set_alpn (const std::vector< std::string > &protocols) -> VoidResult |
| Set ALPN protocols to offer/accept. | |
| auto | is_server () const noexcept -> bool |
| Check if this is a server instance. | |
| auto | key_phase () const noexcept -> uint8_t |
| Get current key phase (for key updates) | |
| void | set_session_ticket_callback (session_ticket_callback_t cb) |
| Set callback for receiving session tickets. | |
| auto | set_session_ticket (std::span< const uint8_t > ticket_data) -> VoidResult |
| Set a session ticket for 0-RTT resumption. | |
| auto | enable_early_data (uint32_t max_early_data) -> VoidResult |
| Enable 0-RTT early data. | |
| auto | is_early_data_accepted () const noexcept -> bool |
| Check if 0-RTT early data was accepted by the server. | |
| auto | derive_zero_rtt_keys () -> VoidResult |
| Derive 0-RTT keys from session ticket. | |
| auto | has_zero_rtt_keys () const noexcept -> bool |
| Check if 0-RTT keys are available. | |
Private Attributes | |
| std::unique_ptr< impl > | impl_ |
QUIC-TLS integration handler (RFC 9001)
Manages the TLS 1.3 handshake for QUIC, handling:
This class wraps OpenSSL for cryptographic operations.
Callback type for receiving session tickets.
This callback is invoked when a NewSessionTicket message is received from the server after handshake completion.
| ticket_data | Raw session ticket data |
| lifetime_hint | Ticket lifetime in seconds |
| ticket_age_add | Obfuscation value for ticket age |
| max_early_data | Maximum early data size (0 if early data not allowed) |
| kcenon::network::protocols::quic::quic_crypto::quic_crypto | ( | ) |
Default constructor.
Definition at line 772 of file crypto.cpp.
|
default |
Destructor (cleans up OpenSSL resources)
|
delete |
|
defaultnoexcept |
|
nodiscardnoexcept |
Get current encryption level.
Definition at line 1008 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::current_level, and impl_.
|
nodiscard |
Derive initial secrets from destination connection ID.
| dest_cid | Destination Connection ID |
Definition at line 883 of file crypto.cpp.
References kcenon::network::protocols::quic::initial_keys::derive(), kcenon::network::error_void(), kcenon::network::get_error_source(), kcenon::network::protocols::quic::initial, and kcenon::network::ok().

|
nodiscard |
Derive 0-RTT keys from session ticket.
Called internally when a valid session ticket is set.
Definition at line 1182 of file crypto.cpp.
References kcenon::network::protocols::quic::initial_keys::derive_keys(), kcenon::network::error_void(), kcenon::network::protocols::quic::hkdf::expand_label(), kcenon::network::protocols::quic::hkdf::extract(), kcenon::network::protocols::quic::initial_salt_v1, kcenon::network::ok(), kcenon::network::protocols::quic::secret_size, and kcenon::network::protocols::quic::zero_rtt.

|
nodiscard |
Enable 0-RTT early data.
| max_early_data | Maximum bytes of early data to send |
Must be called after set_session_ticket() and before init_client().
Definition at line 1163 of file crypto.cpp.
References kcenon::network::error_void(), and kcenon::network::ok().

|
nodiscard |
Get the negotiated ALPN protocol.
Definition at line 1097 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::alpn, and impl_.
|
nodiscard |
Get read keys for an encryption level.
| level | Desired encryption level |
Definition at line 1026 of file crypto.cpp.
References kcenon::network::protocols::quic::encryption_level_to_string(), kcenon::network::protocols::quic::error, and kcenon::network::ok().

|
nodiscard |
Get write keys for an encryption level.
| level | Desired encryption level |
Definition at line 1013 of file crypto.cpp.
References kcenon::network::protocols::quic::encryption_level_to_string(), kcenon::network::protocols::quic::error, and kcenon::network::ok().
Referenced by kcenon::network::protocols::quic::connection::generate_probe_packets().


|
nodiscardnoexcept |
Check if 0-RTT keys are available.
Definition at line 1265 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::has_zero_rtt_keys, and impl_.
|
nodiscard |
Initialize as client.
| server_name | Server hostname (for SNI) |
Definition at line 782 of file crypto.cpp.
References kcenon::network::error_void(), and kcenon::network::ok().

|
nodiscard |
Initialize as server.
| cert_file | Path to certificate file (PEM format) |
| key_file | Path to private key file (PEM format) |
Definition at line 827 of file crypto.cpp.
References kcenon::network::error_void(), and kcenon::network::ok().

|
nodiscardnoexcept |
Check if 0-RTT early data was accepted by the server.
This value is only meaningful after handshake completion.
Definition at line 1177 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::early_data_accepted, and impl_.
|
nodiscardnoexcept |
Check if the handshake is complete.
Definition at line 1003 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::handshake_complete, and impl_.
Referenced by kcenon::network::protocols::quic::connection::update_state().

|
nodiscardnoexcept |
Check if this is a server instance.
Definition at line 1132 of file crypto.cpp.
References impl_, and kcenon::network::protocols::quic::quic_crypto::impl::is_server.
|
nodiscardnoexcept |
Get current key phase (for key updates)
Definition at line 1137 of file crypto.cpp.
References impl_, and kcenon::network::protocols::quic::quic_crypto::impl::key_phase.
|
delete |
|
defaultnoexcept |
|
nodiscard |
Process incoming CRYPTO frame data.
| level | Encryption level of the data |
| data | CRYPTO frame payload |
Definition at line 912 of file crypto.cpp.
References kcenon::network::protocols::quic::application, kcenon::network::protocols::quic::error, and kcenon::network::ok().

|
nodiscard |
Set ALPN protocols to offer/accept.
| protocols | List of protocol names (e.g., {"h3", "hq-interop"}) |
Definition at line 1102 of file crypto.cpp.
References kcenon::network::error_void(), and kcenon::network::ok().

| void kcenon::network::protocols::quic::quic_crypto::set_keys | ( | encryption_level | level, |
| const quic_keys & | read_keys, | ||
| const quic_keys & | write_keys ) |
Set keys for an encryption level (used during handshake)
| level | Encryption level |
| read_keys | Keys for decryption |
| write_keys | Keys for encryption |
Definition at line 1039 of file crypto.cpp.
References kcenon::network::protocols::quic::quic_crypto::impl::current_level, impl_, kcenon::network::protocols::quic::quic_crypto::impl::read_keys, and kcenon::network::protocols::quic::quic_crypto::impl::write_keys.
|
nodiscard |
Set a session ticket for 0-RTT resumption.
| ticket_data | Session ticket from previous connection |
Must be called before init_client() for the ticket to be used.
Definition at line 1151 of file crypto.cpp.
References kcenon::network::error_void(), and kcenon::network::ok().

| void kcenon::network::protocols::quic::quic_crypto::set_session_ticket_callback | ( | session_ticket_callback_t | cb | ) |
Set callback for receiving session tickets.
| cb | Callback function |
The callback will be invoked on the I/O thread when a NewSessionTicket message is received from the server.
Definition at line 1146 of file crypto.cpp.
References impl_, and kcenon::network::protocols::quic::quic_crypto::impl::session_ticket_callback.
|
nodiscard |
Start the handshake (generate initial CRYPTO data)
Definition at line 965 of file crypto.cpp.
References kcenon::network::protocols::quic::error, and kcenon::network::ok().

|
nodiscard |
Perform a key update (1-RTT only)
Definition at line 1052 of file crypto.cpp.
References kcenon::network::protocols::quic::application, kcenon::network::protocols::quic::initial_keys::derive_keys(), kcenon::network::error_void(), kcenon::network::protocols::quic::hkdf::expand_label(), kcenon::network::get_error_source(), kcenon::network::ok(), and kcenon::network::protocols::quic::secret_size.

|
private |
Definition at line 448 of file crypto.h.
Referenced by current_level(), get_alpn(), has_zero_rtt_keys(), is_early_data_accepted(), is_handshake_complete(), is_server(), key_phase(), set_keys(), and set_session_ticket_callback().