OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::ProtoContext::KeyContext Class Reference

#include <proto.hpp>

Inheritance diagram for openvpn::ProtoContext::KeyContext:
[legend]
Collaboration diagram for openvpn::ProtoContext::KeyContext:
[legend]

Classes

struct  DataChannelKey
 
struct  UnwrappedWkc
 What a WKc yields, owned by whoever asked for the unwrap. More...
 
struct  WkcMetadata
 The metadata record a WKc carried, for TLSCryptMetadata::verify() More...
 

Public Types

enum  EventType {
  KEV_NONE , KEV_ACTIVE , KEV_NEGOTIATE , KEV_BECOME_PRIMARY ,
  KEV_PRIMARY_PENDING , KEV_RENEGOTIATE , KEV_RENEGOTIATE_FORCE , KEV_RENEGOTIATE_QUEUE ,
  KEV_EXPIRE
}
 
using Ptr = RCPtr< KeyContext >
 
- Public Types inherited from openvpn::RC< thread_unsafe_refcount >
using Ptr = RCPtr< RC >
 

Public Member Functions

 OPENVPN_SIMPLE_EXCEPTION (tls_crypt_unwrap_wkc_error)
 
 KeyContext (ProtoContext &p, const bool initiator, bool psid_cookie_mode=false)
 
void set_protocol (const Protocol &p)
 
uint32_t get_tls_warnings () const
 
void start (const ProtoSessionID cookie_psid=ProtoSessionID())
 Initialize the state machine and start protocol negotiation.
 
void flush ()
 
void invalidate (const Error::Type reason)
 
void retransmit ()
 
Time next_retransmit () const
 
void app_send_validate (BufferPtr &&bp)
 
void app_send (BufferPtr &&bp)
 
bool net_recv (Packet &&pkt)
 
void encrypt (BufferAllocated &buf)
 
void decrypt (BufferAllocated &buf)
 
void prepare_expire (const EventType current_ev=KeyContext::KEV_NONE)
 
void set_next_event_if_unspecified ()
 
void key_limit_reneg (const EventType ev, const Time &t)
 
Time become_primary_time ()
 
bool event_pending ()
 
EventType get_event () const
 
void reset_event ()
 
bool invalidated () const
 
Error::Type invalidation_reason () const
 
unsigned int key_id () const
 
bool data_channel_ready () const
 
bool is_dirty () const
 
void rekey (const CryptoDCInstance::RekeyType type)
 
Time reached_active () const
 
void send_keepalive ()
 
void send_explicit_exit_notify ()
 
void send_data_channel_message (const unsigned char *data, const size_t size)
 
void generate_datachannel_keys ()
 
void calculate_mssfix (ProtoConfig &c)
 
void init_data_channel ()
 
void data_limit_notify (const DataLimit::Mode cdl_mode, const DataLimit::State cdl_status)
 
int get_state () const
 
- Public Member Functions inherited from openvpn::RC< thread_unsafe_refcount >
 RC () noexcept=default
 
 RC (const RC &)=delete
 
virtual ~RC ()=default
 
RCoperator= (const RC &)=delete
 
olong use_count () const noexcept
 Delegates call to RCImpl and returns the result.
 

Static Public Member Functions

static const char * event_type_string (const EventType et)
 
static bool validate (const Buffer &net_buf, ProtoContext &proto, TimePtr now)
 
static size_t tls_crypt_frame_size (const ProtoConfig &proto_config)
 Smallest tls-crypt frame a WKc can be appended to.
 
static size_t wkc_overhead (const ProtoConfig &proto_config)
 What a WKc holds besides the client key and the metadata.
 
static bool trailing_wkc_len (const Buffer &recv, const ProtoConfig &proto_config, const size_t min_wkc_len, uint16_t &wkc_len)
 Read and validate the WKc length a tls-crypt-v2 packet ends with.
 
static Error::Type unwrap_tls_crypt_wkc (Buffer &recv, const ProtoConfig &proto_config, TLSCryptInstance &tls_crypt_server, UnwrappedWkc &unwrapped)
 Extract and process the TLS crypt WKc information.
 
static bool strip_resent_wkc (Buffer &recv, const ProtoConfig &proto_config)
 Virtually remove a resent WKc from the end of a CONTROL_WKC_V1 packet.
 
- Static Public Member Functions inherited from openvpn::RC< thread_unsafe_refcount >
static constexpr bool is_thread_safe ()
 Delegates call to RCImpl and returns the result.
 

Private Types

using Base = ProtoStackBase< Packet, KeyContext >
 
using ReliableSend = Base::ReliableSend
 
using ReliableRecv = Base::ReliableRecv
 
- Private Types inherited from openvpn::ProtoStackBase< Packet, KeyContext >
enum  NetSendType
 
using id_t = reliable::id_t
 
using ReliableSend = ReliableSendTemplate< Packet >
 
using ReliableRecv = ReliableRecvTemplate< Packet >
 

Private Member Functions

bool do_encrypt (BufferAllocated &buf, const bool compress_hint)
 
void cache_op32 ()
 
void set_state (const int newstate)
 
void set_event (const EventType current)
 
void set_event (const EventType current, const EventType next, const Time &next_time)
 
void invalidate_callback ()
 
void schedule_key_limit_renegotiation ()
 
bool data_limit_add (const DataLimit::Mode mode, const size_t size)
 
void data_limit_event (const DataLimit::Mode mode, const DataLimit::State state)
 
bool data_limit_defer () const
 
Time data_limit_expire () const
 
void active_event ()
 
void process_next_event ()
 
void kev_error (const EventType ev, const Error::Type reason)
 
unsigned int initial_op (const bool sender, const bool tls_crypt_v2) const
 
void send_reset ()
 
bool parse_early_negotiation (const Packet &pkt)
 
void raw_recv (Packet &&raw_pkt)
 
void app_recv (BufferPtr &&to_app_buf)
 
void net_send (const Packet &net_pkt, const Base::NetSendType nstype)
 
void post_ack_action ()
 
void send_auth ()
 
void recv_auth (BufferPtr buf)
 
bool recv_auth_complete (BufferComplete &bc) const
 
void active ()
 
void prepend_dest_psid_and_acks (Buffer &buf, unsigned int opcode)
 
bool verify_src_psid (const ProtoSessionID &src_psid)
 
void accept_peer (const ProtoSessionID &src_psid)
 Adopt src_psid as our peer, and mark this packet as ours.
 
bool verify_dest_psid (Buffer &buf)
 
void gen_head_tls_auth (const unsigned int opcode, Buffer &buf)
 
void gen_head_tls_crypt (const unsigned int opcode, BufferAllocated &buf)
 
void gen_head_tls_plain (const unsigned int opcode, Buffer &buf)
 
void gen_head (const unsigned int opcode, BufferAllocated &buf)
 
bool packet_carries_wkc (id_t id) const
 
size_t control_channel_wrap_overhead () const
 
size_t control_ciphertext_capacity (id_t id) const
 
void encapsulate (id_t id, Packet &pkt)
 
void generate_ack (Packet &pkt)
 
bool decapsulate_post_process (Packet &pkt, ProtoSessionID &src_psid, const PacketIDControl pid)
 
bool decapsulate_tls_auth (Packet &pkt)
 
bool decapsulate_tls_crypt (Packet &pkt)
 
bool decapsulate_tls_plain (Packet &pkt)
 
bool tls_crypt_v2_wanted (const Packet &pkt) const
 May this packet make a tls-auth server session a tls-crypt-v2 one?
 
bool decapsulate (Packet &pkt)
 
bool decapsulate_by_wrap_mode (Packet &pkt)
 Decapsulate pkt with the wrap mode this session is in.
 
int seconds_until (const Time &next_time)
 
- Private Member Functions inherited from openvpn::ProtoStackBase< Packet, KeyContext >
 OPENVPN_SIMPLE_EXCEPTION (proto_stack_invalidated)
 
 OPENVPN_SIMPLE_EXCEPTION (unknown_status_from_ssl_layer)
 
 ProtoStackBase (SSLFactoryAPI &ssl_factory, TimePtr now_arg, const Time::Duration &tls_timeout_arg, const Frame::Ptr &frame, const SessionStats::Ptr &stats_arg, bool psid_cookie_mode)
 
void start_handshake ()
 
uint32_t get_tls_warnings () const
 
bool net_recv (Packet &&pkt)
 
void app_send (BufferPtr &&buf)
 
void raw_send (Packet &&pkt)
 
void flush ()
 
void send_pending_acks ()
 
void retransmit ()
 
Time next_retransmit () const
 
bool ssl_started () const
 
bool invalidated () const
 
Error::Type invalidation_reason () const
 
void invalidate (const Error::Type reason)
 
std::string ssl_handshake_details () const
 
void export_key_material (OpenVPNStaticKey &key, const std::string &label) const
 
const AuthCert::Ptrauth_cert () const
 

Static Private Member Functions

static bool validate_tls_auth (Buffer &recv, ProtoContext &proto, TimePtr now)
 
static bool validate_tls_crypt (Buffer &recv, ProtoContext &proto, TimePtr now)
 
static bool validate_tls_plain (Buffer &recv, ProtoContext &proto, TimePtr now)
 
static const char * state_string (const int s)
 

Private Attributes

friend Base
 
ProtoContextproto
 
int state
 
unsigned int key_id_
 
unsigned int crypto_flags
 
int remote_peer_id
 
bool enable_op32
 
bool resend_wkc = false
 
bool pkt_from_peer = false
 Set per packet by accept_peer(), read by decapsulate()
 
bool dirty
 
bool key_limit_renegotiation_fired
 
bool is_reliable
 
Compress::Ptr compress
 
CryptoDCInstance::Ptr crypto
 
TLSPRFInstance::Ptr tlsprf
 
Time construct_time
 
Time reached_active_time_
 
Time next_event_time
 
EventType current_event
 
EventType next_event
 
std::deque< BufferPtrapp_pre_write_queue
 
std::unique_ptr< DataChannelKeydata_channel_key
 
BufferComposed app_recv_buf
 
std::unique_ptr< DataLimitdata_limit
 
BufferAllocated work
 
- Private Attributes inherited from openvpn::ProtoStackBase< Packet, KeyContext >
TimePtr now
 
ReliableRecv rel_recv
 
ReliableSend rel_send
 
ReliableAck xmit_acks
 

Static Private Attributes

static BufferAllocated static_work
 
- Static Private Attributes inherited from openvpn::ProtoStackBase< Packet, KeyContext >
static constexpr size_t ovpn_sending_window
 
static constexpr size_t ovpn_receiving_window
 

Detailed Description

Definition at line 1711 of file proto.hpp.

Member Typedef Documentation

◆ Base

◆ Ptr

◆ ReliableRecv

◆ ReliableSend

Member Enumeration Documentation

◆ EventType

Enumerator
KEV_NONE 
KEV_ACTIVE 
KEV_NEGOTIATE 
KEV_BECOME_PRIMARY 
KEV_PRIMARY_PENDING 
KEV_RENEGOTIATE 
KEV_RENEGOTIATE_FORCE 
KEV_RENEGOTIATE_QUEUE 
KEV_EXPIRE 

Definition at line 1768 of file proto.hpp.

Constructor & Destructor Documentation

◆ KeyContext()

openvpn::ProtoContext::KeyContext::KeyContext ( ProtoContext p,
const bool  initiator,
bool  psid_cookie_mode = false 
)
inline

Definition at line 1835 of file proto.hpp.

Member Function Documentation

◆ accept_peer()

void openvpn::ProtoContext::KeyContext::accept_peer ( const ProtoSessionID src_psid)
inlineprivate

Adopt src_psid as our peer, and mark this packet as ours.

Reached only once a packet has verified under one of this session's keys and echoed the psid we chose. Pinning earlier let a packet that was then rejected name the peer anyway. Must precede any queued ACK: prepend_dest_psid_and_acks() throws without a peer psid.

Definition at line 3324 of file proto.hpp.

Here is the caller graph for this function:

◆ active()

void openvpn::ProtoContext::KeyContext::active ( )
inlineprivate

Definition at line 3263 of file proto.hpp.

Here is the caller graph for this function:

◆ active_event()

void openvpn::ProtoContext::KeyContext::active_event ( )
inlineprivate

Definition at line 2998 of file proto.hpp.

Here is the caller graph for this function:

◆ app_recv()

void openvpn::ProtoContext::KeyContext::app_recv ( BufferPtr &&  to_app_buf)
inlineprivate

Definition at line 3133 of file proto.hpp.

◆ app_send()

void openvpn::ProtoContext::KeyContext::app_send ( BufferPtr &&  bp)
inline

Definition at line 1941 of file proto.hpp.

Here is the caller graph for this function:

◆ app_send_validate()

void openvpn::ProtoContext::KeyContext::app_send_validate ( BufferPtr &&  bp)
inline

Definition at line 1933 of file proto.hpp.

Here is the caller graph for this function:

◆ become_primary_time()

Time openvpn::ProtoContext::KeyContext::become_primary_time ( )
inline

Definition at line 2054 of file proto.hpp.

◆ cache_op32()

void openvpn::ProtoContext::KeyContext::cache_op32 ( )
inlineprivate

Definition at line 2880 of file proto.hpp.

Here is the caller graph for this function:

◆ calculate_mssfix()

void openvpn::ProtoContext::KeyContext::calculate_mssfix ( ProtoConfig c)
inline

Definition at line 2230 of file proto.hpp.

Here is the caller graph for this function:

◆ control_channel_wrap_overhead()

size_t openvpn::ProtoContext::KeyContext::control_channel_wrap_overhead ( ) const
inlineprivate

Definition at line 3457 of file proto.hpp.

Here is the caller graph for this function:

◆ control_ciphertext_capacity()

size_t openvpn::ProtoContext::KeyContext::control_ciphertext_capacity ( id_t  id) const
inlineprivate

Definition at line 3475 of file proto.hpp.

◆ data_channel_ready()

bool openvpn::ProtoContext::KeyContext::data_channel_ready ( ) const
inline

Definition at line 2100 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_add()

bool openvpn::ProtoContext::KeyContext::data_limit_add ( const DataLimit::Mode  mode,
const size_t  size 
)
inlineprivate

