Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::protocols::quic::quic_keys Struct Reference

QUIC encryption keys for a single encryption level (RFC 9001 Section 5) More...

#include <keys.h>

Collaboration diagram for kcenon::network::protocols::quic::quic_keys:
Collaboration graph

Public Member Functions

auto is_valid () const noexcept -> bool
 Check if keys are initialized (non-zero)
 
void clear () noexcept
 Clear all key material securely.
 
auto operator== (const quic_keys &other) const noexcept -> bool
 Equality comparison.
 
auto operator!= (const quic_keys &other) const noexcept -> bool
 Inequality comparison.
 

Public Attributes

std::array< uint8_t, secret_sizesecret {}
 Traffic secret (used for key updates)
 
std::array< uint8_t, aes_128_key_sizekey {}
 AEAD encryption key (AES-128-GCM by default)
 
std::array< uint8_t, aead_iv_sizeiv {}
 AEAD initialization vector.
 
std::array< uint8_t, hp_key_sizehp_key {}
 Header protection key.
 

Detailed Description

QUIC encryption keys for a single encryption level (RFC 9001 Section 5)

Contains all the cryptographic material needed for packet protection:

  • Traffic secret: Used for key derivation and key updates
  • AEAD key: Used for payload encryption (AES-128-GCM or AES-256-GCM)
  • IV: Initialization vector XORed with packet number for nonce
  • HP key: Header protection key for protecting header bytes

Definition at line 91 of file keys.h.

Member Function Documentation

◆ clear()

void kcenon::network::protocols::quic::quic_keys::clear ( )
noexcept

Clear all key material securely.

Definition at line 36 of file keys.cpp.

37{
38 // Use volatile to prevent compiler optimization
39 volatile uint8_t* p;
40
41 p = secret.data();
42 std::memset(const_cast<uint8_t*>(p), 0, secret.size());
43
44 p = key.data();
45 std::memset(const_cast<uint8_t*>(p), 0, key.size());
46
47 p = iv.data();
48 std::memset(const_cast<uint8_t*>(p), 0, iv.size());
49
50 p = hp_key.data();
51 std::memset(const_cast<uint8_t*>(p), 0, hp_key.size());
52}
std::array< uint8_t, hp_key_size > hp_key
Header protection key.
Definition keys.h:103
std::array< uint8_t, aes_128_key_size > key
AEAD encryption key (AES-128-GCM by default)
Definition keys.h:97
std::array< uint8_t, secret_size > secret
Traffic secret (used for key updates)
Definition keys.h:94
std::array< uint8_t, aead_iv_size > iv
AEAD initialization vector.
Definition keys.h:100

References hp_key, iv, key, and secret.

Referenced by kcenon::network::protocols::quic::key_pair::clear().

Here is the caller graph for this function:

◆ is_valid()

auto kcenon::network::protocols::quic::quic_keys::is_valid ( ) const -> bool
nodiscardnoexcept

Check if keys are initialized (non-zero)

Returns
true if any key material is non-zero

Definition at line 30 of file keys.cpp.

31{
32 // Check if key is non-zero
33 return std::any_of(key.begin(), key.end(), [](uint8_t b) { return b != 0; });
34}

References key.

Referenced by kcenon::network::protocols::quic::key_pair::is_valid().

Here is the caller graph for this function:

◆ operator!=()

auto kcenon::network::protocols::quic::quic_keys::operator!= ( const quic_keys & other) const -> bool
nodiscardnoexcept

Inequality comparison.

Definition at line 60 of file keys.cpp.

61{
62 return !(*this == other);
63}

◆ operator==()

auto kcenon::network::protocols::quic::quic_keys::operator== ( const quic_keys & other) const -> bool
nodiscardnoexcept

Equality comparison.

Parameters
otherKeys to compare with
Returns
true if all key material matches

Definition at line 54 of file keys.cpp.

55{
56 return secret == other.secret && key == other.key && iv == other.iv &&
57 hp_key == other.hp_key;
58}

Member Data Documentation

◆ hp_key

std::array<uint8_t, hp_key_size> kcenon::network::protocols::quic::quic_keys::hp_key {}

Header protection key.

Definition at line 103 of file keys.h.

103{};

Referenced by clear(), and kcenon::network::protocols::quic::initial_keys::derive_keys().

◆ iv

std::array<uint8_t, aead_iv_size> kcenon::network::protocols::quic::quic_keys::iv {}

AEAD initialization vector.

Definition at line 100 of file keys.h.

100{};

Referenced by clear(), and kcenon::network::protocols::quic::initial_keys::derive_keys().

◆ key

std::array<uint8_t, aes_128_key_size> kcenon::network::protocols::quic::quic_keys::key {}

AEAD encryption key (AES-128-GCM by default)

Definition at line 97 of file keys.h.

97{};

Referenced by clear(), kcenon::network::protocols::quic::initial_keys::derive_keys(), and is_valid().

◆ secret

std::array<uint8_t, secret_size> kcenon::network::protocols::quic::quic_keys::secret {}

Traffic secret (used for key updates)

Definition at line 94 of file keys.h.

94{};

Referenced by clear().


The documentation for this struct was generated from the following files: