OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::AEAD::Crypto< CRYPTO_API >::Nonce Class Reference

Public Member Functions

 Nonce ()
 
void set_tail (const StaticKey &sk)
 
 Nonce (const Nonce &ref, PacketIDDataSend &pid_send, const unsigned char *op32)
 
void prepend_ad (Buffer &buf, const PacketIDDataSend &pid_send) const
 
 Nonce (const Nonce &ref, const PacketIDDataReceive &recv_pid, Buffer &buf, const unsigned char *op32)
 
bool verify_packet_id (PacketIDDataReceive &pid_recv, const PacketIDControl::time_t now, const SessionStats::Ptr &stats_arg)
 
const unsigned char * iv () const
 
const unsigned char * ad () const
 
size_t ad_len (const PacketIDDataSend &pid_send) const
 
size_t ad_len (const PacketIDDataReceive &pid_recv) const
 

Private Attributes

bool ad_op32
 
unsigned char data [16]
 

Static Private Attributes

static constexpr std::size_t data_offset_pkt_id = 4
 
static constexpr std::size_t op32_size = 4
 

Detailed Description

template<typename CRYPTO_API>
class openvpn::AEAD::Crypto< CRYPTO_API >::Nonce

Definition at line 44 of file crypto_aead.hpp.

Constructor & Destructor Documentation

◆ Nonce() [1/3]

template<typename CRYPTO_API >
openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::Nonce ( )
inline

Definition at line 47 of file crypto_aead.hpp.

◆ Nonce() [2/3]

template<typename CRYPTO_API >
openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::Nonce ( const Nonce ref,
PacketIDDataSend pid_send,
const unsigned char *  op32 
)
inline

Copy op code and tail of packet ID

Definition at line 78 of file crypto_aead.hpp.

◆ Nonce() [3/3]

template<typename CRYPTO_API >
openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::Nonce ( const Nonce ref,
const PacketIDDataReceive recv_pid,
Buffer buf,
const unsigned char *  op32 
)
inline

Definition at line 101 of file crypto_aead.hpp.

Member Function Documentation

◆ ad()

template<typename CRYPTO_API >
const unsigned char * openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::ad ( ) const
inline

Definition at line 130 of file crypto_aead.hpp.

Here is the caller graph for this function:

◆ ad_len() [1/2]

template<typename CRYPTO_API >
size_t openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::ad_len ( const PacketIDDataReceive pid_recv) const
inline

Definition at line 140 of file crypto_aead.hpp.

◆ ad_len() [2/2]

template<typename CRYPTO_API >
size_t openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::ad_len ( const PacketIDDataSend pid_send) const
inline

Definition at line 135 of file crypto_aead.hpp.

Here is the caller graph for this function:

◆ iv()

template<typename CRYPTO_API >
const unsigned char * openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::iv ( ) const
inline

Definition at line 125 of file crypto_aead.hpp.

Here is the caller graph for this function:

◆ prepend_ad()

template<typename CRYPTO_API >
void openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::prepend_ad ( Buffer buf,
const PacketIDDataSend pid_send 
) const
inline

Definition at line 95 of file crypto_aead.hpp.

Here is the caller graph for this function:

◆ set_tail()

template<typename CRYPTO_API >
void openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::set_tail ( const StaticKey sk)
inline

Sets the IV tail for AEAD operations

The IV for AEAD ciphers (both AES-GCM and Chacha20-Poly1305) consists of 96 bits/12 bytes (It then gets concatenated with internal 32 bits for block counter to form a 128 bit counter for the encryption).

Since we only use 4 bytes (32 bit packet ID) on the wire, we fill out the rest of the IV with pseudorandom bytes that come from the negotiated key for the HMAC key (this key is not used by AEAD ciphers, so we reuse it for this purpose in AEAD mode).

Definition at line 66 of file crypto_aead.hpp.

Here is the caller graph for this function:

◆ verify_packet_id()

template<typename CRYPTO_API >
bool openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::verify_packet_id ( PacketIDDataReceive pid_recv,
const PacketIDControl::time_t  now,
const SessionStats::Ptr stats_arg 
)
inline

Definition at line 118 of file crypto_aead.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ ad_op32

template<typename CRYPTO_API >
bool openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::ad_op32
private

Definition at line 147 of file crypto_aead.hpp.

◆ data

template<typename CRYPTO_API >
unsigned char openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::data[16]
private

Definition at line 152 of file crypto_aead.hpp.

◆ data_offset_pkt_id

template<typename CRYPTO_API >
constexpr std::size_t openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::data_offset_pkt_id = 4
staticconstexprprivate

Definition at line 153 of file crypto_aead.hpp.

◆ op32_size

template<typename CRYPTO_API >
constexpr std::size_t openvpn::AEAD::Crypto< CRYPTO_API >::Nonce::op32_size = 4
staticconstexprprivate

Definition at line 154 of file crypto_aead.hpp.


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