Definition at line 2948 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_defer()

bool openvpn::ProtoContext::KeyContext::data_limit_defer ( ) const
inlineprivate

Definition at line 2984 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_event()

void openvpn::ProtoContext::KeyContext::data_limit_event ( const DataLimit::Mode  mode,
const DataLimit::State  state 
)
inlineprivate

Definition at line 2959 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_expire()

Time openvpn::ProtoContext::KeyContext::data_limit_expire ( ) const
inlineprivate

Definition at line 2993 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_notify()

void openvpn::ProtoContext::KeyContext::data_limit_notify ( const DataLimit::Mode  cdl_mode,
const DataLimit::State  cdl_status 
)
inline

Definition at line 2381 of file proto.hpp.

◆ decapsulate()

bool openvpn::ProtoContext::KeyContext::decapsulate ( Packet pkt)
inlineprivate

tls-auth/tls-crypt packet id. We start with a different id here to indicate EARLY_NEG_START/CONTROL_WKC_V1 support

Definition at line 3757 of file proto.hpp.

◆ decapsulate_by_wrap_mode()

bool openvpn::ProtoContext::KeyContext::decapsulate_by_wrap_mode ( Packet pkt)
inlineprivate

Decapsulate pkt with the wrap mode this session is in.

Split out of decapsulate() so that what the wrap mode decides stays separate from what every packet gets: the tls-crypt-v2 arm is the one with a step of its own, since on a server the key its frame is read with comes from the WKc the packet carries and from nowhere else.

Returns
whether the packet yielded a message for the reliable receive layer. A packet of our peer's carrying only ACKs authenticates and returns false, so this is not the test for whether the sender is who it claims – see pkt_from_peer.

Definition at line 3833 of file proto.hpp.

Here is the caller graph for this function:

◆ decapsulate_post_process()

bool openvpn::ProtoContext::KeyContext::decapsulate_post_process ( Packet pkt,
ProtoSessionID src_psid,
const PacketIDControl  pid 
)
inlineprivate

Definition at line 3526 of file proto.hpp.

Here is the caller graph for this function:

◆ decapsulate_tls_auth()

bool openvpn::ProtoContext::KeyContext::decapsulate_tls_auth ( Packet pkt)
inlineprivate

Definition at line 3595 of file proto.hpp.

Here is the caller graph for this function:

◆ decapsulate_tls_crypt()

bool openvpn::ProtoContext::KeyContext::decapsulate_tls_crypt ( Packet pkt)
inlineprivate

Definition at line 3629 of file proto.hpp.

Here is the caller graph for this function:

◆ decapsulate_tls_plain()

bool openvpn::ProtoContext::KeyContext::decapsulate_tls_plain ( Packet pkt)
inlineprivate

Definition at line 3696 of file proto.hpp.

Here is the caller graph for this function:

◆ decrypt()

void openvpn::ProtoContext::KeyContext::decrypt ( BufferAllocated buf)
inline

Definition at line 1982 of file proto.hpp.

Here is the caller graph for this function:

◆ do_encrypt()

bool openvpn::ProtoContext::KeyContext::do_encrypt ( BufferAllocated buf,
const bool  compress_hint 
)
inlineprivate

Definition at line 2836 of file proto.hpp.

Here is the caller graph for this function:

◆ encapsulate()

void openvpn::ProtoContext::KeyContext::encapsulate ( id_t  id,
Packet pkt 
)
inlineprivate

Definition at line 3496 of file proto.hpp.

◆ encrypt()

void openvpn::ProtoContext::KeyContext::encrypt ( BufferAllocated buf)
inline

Definition at line 1961 of file proto.hpp.

◆ event_pending()

bool openvpn::ProtoContext::KeyContext::event_pending ( )
inline

Definition at line 2062 of file proto.hpp.

◆ event_type_string()

static const char * openvpn::ProtoContext::KeyContext::event_type_string ( const EventType  et)
inlinestatic

Definition at line 1808 of file proto.hpp.

Here is the caller graph for this function:

◆ flush()

void openvpn::ProtoContext::KeyContext::flush ( )
inline

Definition at line 1901 of file proto.hpp.

Here is the caller graph for this function:

◆ gen_head()

void openvpn::ProtoContext::KeyContext::gen_head ( const unsigned int  opcode,
BufferAllocated buf 
)
inlineprivate

Definition at line 3424 of file proto.hpp.

Here is the caller graph for this function:

◆ gen_head_tls_auth()

void openvpn::ProtoContext::KeyContext::gen_head_tls_auth ( const unsigned int  opcode,
Buffer buf 
)
inlineprivate

Definition at line 3344 of file proto.hpp.

Here is the caller graph for this function:

◆ gen_head_tls_crypt()

void openvpn::ProtoContext::KeyContext::gen_head_tls_crypt ( const unsigned int  opcode,
BufferAllocated buf 
)
inlineprivate

Definition at line 3366 of file proto.hpp.

Here is the caller graph for this function:

◆ gen_head_tls_plain()

void openvpn::ProtoContext::KeyContext::gen_head_tls_plain ( const unsigned int  opcode,
Buffer buf 
)
inlineprivate

Definition at line 3416 of file proto.hpp.

Here is the caller graph for this function:

◆ generate_ack()

void openvpn::ProtoContext::KeyContext::generate_ack ( Packet pkt)
inlineprivate

Definition at line 3516 of file proto.hpp.

◆ generate_datachannel_keys()

void openvpn::ProtoContext::KeyContext::generate_datachannel_keys ( )
inline

Definition at line 2203 of file proto.hpp.

Here is the caller graph for this function:

◆ get_event()

EventType openvpn::ProtoContext::KeyContext::get_event ( ) const
inline

Definition at line 2070 of file proto.hpp.

◆ get_state()

int openvpn::ProtoContext::KeyContext::get_state ( ) const
inline

Definition at line 2388 of file proto.hpp.

◆ get_tls_warnings()

uint32_t openvpn::ProtoContext::KeyContext::get_tls_warnings ( ) const
inline

Definition at line 1873 of file proto.hpp.

◆ init_data_channel()

void openvpn::ProtoContext::KeyContext::init_data_channel ( )
inline

Definition at line 2320 of file proto.hpp.

Here is the caller graph for this function:

◆ initial_op()

unsigned int openvpn::ProtoContext::KeyContext::initial_op ( const bool  sender,
const bool  tls_crypt_v2 
) const
inlineprivate

Definition at line 3045 of file proto.hpp.

Here is the caller graph for this function:

◆ invalidate()

void openvpn::ProtoContext::KeyContext::invalidate ( const Error::Type  reason)
inline

Definition at line 1912 of file proto.hpp.

Here is the caller graph for this function:

◆ invalidate_callback()

void openvpn::ProtoContext::KeyContext::invalidate_callback ( )
inlineprivate

Definition at line 2913 of file proto.hpp.

◆ invalidated()

bool openvpn::ProtoContext::KeyContext::invalidated ( ) const
inline

Definition at line 2082 of file proto.hpp.

Here is the caller graph for this function:

◆ invalidation_reason()

Error::Type openvpn::ProtoContext::KeyContext::invalidation_reason ( ) const
inline

Definition at line 2088 of file proto.hpp.

◆ is_dirty()

bool openvpn::ProtoContext::KeyContext::is_dirty ( ) const
inline

Definition at line 2105 of file proto.hpp.

◆ kev_error()

void openvpn::ProtoContext::KeyContext::kev_error ( const EventType  ev,
const Error::Type  reason 
)
inlineprivate

Definition at line 3038 of file proto.hpp.

Here is the caller graph for this function:

◆ key_id()

unsigned int openvpn::ProtoContext::KeyContext::key_id ( ) const
inline

Definition at line 2094 of file proto.hpp.

Here is the caller graph for this function:

◆ key_limit_reneg()

void openvpn::ProtoContext::KeyContext::key_limit_reneg ( const EventType  ev,
const Time t 
)
inline

Definition at line 2047 of file proto.hpp.

Here is the caller graph for this function:

◆ net_recv()

bool openvpn::ProtoContext::KeyContext::net_recv ( Packet &&  pkt)
inline

Definition at line 1953 of file proto.hpp.

Here is the caller graph for this function:

◆ net_send()

void openvpn::ProtoContext::KeyContext::net_send ( const Packet net_pkt,
const Base::NetSendType  nstype 
)
inlineprivate

Definition at line 3166 of file proto.hpp.

◆ next_retransmit()

Time openvpn::ProtoContext::KeyContext::next_retransmit ( ) const
inline

Definition at line 1925 of file proto.hpp.

◆ OPENVPN_SIMPLE_EXCEPTION()

openvpn::ProtoContext::KeyContext::OPENVPN_SIMPLE_EXCEPTION ( tls_crypt_unwrap_wkc_error  )

◆ packet_carries_wkc()

bool openvpn::ProtoContext::KeyContext::packet_carries_wkc ( id_t  id) const
inlineprivate

Definition at line 3446 of file proto.hpp.

Here is the caller graph for this function:

◆ parse_early_negotiation()

bool openvpn::ProtoContext::KeyContext::parse_early_negotiation ( const Packet pkt)
inlineprivate

Definition at line 3068 of file proto.hpp.

Here is the caller graph for this function:

◆ post_ack_action()

void openvpn::ProtoContext::KeyContext::post_ack_action ( )
inlineprivate

Definition at line 3172 of file proto.hpp.

Here is the caller graph for this function:

◆ prepare_expire()

void openvpn::ProtoContext::KeyContext::prepare_expire ( const EventType  current_ev = KeyContext::KEV_NONE)
inline

Definition at line 2032 of file proto.hpp.

Here is the caller graph for this function:

◆ prepend_dest_psid_and_acks()

void openvpn::ProtoContext::KeyContext::prepend_dest_psid_and_acks ( Buffer buf,
unsigned int  opcode 
)
inlineprivate

Definition at line 3286 of file proto.hpp.

Here is the caller graph for this function:

◆ process_next_event()

void openvpn::ProtoContext::KeyContext::process_next_event ( )
inlineprivate

Definition at line 3005 of file proto.hpp.

Here is the caller graph for this function:

◆ raw_recv()

void openvpn::ProtoContext::KeyContext::raw_recv ( Packet &&  raw_pkt)
inlineprivate

Definition at line 3112 of file proto.hpp.

◆ reached_active()

Time openvpn::ProtoContext::KeyContext::reached_active ( ) const
inline

Definition at line 2123 of file proto.hpp.

Here is the caller graph for this function:

◆ recv_auth()

void openvpn::ProtoContext::KeyContext::recv_auth ( BufferPtr  buf)
inlineprivate

Definition at line 3226 of file proto.hpp.

Here is the caller graph for this function:

◆ recv_auth_complete()

bool openvpn::ProtoContext::KeyContext::recv_auth_complete ( BufferComplete bc) const
inlineprivate

Definition at line 3243 of file proto.hpp.

Here is the caller graph for this function:

◆ rekey()

void openvpn::ProtoContext::KeyContext::rekey ( const CryptoDCInstance::RekeyType  type)
inline

Definition at line 2111 of file proto.hpp.

◆ reset_event()

void openvpn::ProtoContext::KeyContext::reset_event ( )
inline

Definition at line 2076 of file proto.hpp.

◆ retransmit()

void openvpn::ProtoContext::KeyContext::retransmit ( )
inline

Definition at line 1918 of file proto.hpp.

◆ schedule_key_limit_renegotiation()

void openvpn::ProtoContext::KeyContext::schedule_key_limit_renegotiation ( )
inlineprivate

Definition at line 2922 of file proto.hpp.

Here is the caller graph for this function:

◆ seconds_until()

int openvpn::ProtoContext::KeyContext::seconds_until ( const Time next_time)
inlineprivate

Definition at line 3945 of file proto.hpp.

Here is the caller graph for this function:

◆ send_auth()

void openvpn::ProtoContext::KeyContext::send_auth ( )
inlineprivate

Definition at line 3199 of file proto.hpp.

Here is the caller graph for this function:

◆ send_data_channel_message()

void openvpn::ProtoContext::KeyContext::send_data_channel_message ( const unsigned char *  data,
const size_t  size 
)
inline

Definition at line 2147 of file proto.hpp.

Here is the caller graph for this function:

◆ send_explicit_exit_notify()

void openvpn::ProtoContext::KeyContext::send_explicit_exit_notify ( )
inline

Definition at line 2136 of file proto.hpp.

◆ send_keepalive()

void openvpn::ProtoContext::KeyContext::send_keepalive ( )
inline

Definition at line 2129 of file proto.hpp.

◆ send_reset()

void openvpn::ProtoContext::KeyContext::send_reset ( )
inlineprivate

Definition at line 3060 of file proto.hpp.

Here is the caller graph for this function:

◆ set_event() [1/2]

void openvpn::ProtoContext::KeyContext::set_event ( const EventType  current)
inlineprivate

Definition at line 2894 of file proto.hpp.

Here is the caller graph for this function:

◆ set_event() [2/2]

void openvpn::ProtoContext::KeyContext::set_event ( const EventType  current,
const EventType  next,
const Time next_time 
)
inlineprivate

Definition at line 2902 of file proto.hpp.

◆ set_next_event_if_unspecified()

void openvpn::ProtoContext::KeyContext::set_next_event_if_unspecified ( )
inline

Definition at line 2040 of file proto.hpp.

◆ set_protocol()

void openvpn::ProtoContext::KeyContext::set_protocol ( const Protocol p)
inline

Definition at line 1868 of file proto.hpp.

Here is the caller graph for this function:

◆ set_state()

void openvpn::ProtoContext::KeyContext::set_state ( const int  newstate)
inlineprivate

Definition at line 2886 of file proto.hpp.

Here is the caller graph for this function:

◆ start()

void openvpn::ProtoContext::KeyContext::start ( const ProtoSessionID  cookie_psid = ProtoSessionID())
inline

Initialize the state machine and start protocol negotiation.

Called by ProtoContext::start()

Parameters
cookie_psidsee comment in ProtoContext::reset()

Definition at line 1885 of file proto.hpp.

◆ state_string()

static const char * openvpn::ProtoContext::KeyContext::state_string ( const int  s)
inlinestaticprivate

Definition at line 3913 of file proto.hpp.

Here is the caller graph for this function:

◆ strip_resent_wkc()

static bool openvpn::ProtoContext::KeyContext::strip_resent_wkc ( Buffer recv,
const ProtoConfig proto_config 
)
inlinestatic

Virtually remove a resent WKc from the end of a CONTROL_WKC_V1 packet.

A client asked to resend its WKc (EARLY_NEG_FLAG_RESEND_WKC) appends it to every transmission of the third handshake packet, retransmissions included, since encapsulate() re-runs for each of them. By the time such a packet reaches a session the client key it wraps is already set up, so the WKc is of no further use and must simply be taken off: the tls-crypt frame in front of it is what gets decapsulated, and its auth tag covers that frame alone.

OpenVPN 2 does the same in tls_crypt_v2_extract_client_key() when its initial_packet argument is false, turning the packet back into a CONTROL_V1.

Returns
false if the trailing length does not describe a WKc that fits behind a tls-crypt frame, i.e. the packet is malformed and must be dropped.

Definition at line 2676 of file proto.hpp.

Here is the caller graph for this function:

◆ tls_crypt_frame_size()

static size_t openvpn::ProtoContext::KeyContext::tls_crypt_frame_size ( const ProtoConfig proto_config)
inlinestatic

Smallest tls-crypt frame a WKc can be appended to.

Header, auth tag, an empty ACK array and the reliable ID, with no ciphertext – a WKc can fill a packet by itself, see control_ciphertext_capacity().

Definition at line 2399 of file proto.hpp.

Here is the caller graph for this function:

◆ tls_crypt_v2_wanted()

bool openvpn::ProtoContext::KeyContext::tls_crypt_v2_wanted ( const Packet pkt) const
inlineprivate

May this packet make a tls-auth server session a tls-crypt-v2 one?

Only the opcode asks for the switch and packet_type() weighs nothing else, so a spoofed datagram gets a say. Hence: on offer only until a packet of our peer's has been accepted, and decapsulate() takes it back if this one is not.

Definition at line 3748 of file proto.hpp.

Here is the caller graph for this function:

◆ trailing_wkc_len()

static bool openvpn::ProtoContext::KeyContext::trailing_wkc_len ( const Buffer recv,
const ProtoConfig proto_config,
const size_t  min_wkc_len,
uint16_t &  wkc_len 
)
inlinestatic

Read and validate the WKc length a tls-crypt-v2 packet ends with.

wkc_len is read straight from the last two bytes of the packet and is therefore fully attacker-controlled. It has to be validated before any pointer arithmetic uses it: the WKc must fit between the end of the tls-crypt frame and the end of the packet, and hold at least min_wkc_len bytes. Without this a bogus length underflows the unsigned size computations into a wild pointer, causing an out-of-bounds read during decryption – an unauthenticated remote DoS.

Returns
false if recv is too short to hold the tls-crypt frame and the length field, or if wkc_len is smaller than min_wkc_len or larger than the space behind the frame.

Definition at line 2436 of file proto.hpp.

Here is the caller graph for this function:

◆ unwrap_tls_crypt_wkc()

static Error::Type openvpn::ProtoContext::KeyContext::unwrap_tls_crypt_wkc ( Buffer recv,
const ProtoConfig proto_config,
TLSCryptInstance tls_crypt_server,
UnwrappedWkc unwrapped 
)
inlinestatic

Extract and process the TLS crypt WKc information.

Parameters
recvBuffer containing the raw packet.
proto_configConfig object holding the settings needed for processing.
tls_crypt_serverServer context used only to process incoming WKc's.
unwrappedReceives the client key and the metadata record the WKc carried. Written only on success.
Returns
Error::SUCCESS on success.

Definition at line 2491 of file proto.hpp.

Here is the caller graph for this function:

◆ validate()

static bool openvpn::ProtoContext::KeyContext::validate ( const Buffer net_buf,
ProtoContext proto,
TimePtr  now 
)
inlinestatic

Definition at line 2169 of file proto.hpp.

Here is the caller graph for this function:

◆ validate_tls_auth()

static bool openvpn::ProtoContext::KeyContext::validate_tls_auth ( Buffer recv,
ProtoContext proto,
TimePtr  now 
)
inlinestaticprivate

Definition at line 2693 of file proto.hpp.

Here is the caller graph for this function:

◆ validate_tls_crypt()

static bool openvpn::ProtoContext::KeyContext::validate_tls_crypt ( Buffer recv,
ProtoContext proto,
TimePtr  now 
)
inlinestaticprivate

Definition at line 2741 of file proto.hpp.

Here is the caller graph for this function:

◆ validate_tls_plain()

static bool openvpn::ProtoContext::KeyContext::validate_tls_plain ( Buffer recv,
ProtoContext proto,
TimePtr  now 
)
inlinestaticprivate

Definition at line 2816 of file proto.hpp.

Here is the caller graph for this function:

◆ verify_dest_psid()

bool openvpn::ProtoContext::KeyContext::verify_dest_psid ( Buffer buf)
inlineprivate

Definition at line 3331 of file proto.hpp.

Here is the caller graph for this function:

◆ verify_src_psid()

bool openvpn::ProtoContext::KeyContext::verify_src_psid ( const ProtoSessionID src_psid)
inlineprivate

Definition at line 3304 of file proto.hpp.

Here is the caller graph for this function:

◆ wkc_overhead()

static size_t openvpn::ProtoContext::KeyContext::wkc_overhead ( const ProtoConfig proto_config)
inlinestatic

What a WKc holds besides the client key and the metadata.

Its own trailing length field, the authentication tag T, and the server key ID where one is configured. A WKc smaller than this cannot be parsed at all, so it is the floor an attacker-supplied length is held to.

Definition at line 2415 of file proto.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ app_pre_write_queue

std::deque<BufferPtr> openvpn::ProtoContext::KeyContext::app_pre_write_queue
private

Definition at line 3978 of file proto.hpp.

◆ app_recv_buf

BufferComposed openvpn::ProtoContext::KeyContext::app_recv_buf
private

Definition at line 3980 of file proto.hpp.

◆ Base

Definition at line 1714 of file proto.hpp.

◆ compress

Compress::Ptr openvpn::ProtoContext::KeyContext::compress
private

Definition at line 3970 of file proto.hpp.

◆ construct_time

Time openvpn::ProtoContext::KeyContext::construct_time
private

Definition at line 3973 of file proto.hpp.

◆ crypto

CryptoDCInstance::Ptr openvpn::ProtoContext::KeyContext::crypto
private

Definition at line 3971 of file proto.hpp.

◆ crypto_flags

unsigned int openvpn::ProtoContext::KeyContext::crypto_flags
private

Definition at line 3958 of file proto.hpp.

◆ current_event

EventType openvpn::ProtoContext::KeyContext::current_event
private

Definition at line 3976 of file proto.hpp.

◆ data_channel_key

std::unique_ptr<DataChannelKey> openvpn::ProtoContext::KeyContext::data_channel_key
private

Definition at line 3979 of file proto.hpp.

◆ data_limit

std::unique_ptr<DataLimit> openvpn::ProtoContext::KeyContext::data_limit
private

Definition at line 3981 of file proto.hpp.

◆ dirty

bool openvpn::ProtoContext::KeyContext::dirty
private

Definition at line 3967 of file proto.hpp.

◆ enable_op32

bool openvpn::ProtoContext::KeyContext::enable_op32
private

Definition at line 3960 of file proto.hpp.

◆ is_reliable

bool openvpn::ProtoContext::KeyContext::is_reliable
private

Definition at line 3969 of file proto.hpp.

◆ key_id_

unsigned int openvpn::ProtoContext::KeyContext::key_id_
private

Definition at line 3957 of file proto.hpp.

◆ key_limit_renegotiation_fired

bool openvpn::ProtoContext::KeyContext::key_limit_renegotiation_fired
private

Definition at line 3968 of file proto.hpp.

◆ next_event

EventType openvpn::ProtoContext::KeyContext::next_event
private

Definition at line 3977 of file proto.hpp.

◆ next_event_time

Time openvpn::ProtoContext::KeyContext::next_event_time
private

Definition at line 3975 of file proto.hpp.

◆ pkt_from_peer

bool openvpn::ProtoContext::KeyContext::pkt_from_peer = false
private

Set per packet by accept_peer(), read by decapsulate()

Definition at line 3966 of file proto.hpp.

◆ proto

ProtoContext& openvpn::ProtoContext::KeyContext::proto
private

Definition at line 3955 of file proto.hpp.

◆ reached_active_time_

Time openvpn::ProtoContext::KeyContext::reached_active_time_
private

Definition at line 3974 of file proto.hpp.

◆ remote_peer_id

int openvpn::ProtoContext::KeyContext::remote_peer_id
private

Definition at line 3959 of file proto.hpp.

◆ resend_wkc

bool openvpn::ProtoContext::KeyContext::resend_wkc = false
private

Definition at line 3964 of file proto.hpp.

◆ state

int openvpn::ProtoContext::KeyContext::state
private

Definition at line 3956 of file proto.hpp.

◆ static_work

BufferAllocated openvpn::ProtoContext::KeyContext::static_work
staticprivate

Definition at line 3985 of file proto.hpp.

◆ tlsprf

TLSPRFInstance::Ptr openvpn::ProtoContext::KeyContext::tlsprf
private

Definition at line 3972 of file proto.hpp.

◆ work

BufferAllocated openvpn::ProtoContext::KeyContext::work
private

Definition at line 3982 of file proto.hpp.


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