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

#include <proto.hpp>

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

Classes

class  IvProtoHelper
 
class  KeyContext
 
class  Packet
 
class  PacketType
 
class  ProbeWrap
 Wrap an out-of-band SERVER_PROBE / unwrap the matching PROBE_REPLY. More...
 
class  ProtoConfig
 
class  PsidCookieHelper
 
class  TLSAuthPreValidate
 
class  TLSCryptPreValidate
 
class  TLSWrapPreValidate
 
struct  TLSWrapSelection
 A control-channel wrap mode paired with its hmac size. More...
 

Public Types

enum class  UnwrapStatus { OK , DROP , HMAC_ERROR , DECRYPT_ERROR }
 

Public Member Functions

 OPENVPN_UNTAGGED_EXCEPTION_INHERIT (option_error, proto_error)
 
 OPENVPN_UNTAGGED_EXCEPTION_INHERIT (option_error, process_server_push_error)
 
 OPENVPN_UNTAGGED_EXCEPTION_INHERIT (option_error, proto_option_error)
 
std::string dump_packet (const Buffer &buf)
 
template<typename S >
void write_control_string (const S &str)
 
 OPENVPN_SIMPLE_EXCEPTION (select_key_context_error)
 
 ProtoContext (ProtoContextCallbackInterface *cb_arg, const ProtoConfig::Ptr &config_arg, const SessionStats::Ptr &stats_arg)
 
void reset_tls_wrap_mode (const ProtoConfig &c)
 
uint32_t get_tls_warnings () const
 
bool uses_bs64_cipher () const
 
void reset_tls_crypt (const ProtoConfig &c, const OpenVPNStaticKey &key)
 
void set_dynamic_tls_crypt (const ProtoConfig &c, const KeyContext::Ptr &key_ctx)
 
void reset_tls_crypt_server (const ProtoConfig &c)
 
void reset (const ProtoSessionID cookie_psid=ProtoSessionID())
 Resets ProtoContext *this to it's initial state.
 
void set_protocol (const Protocol &p)
 
void pre_destroy ()
 
bool primary_defined ()
 
virtual ~ProtoContext ()=default
 
PacketType packet_type (const Buffer &buf)
 
void start (const ProtoSessionID cookie_psid=ProtoSessionID())
 Initialize the state machine and start protocol negotiation.
 
void renegotiate ()
 
void flush (const bool control_channel)
 
void housekeeping ()
 
Time next_housekeeping () const
 
void control_send (BufferPtr &&app_bp)
 
void control_send (BufferAllocated &&app_buf)
 
bool control_net_validate (const PacketType &type, const Buffer &net_buf)
 
bool control_net_recv (const PacketType &type, BufferPtr &&net_bp)
 
bool control_net_recv (const PacketType &type, BufferAllocated &&net_buf)
 pass received control channel network packets (ciphertext) into protocol object
 
void data_encrypt (BufferAllocated &in_out)
 
bool data_decrypt (const PacketType &type, BufferAllocated &in_out)
 
void disconnect (const Error::Type reason)
 
void send_explicit_exit_notify ()
 
void update_last_sent ()
 
bool data_channel_ready () const
 
unsigned int negotiations () const
 
const Time::Duration & slowest_handshake ()
 
bool invalidated () const
 
Error::Type invalidation_reason () const
 
void init_data_channel ()
 
void process_push (const OptionList &opt, const ProtoContextCompressionOptions &pco)
 
size_t align_adjust_hint () const
 
bool is_keepalive_enabled () const
 
void disable_keepalive (unsigned int &keepalive_ping, unsigned int &keepalive_timeout)
 
void data_limit_notify (const unsigned int key_id, const DataLimit::Mode cdl_mode, const DataLimit::State cdl_status)
 
CryptoDCSettingsdc_settings ()
 
void reset_dc_factory ()
 
void set_local_peer_id (const int local_peer_id)
 
const Timenow () const
 
void update_now ()
 
const Frameframe () const
 
const Frame::Ptrframeptr () const
 
const Modemode () const
 
bool is_server () const
 
bool is_client () const
 
bool is_tcp ()
 
bool is_udp ()
 
const ProtoConfigconf () const
 
ProtoConfigconf ()
 
ProtoConfig::Ptr conf_ptr () const
 
SessionStatsstat () const
 
bool is_state_client_wait_reset_ack () const
 

Static Public Member Functions

static const char * opcode_name (const unsigned int opcode)
 
static void write_uint16_length (const size_t size, Buffer &buf)
 
static uint16_t read_uint16_length (Buffer &buf)
 
template<typename S >
static void write_auth_string (const S &str, Buffer &buf)
 
template<typename S >
static S read_auth_string (Buffer &buf)
 
template<typename S >
static void write_control_string (const S &str, Buffer &buf)
 
static void write_empty_string (Buffer &buf)
 
template<typename S >
static S read_control_string (const Buffer &buf)
 
static bool opcode_carries_wkc (const unsigned int opcode)
 Does a packet with this opcode carry a WKc?
 
static void wrap_tls_auth (const unsigned int opcode, Buffer &buf, PacketIDControlSend &pid_send, const PacketIDControl::time_t now_secs, const size_t hmac_size, const ProtoSessionID &psid_self, const unsigned int key_id, OvpnHMACInstance &ta_hmac_send)
 tls-auth: [op][psid][hmac][pid][payload]
 
static void wrap_tls_crypt (const unsigned int opcode, BufferAllocated &buf, BufferAllocated &work, Frame &frame, PacketIDControlSend &pid_send, const PacketIDControl::time_t now_secs, const size_t hmac_size, const ProtoSessionID &psid_self, const unsigned int key_id, TLSCryptInstance &tls_crypt_send, const Buffer *wkc)
 
static void wrap_tls_plain (const unsigned int opcode, Buffer &buf, const ProtoSessionID &psid_self, const unsigned int key_id)
 plaintext control channel: [op][psid][payload]
 
static UnwrapStatus unwrap_tls_auth (Buffer &recv, const size_t hmac_size, OvpnHMACInstance &ta_hmac_recv, const PacketIDControlReceive &pid_recv, ProtoSessionID &src_psid, PacketIDControl &pid)
 
static UnwrapStatus unwrap_tls_crypt (BufferAllocated &recv, BufferAllocated &work, Frame &frame, const size_t hmac_size, TLSCryptInstance &tls_crypt_recv, const PacketIDControlReceive &pid_recv, ProtoSessionID &src_psid, PacketIDControl &pid)
 
static void build_tls_auth (const ProtoConfig &c, OvpnHMACInstance::Ptr &send, OvpnHMACInstance::Ptr &recv)
 
static void build_tls_crypt (const ProtoConfig &c, const bool server, const OpenVPNStaticKey &key, TLSCryptInstance::Ptr &send, TLSCryptInstance::Ptr &recv)
 
- Static Public Member Functions inherited from openvpn::logging::LoggingMixin< OPENVPN_DEBUG_PROTO, logging::LOG_LEVEL_VERB, ProtoContext >
static int log_level ()
 return the current logging level for all logging
 
static void set_log_level (int level)
 set the log level for all loggigng
 

Static Public Attributes

static constexpr size_t MAX_CONTROL_WRAP_OVERHEAD
 
- Static Public Attributes inherited from openvpn::logging::LoggingMixin< OPENVPN_DEBUG_PROTO, logging::LOG_LEVEL_VERB, ProtoContext >
static constexpr int max_log_level
 
static constexpr int default_log_level
 

Protected Types

enum  {
  KEY_ID_MASK = 0x07 , OPCODE_SHIFT = 3 , CONTROL_SOFT_RESET_V1 = 3 , CONTROL_V1 = 4 ,
  CONTROL_WKC_V1 = 11 , CONTROL_OOB_V1 = 12 , CONTROL_OOB_WKC_V1 = 13 , ACK_V1 = 5 ,
  DATA_V1 = 6 , DATA_V2 = 9 , CONTROL_HARD_RESET_CLIENT_V2 = 7 , CONTROL_HARD_RESET_CLIENT_V3 = 10 ,
  CONTROL_HARD_RESET_SERVER_V2 = 8 , INVALID_OPCODE = 0 , OP_SIZE_V2 = 4 , OP_PEER_ID_UNDEF = 0x00FFFFFF ,
  STATE_UNDEF = -1 , C_WAIT_RESET_ACK = 0 , C_WAIT_AUTH_ACK = 1 , S_WAIT_RESET_ACK = 2 ,
  S_WAIT_AUTH_ACK = 3 , LAST_ACK_STATE = 3 , C_INITIAL = 4 , C_WAIT_RESET = 5 ,
  C_WAIT_AUTH = 6 , S_INITIAL = 7 , S_WAIT_RESET = 8 , S_WAIT_AUTH = 9 ,
  ACTIVE = 10
}
 
enum  iv_proto_flag : unsigned int {
  IV_PROTO_DATA_V2 = (1 << 1) , IV_PROTO_REQUEST_PUSH = (1 << 2) , IV_PROTO_TLS_KEY_EXPORT = (1 << 3) , IV_PROTO_AUTH_PENDING_KW = (1 << 4) ,
  IV_PROTO_NCP_P2P = (1 << 5) , IV_PROTO_DNS_OPTION = (1 << 6) , IV_PROTO_CC_EXIT_NOTIFY = (1 << 7) , IV_PROTO_AUTH_FAIL_TEMP = (1 << 8) ,
  IV_PROTO_DYN_TLS_CRYPT = (1 << 9) , IV_PROTO_DATA_EPOCH = (1 << 10) , IV_PROTO_DNS_OPTION_V2 = (1 << 11) , IV_PROTO_PUSH_UPDATE = (1 << 12)
}
 
enum  tlv_types : uint16_t { EARLY_NEG_FLAGS = 0x0001 }
 
enum  early_neg_flags : uint16_t { EARLY_NEG_FLAG_RESEND_WKC = 0x0001 }
 

Protected Member Functions

int primary_state () const
 

Static Protected Member Functions

static unsigned int opcode_extract (const unsigned int op)
 
static unsigned int key_id_extract (const unsigned int op)
 
static size_t op_head_size (const unsigned int op)
 
static unsigned char op_compose (const unsigned int opcode, const unsigned int key_id)
 
static unsigned int op32_compose (const unsigned int opcode, const unsigned int key_id, const int op_peer_id)
 

Static Protected Attributes

static constexpr size_t APP_MSG_MAX = 65536
 
static constexpr size_t OPCODE_SIZE = 1
 
static constexpr PacketIDControl::id_t EARLY_NEG_START = 0x0f000000
 
static constexpr PacketIDControl::id_t EARLY_NEG_MASK = 0xff000000
 
- Static Protected Attributes inherited from openvpn::logging::LoggingMixin< OPENVPN_DEBUG_PROTO, logging::LOG_LEVEL_VERB, ProtoContext >
static logging::Logger< DEFAULT_LOG_LEVEL, MAX_LEVEL > log_
 

Private Types

enum  TLSWrapMode { TLS_PLAIN , TLS_AUTH , TLS_CRYPT , TLS_CRYPT_V2 }
 

Private Member Functions

void reset_all ()
 
void client_auth (Buffer &buf)
 
void update_last_received ()
 
void net_send (const unsigned int key_id, const Packet &net_pkt)
 
void app_recv (const unsigned int key_id, BufferPtr &&to_app_buf)
 
bool renegotiate_request (Packet &pkt)
 
KeyContextselect_key_context (const PacketType &type, const bool control)
 
KeyContextselect_control_send_context ()
 
void keepalive_housekeeping ()
 
bool process_events ()
 
void new_secondary_key (const bool initiator)
 
void promote_secondary_to_primary ()
 
void process_primary_event ()
 
void process_secondary_event ()
 
std::string debug_prefix ()
 
unsigned int next_key_id ()
 
void keepalive_parms_modified ()
 

Static Private Member Functions

static TLSWrapSelection select_tls_wrap (const ProtoConfig &c)
 

Private Attributes

ProtoContextCallbackInterfaceproto_callback
 
ProtoConfig::Ptr config
 
SessionStats::Ptr stats
 
size_t hmac_size
 
TLSWrapMode tls_wrap_mode
 
Mode mode_
 
unsigned int upcoming_key_id = 0
 
unsigned int n_key_ids
 
TimePtr now_
 
Time keepalive_xmit
 
Time keepalive_expire
 
Time::Duration slowest_handshake_
 
OvpnHMACInstance::Ptr ta_hmac_send
 
OvpnHMACInstance::Ptr ta_hmac_recv
 
TLSCryptInstance::Ptr tls_crypt_send
 
TLSCryptInstance::Ptr tls_crypt_recv
 
TLSCryptInstance::Ptr tls_crypt_server
 
OpenVPNStaticKey tls_crypt_client_key
 Kc, the tls-crypt-v2 client key this session's control channel is keyed with.
 
bool dynamic_tls_crypt_keyed = false
 Whether set_dynamic_tls_crypt() has keyed this session already.
 
PacketIDControlSend ta_pid_send
 
PacketIDControlReceive ta_pid_recv
 
ProtoSessionID psid_self
 
ProtoSessionID psid_peer
 
KeyContext::Ptr primary
 
KeyContext::Ptr secondary
 
bool dc_deferred = false
 

Detailed Description

Definition at line 205 of file proto.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
KEY_ID_MASK 
OPCODE_SHIFT 
CONTROL_SOFT_RESET_V1 
CONTROL_V1 
CONTROL_WKC_V1 
CONTROL_OOB_V1 
CONTROL_OOB_WKC_V1 
ACK_V1 
DATA_V1 
DATA_V2 
CONTROL_HARD_RESET_CLIENT_V2 
CONTROL_HARD_RESET_CLIENT_V3 
CONTROL_HARD_RESET_SERVER_V2 
INVALID_OPCODE 
OP_SIZE_V2 
OP_PEER_ID_UNDEF 
STATE_UNDEF 
C_WAIT_RESET_ACK 
C_WAIT_AUTH_ACK 
S_WAIT_RESET_ACK 
S_WAIT_AUTH_ACK 
LAST_ACK_STATE 
C_INITIAL 
C_WAIT_RESET 
C_WAIT_AUTH 
S_INITIAL 
S_WAIT_RESET 
S_WAIT_AUTH 
ACTIVE 

Definition at line 218 of file proto.hpp.

◆ early_neg_flags

enum openvpn::ProtoContext::early_neg_flags : uint16_t
protected
Enumerator
EARLY_NEG_FLAG_RESEND_WKC 

Definition at line 299 of file proto.hpp.

◆ iv_proto_flag

enum openvpn::ProtoContext::iv_proto_flag : unsigned int
protected
Enumerator
IV_PROTO_DATA_V2 
IV_PROTO_REQUEST_PUSH 
IV_PROTO_TLS_KEY_EXPORT 
IV_PROTO_AUTH_PENDING_KW 
IV_PROTO_NCP_P2P 
IV_PROTO_DNS_OPTION 
IV_PROTO_CC_EXIT_NOTIFY 
IV_PROTO_AUTH_FAIL_TEMP 
IV_PROTO_DYN_TLS_CRYPT 
IV_PROTO_DATA_EPOCH 
IV_PROTO_DNS_OPTION_V2 
IV_PROTO_PUSH_UPDATE 

Definition at line 273 of file proto.hpp.

◆ TLSWrapMode

Enumerator
TLS_PLAIN 
TLS_AUTH 
TLS_CRYPT 
TLS_CRYPT_V2 

Definition at line 1955 of file proto.hpp.

◆ tlv_types

enum openvpn::ProtoContext::tlv_types : uint16_t
protected
Enumerator
EARLY_NEG_FLAGS 

Definition at line 294 of file proto.hpp.

◆ UnwrapStatus

Enumerator
OK 
DROP 
HMAC_ERROR 
DECRYPT_ERROR 

Definition at line 1817 of file proto.hpp.

Constructor & Destructor Documentation

◆ ProtoContext()

openvpn::ProtoContext::ProtoContext ( ProtoContextCallbackInterface cb_arg,
const ProtoConfig::Ptr config_arg,
const SessionStats::Ptr stats_arg 
)
inline

Definition at line 4620 of file proto.hpp.

◆ ~ProtoContext()

virtual openvpn::ProtoContext::~ProtoContext ( )
virtualdefault

Member Function Documentation

◆ align_adjust_hint()

size_t openvpn::ProtoContext::align_adjust_hint ( ) const
inline

Definition at line 5115 of file proto.hpp.

Here is the caller graph for this function:

◆ app_recv()

void openvpn::ProtoContext::app_recv ( const unsigned int  key_id,
BufferPtr &&  to_app_buf 
)
inlineprivate

Definition at line 5277 of file proto.hpp.

Here is the caller graph for this function:

◆ build_tls_auth()

static void openvpn::ProtoContext::build_tls_auth ( const ProtoConfig c,
OvpnHMACInstance::Ptr send,
OvpnHMACInstance::Ptr recv 
)
inlinestatic

tls-auth: build the send + recv HMAC instances. Direction follows the configured key-direction (not the client/server role), as in reset().

Definition at line 1908 of file proto.hpp.

Here is the caller graph for this function:

◆ build_tls_crypt()

static void openvpn::ProtoContext::build_tls_crypt ( const ProtoConfig c,
const bool  server,
const OpenVPNStaticKey key,
TLSCryptInstance::Ptr send,
TLSCryptInstance::Ptr recv 
)
inlinestatic

tls-crypt / tls-crypt-v2: build the send + recv instances from key. The encrypt/decrypt slices are selected by the caller's role (server).

Definition at line 1933 of file proto.hpp.

Here is the caller graph for this function:

◆ client_auth()

void openvpn::ProtoContext::client_auth ( Buffer buf)
inlineprivate

Definition at line 5262 of file proto.hpp.

Here is the caller graph for this function:

◆ conf() [1/2]

ProtoConfig & openvpn::ProtoContext::conf ( )
inline

Definition at line 5222 of file proto.hpp.

◆ conf() [2/2]

const ProtoConfig & openvpn::ProtoContext::conf ( ) const
inline

Definition at line 5218 of file proto.hpp.

Here is the caller graph for this function:

◆ conf_ptr()

ProtoConfig::Ptr openvpn::ProtoContext::conf_ptr ( ) const
inline

Definition at line 5226 of file proto.hpp.

Here is the caller graph for this function:

◆ control_net_recv() [1/2]

bool openvpn::ProtoContext::control_net_recv ( const PacketType type,
BufferAllocated &&  net_buf 
)
inline

pass received control channel network packets (ciphertext) into protocol object

Parameters
typePacket type discriminator
net_bufBuffer containing the network packet
Returns
true if successfully processed, false if not
Note
Implemented in terms of control_net_recv(const PacketType &type, BufferPtr &&net_bp)

Definition at line 4982 of file proto.hpp.

◆ control_net_recv() [2/2]

bool openvpn::ProtoContext::control_net_recv ( const PacketType type,
BufferPtr &&  net_bp 
)
inline

Definition at line 4967 of file proto.hpp.

Here is the caller graph for this function:

◆ control_net_validate()

bool openvpn::ProtoContext::control_net_validate ( const PacketType type,
const Buffer net_buf 
)
inline

Definition at line 4961 of file proto.hpp.

Here is the caller graph for this function:

◆ control_send() [1/2]

void openvpn::ProtoContext::control_send ( BufferAllocated &&  app_buf)
inline

Definition at line 4955 of file proto.hpp.

◆ control_send() [2/2]

void openvpn::ProtoContext::control_send ( BufferPtr &&  app_bp)
inline

Definition at line 4950 of file proto.hpp.

Here is the caller graph for this function:

◆ data_channel_ready()

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

Definition at line 5061 of file proto.hpp.

◆ data_decrypt()

bool openvpn::ProtoContext::data_decrypt ( const PacketType type,
BufferAllocated in_out 
)
inline

Definition at line 4998 of file proto.hpp.

Here is the caller graph for this function:

◆ data_encrypt()

void openvpn::ProtoContext::data_encrypt ( BufferAllocated in_out)
inline

Definition at line 4988 of file proto.hpp.

Here is the caller graph for this function:

◆ data_limit_notify()

void openvpn::ProtoContext::data_limit_notify ( const unsigned int  key_id,
const DataLimit::Mode  cdl_mode,
const DataLimit::State  cdl_status 
)
inline

Definition at line 5145 of file proto.hpp.

Here is the caller graph for this function:

◆ dc_settings()

CryptoDCSettings & openvpn::ProtoContext::dc_settings ( )
inline

Definition at line 5156 of file proto.hpp.

Here is the caller graph for this function:

◆ debug_prefix()

std::string openvpn::ProtoContext::debug_prefix ( )
inlineprivate

Definition at line 5488 of file proto.hpp.

Here is the caller graph for this function:

◆ disable_keepalive()

void openvpn::ProtoContext::disable_keepalive ( unsigned int &  keepalive_ping,
unsigned int &  keepalive_timeout 
)
inline

Definition at line 5129 of file proto.hpp.

Here is the caller graph for this function:

◆ disconnect()

void openvpn::ProtoContext::disconnect ( const Error::Type  reason)
inline

Definition at line 5023 of file proto.hpp.

Here is the caller graph for this function:

◆ dump_packet()

std::string openvpn::ProtoContext::dump_packet ( const Buffer buf)
inline

Definition at line 1457 of file proto.hpp.

Here is the caller graph for this function:

◆ flush()

void openvpn::ProtoContext::flush ( const bool  control_channel)
inline

Definition at line 4894 of file proto.hpp.

Here is the caller graph for this function:

◆ frame()

const Frame & openvpn::ProtoContext::frame ( ) const
inline

Definition at line 5184 of file proto.hpp.

Here is the caller graph for this function:

◆ frameptr()

const Frame::Ptr & openvpn::ProtoContext::frameptr ( ) const
inline

Definition at line 5188 of file proto.hpp.

◆ get_tls_warnings()

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

Definition at line 4640 of file proto.hpp.

Here is the caller graph for this function:

◆ housekeeping()

void openvpn::ProtoContext::housekeeping ( )
inline

Definition at line 4912 of file proto.hpp.

Here is the caller graph for this function:

◆ init_data_channel()

void openvpn::ProtoContext::init_data_channel ( )
inline

Definition at line 5093 of file proto.hpp.

Here is the caller graph for this function:

◆ invalidated()

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

Definition at line 5079 of file proto.hpp.

Here is the caller graph for this function:

◆ invalidation_reason()

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

Definition at line 5085 of file proto.hpp.

Here is the caller graph for this function:

◆ is_client()

bool openvpn::ProtoContext::is_client ( ) const
inline

Definition at line 5202 of file proto.hpp.

Here is the caller graph for this function:

◆ is_keepalive_enabled()

bool openvpn::ProtoContext::is_keepalive_enabled ( ) const
inline

Definition at line 5121 of file proto.hpp.

Here is the caller graph for this function:

◆ is_server()

bool openvpn::ProtoContext::is_server ( ) const
inline

Definition at line 5198 of file proto.hpp.

Here is the caller graph for this function:

◆ is_state_client_wait_reset_ack()

bool openvpn::ProtoContext::is_state_client_wait_reset_ack ( ) const
inline

Definition at line 5238 of file proto.hpp.

◆ is_tcp()

bool openvpn::ProtoContext::is_tcp ( )
inline

Definition at line 5208 of file proto.hpp.

Here is the caller graph for this function:

◆ is_udp()

bool openvpn::ProtoContext::is_udp ( )
inline

Definition at line 5212 of file proto.hpp.

Here is the caller graph for this function:

◆ keepalive_housekeeping()

void openvpn::ProtoContext::keepalive_housekeeping ( )
inlineprivate

Definition at line 5340 of file proto.hpp.

Here is the caller graph for this function:

◆ keepalive_parms_modified()

void openvpn::ProtoContext::keepalive_parms_modified ( )
inlineprivate

Definition at line 5516 of file proto.hpp.

Here is the caller graph for this function:

◆ key_id_extract()

static unsigned int openvpn::ProtoContext::key_id_extract ( const unsigned int  op)
inlinestaticprotected

Definition at line 316 of file proto.hpp.

Here is the caller graph for this function:

◆ mode()

const Mode & openvpn::ProtoContext::mode ( ) const
inline

Definition at line 5194 of file proto.hpp.

Here is the caller graph for this function:

◆ negotiations()

unsigned int openvpn::ProtoContext::negotiations ( ) const
inline

Definition at line 5067 of file proto.hpp.

Here is the caller graph for this function:

◆ net_send()

void openvpn::ProtoContext::net_send ( const unsigned int  key_id,
const Packet net_pkt 
)
inlineprivate

Definition at line 5272 of file proto.hpp.

Here is the caller graph for this function:

◆ new_secondary_key()

void openvpn::ProtoContext::new_secondary_key ( const bool  initiator)
inlineprivate

Definition at line 5385 of file proto.hpp.

Here is the caller graph for this function:

◆ next_housekeeping()

Time openvpn::ProtoContext::next_housekeeping ( ) const
inline

Definition at line 4932 of file proto.hpp.

Here is the caller graph for this function:

◆ next_key_id()

unsigned int openvpn::ProtoContext::next_key_id ( )
inlineprivate

Definition at line 5505 of file proto.hpp.

Here is the caller graph for this function:

◆ now()

const Time & openvpn::ProtoContext::now ( ) const
inline

Definition at line 5174 of file proto.hpp.

Here is the caller graph for this function:

◆ op32_compose()

static unsigned int openvpn::ProtoContext::op32_compose ( const unsigned int  opcode,
const unsigned int  key_id,
const int  op_peer_id 
)
inlinestaticprotected

Definition at line 333 of file proto.hpp.

Here is the caller graph for this function:

◆ op_compose()

static unsigned char openvpn::ProtoContext::op_compose ( const unsigned int  opcode,
const unsigned int  key_id 
)
inlinestaticprotected

Definition at line 326 of file proto.hpp.

Here is the caller graph for this function:

◆ op_head_size()

static size_t openvpn::ProtoContext::op_head_size ( const unsigned int  op)
inlinestaticprotected

Definition at line 321 of file proto.hpp.

Here is the caller graph for this function:

◆ opcode_carries_wkc()

static bool openvpn::ProtoContext::opcode_carries_wkc ( const unsigned int  opcode)
inlinestatic

Does a packet with this opcode carry a WKc?

On a server such a packet is what keys the session, so it cannot be validated with a key yet.

Definition at line 1724 of file proto.hpp.

Here is the caller graph for this function:

◆ opcode_extract()

static unsigned int openvpn::ProtoContext::opcode_extract ( const unsigned int  op)
inlinestaticprotected

Definition at line 311 of file proto.hpp.

Here is the caller graph for this function:

◆ opcode_name()

static const char * openvpn::ProtoContext::opcode_name ( const unsigned int  opcode)
inlinestatic

Definition at line 1431 of file proto.hpp.

Here is the caller graph for this function:

◆ OPENVPN_SIMPLE_EXCEPTION()

openvpn::ProtoContext::OPENVPN_SIMPLE_EXCEPTION ( select_key_context_error  )

◆ OPENVPN_UNTAGGED_EXCEPTION_INHERIT() [1/3]

openvpn::ProtoContext::OPENVPN_UNTAGGED_EXCEPTION_INHERIT ( option_error  ,
process_server_push_error   
)

◆ OPENVPN_UNTAGGED_EXCEPTION_INHERIT() [2/3]

openvpn::ProtoContext::OPENVPN_UNTAGGED_EXCEPTION_INHERIT ( option_error  ,
proto_error   
)

◆ OPENVPN_UNTAGGED_EXCEPTION_INHERIT() [3/3]

openvpn::ProtoContext::OPENVPN_UNTAGGED_EXCEPTION_INHERIT ( option_error  ,
proto_option_error   
)

◆ packet_type()

PacketType openvpn::ProtoContext::packet_type ( const Buffer buf)
inline

Definition at line 4844 of file proto.hpp.

Here is the caller graph for this function:

◆ pre_destroy()

void openvpn::ProtoContext::pre_destroy ( )
inline

Definition at line 4830 of file proto.hpp.

Here is the caller graph for this function:

◆ primary_defined()

bool openvpn::ProtoContext::primary_defined ( )
inline

Definition at line 4836 of file proto.hpp.

Here is the caller graph for this function:

◆ primary_state()

int openvpn::ProtoContext::primary_state ( ) const
inlineprotected

Definition at line 5244 of file proto.hpp.

Here is the caller graph for this function:

◆ process_events()

bool openvpn::ProtoContext::process_events ( )
inlineprivate

Definition at line 5360 of file proto.hpp.

Here is the caller graph for this function:

◆ process_primary_event()

void openvpn::ProtoContext::process_primary_event ( )
inlineprivate

Definition at line 5407 of file proto.hpp.

Here is the caller graph for this function:

◆ process_push()

void openvpn::ProtoContext::process_push ( const OptionList opt,
const ProtoContextCompressionOptions pco 
)
inline

Definition at line 5105 of file proto.hpp.

Here is the caller graph for this function:

◆ process_secondary_event()

void openvpn::ProtoContext::process_secondary_event ( )
inlineprivate

Definition at line 5446 of file proto.hpp.

Here is the caller graph for this function:

◆ promote_secondary_to_primary()

void openvpn::ProtoContext::promote_secondary_to_primary ( )
inlineprivate

Definition at line 5397 of file proto.hpp.

Here is the caller graph for this function:

◆ read_auth_string()

template<typename S >
static S openvpn::ProtoContext::read_auth_string ( Buffer buf)
inlinestatic

Definition at line 1586 of file proto.hpp.

◆ read_control_string()

template<typename S >
static S openvpn::ProtoContext::read_control_string ( const Buffer buf)
inlinestatic

Definition at line 1612 of file proto.hpp.

◆ read_uint16_length()

static uint16_t openvpn::ProtoContext::read_uint16_length ( Buffer buf)
inlinestatic

Definition at line 1560 of file proto.hpp.

Here is the caller graph for this function:

◆ renegotiate()

void openvpn::ProtoContext::renegotiate ( )
inline

Definition at line 4877 of file proto.hpp.

Here is the caller graph for this function:

◆ renegotiate_request()

bool openvpn::ProtoContext::renegotiate_request ( Packet pkt)
inlineprivate

Definition at line 5283 of file proto.hpp.

Here is the caller graph for this function:

◆ reset()

void openvpn::ProtoContext::reset ( const ProtoSessionID  cookie_psid = ProtoSessionID())
inline

Resets ProtoContext *this to it's initial state.

Parameters
cookie_psidthe ProtoSessionID parameter that allows a server implementation using the psid cookie mechanism to pass in the verified hmac server session cookie. In the client implementation, the parameter is meaningless and defaults to an empty ProtoSessionID which is created at compile time since the default ProtoSessionID ctor is constexpr. For the default cookie_psid, defined() returns false (vs true for the verified session cookie) so the absence of a parameter selects the correct code path.

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

Initialize tls_auth packet ID for the send case

The second argument sets the expected packet id. If the server implementation is using the psid cookie mechanism, the state creation is deferred until the client's second packet, id 1, is received; otherwise we expect to handle the 1st packet, id 0.

Definition at line 4733 of file proto.hpp.

Here is the caller graph for this function:

◆ reset_all()

void openvpn::ProtoContext::reset_all ( )
inlineprivate

Definition at line 5252 of file proto.hpp.

Here is the caller graph for this function:

◆ reset_dc_factory()

void openvpn::ProtoContext::reset_dc_factory ( )
inline

Definition at line 5162 of file proto.hpp.

Here is the caller graph for this function:

◆ reset_tls_crypt()

void openvpn::ProtoContext::reset_tls_crypt ( const ProtoConfig c,
const OpenVPNStaticKey key 
)
inline

Definition at line 4654 of file proto.hpp.

Here is the caller graph for this function:

◆ reset_tls_crypt_server()

void openvpn::ProtoContext::reset_tls_crypt_server ( const ProtoConfig c)
inline

Definition at line 4709 of file proto.hpp.

Here is the caller graph for this function:

◆ reset_tls_wrap_mode()

void openvpn::ProtoContext::reset_tls_wrap_mode ( const ProtoConfig c)
inline

Definition at line 4633 of file proto.hpp.

Here is the caller graph for this function:

◆ select_control_send_context()

KeyContext & openvpn::ProtoContext::select_control_send_context ( )
inlineprivate

Definition at line 5330 of file proto.hpp.

Here is the caller graph for this function:

◆ select_key_context()

KeyContext & openvpn::ProtoContext::select_key_context ( const PacketType type,
const bool  control 
)
inlineprivate

Definition at line 5299 of file proto.hpp.

Here is the caller graph for this function:

◆ select_tls_wrap()

static TLSWrapSelection openvpn::ProtoContext::select_tls_wrap ( const ProtoConfig c)
inlinestaticprivate

Wrap mode implied by c, preferring tls-auth when it is enabled alongside tls-crypt or tls-crypt-v2.

Definition at line 1972 of file proto.hpp.

Here is the caller graph for this function:

◆ send_explicit_exit_notify()

void openvpn::ProtoContext::send_explicit_exit_notify ( )
inline

Definition at line 5033 of file proto.hpp.

Here is the caller graph for this function:

◆ set_dynamic_tls_crypt()

void openvpn::ProtoContext::set_dynamic_tls_crypt ( const ProtoConfig c,
const KeyContext::Ptr key_ctx 
)
inline

Definition at line 4659 of file proto.hpp.

Here is the caller graph for this function:

◆ set_local_peer_id()

void openvpn::ProtoContext::set_local_peer_id ( const int  local_peer_id)
inline

Definition at line 5168 of file proto.hpp.

Here is the caller graph for this function:

◆ set_protocol()

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

Definition at line 4819 of file proto.hpp.

Here is the caller graph for this function:

◆ slowest_handshake()

const Time::Duration & openvpn::ProtoContext::slowest_handshake ( )
inline

Definition at line 5073 of file proto.hpp.

Here is the caller graph for this function:

◆ start()

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

Initialize the state machine and start protocol negotiation.

Called by both derived client and server protocol classes, this function hands off to the implementation in KeyContext::start()

Parameters
cookie_psidsee ProtoContext::reset()

Definition at line 4857 of file proto.hpp.

Here is the caller graph for this function:

◆ stat()

SessionStats & openvpn::ProtoContext::stat ( ) const
inline

Definition at line 5232 of file proto.hpp.

Here is the caller graph for this function:

◆ unwrap_tls_auth()

static UnwrapStatus openvpn::ProtoContext::unwrap_tls_auth ( Buffer recv,
const size_t  hmac_size,
OvpnHMACInstance ta_hmac_recv,
const PacketIDControlReceive pid_recv,
ProtoSessionID src_psid,
PacketIDControl pid 
)
inlinestatic

tls-auth: verify the HMAC, extract the source PSID and packet id, and leave recv positioned at the (authenticated) payload. Counterpart of wrap_tls_auth(); usable without a session (e.g. an OOB probe reply).

Definition at line 1830 of file proto.hpp.

Here is the caller graph for this function:

◆ unwrap_tls_crypt()

static UnwrapStatus openvpn::ProtoContext::unwrap_tls_crypt ( BufferAllocated recv,
BufferAllocated work,
Frame frame,
const size_t  hmac_size,
TLSCryptInstance tls_crypt_recv,
const PacketIDControlReceive pid_recv,
ProtoSessionID src_psid,
PacketIDControl pid 
)
inlinestatic

tls-crypt / tls-crypt-v2: extract source PSID + packet id, decrypt the payload into work, verify the HMAC, and swap the plaintext into recv. Counterpart of wrap_tls_crypt(); usable without a session.

Definition at line 1859 of file proto.hpp.

Here is the caller graph for this function:

◆ update_last_received()

void openvpn::ProtoContext::update_last_received ( )
inlineprivate

Definition at line 5267 of file proto.hpp.

Here is the caller graph for this function:

◆ update_last_sent()

void openvpn::ProtoContext::update_last_sent ( )
inline

Definition at line 5054 of file proto.hpp.

Here is the caller graph for this function:

◆ update_now()

void openvpn::ProtoContext::update_now ( )
inline

Definition at line 5178 of file proto.hpp.

Here is the caller graph for this function:

◆ uses_bs64_cipher()

bool openvpn::ProtoContext::uses_bs64_cipher ( ) const
inline

Definition at line 4649 of file proto.hpp.

Here is the caller graph for this function:

◆ wrap_tls_auth()

static void openvpn::ProtoContext::wrap_tls_auth ( const unsigned int  opcode,
Buffer buf,
PacketIDControlSend pid_send,
const PacketIDControl::time_t  now_secs,
const size_t  hmac_size,
const ProtoSessionID psid_self,
const unsigned int  key_id,
OvpnHMACInstance ta_hmac_send 
)
inlinestatic

tls-auth: [op][psid][hmac][pid][payload]

Definition at line 1730 of file proto.hpp.

Here is the caller graph for this function:

◆ wrap_tls_crypt()

static void openvpn::ProtoContext::wrap_tls_crypt ( const unsigned int  opcode,
BufferAllocated buf,
BufferAllocated work,
Frame frame,
PacketIDControlSend pid_send,
const PacketIDControl::time_t  now_secs,
const size_t  hmac_size,
const ProtoSessionID psid_self,
const unsigned int  key_id,
TLSCryptInstance tls_crypt_send,
const Buffer wkc 
)
inlinestatic

tls-crypt / tls-crypt-v2: [op][psid][pid][hmac][encrypted payload](+WKc). The plaintext payload is in buf; work is scratch. Pass wkc (the wrapped client key) non-null for tls-crypt-v2 so it is appended on the WKc-bearing opcodes; pass nullptr otherwise.

Definition at line 1756 of file proto.hpp.

Here is the caller graph for this function:

◆ wrap_tls_plain()

static void openvpn::ProtoContext::wrap_tls_plain ( const unsigned int  opcode,
Buffer buf,
const ProtoSessionID psid_self,
const unsigned int  key_id 
)
inlinestatic

plaintext control channel: [op][psid][payload]

Definition at line 1805 of file proto.hpp.

Here is the caller graph for this function:

◆ write_auth_string()

template<typename S >
static void openvpn::ProtoContext::write_auth_string ( const S &  str,
Buffer buf 
)
inlinestatic

Definition at line 1572 of file proto.hpp.

Here is the caller graph for this function:

◆ write_control_string() [1/2]

template<typename S >
void openvpn::ProtoContext::write_control_string ( const S &  str)
inline

Definition at line 1633 of file proto.hpp.

◆ write_control_string() [2/2]

template<typename S >
static void openvpn::ProtoContext::write_control_string ( const S &  str,
Buffer buf 
)
inlinestatic

Definition at line 1599 of file proto.hpp.

Here is the caller graph for this function:

◆ write_empty_string()

static void openvpn::ProtoContext::write_empty_string ( Buffer buf)
inlinestatic

Definition at line 1606 of file proto.hpp.

Here is the caller graph for this function:

◆ write_uint16_length()

static void openvpn::ProtoContext::write_uint16_length ( const size_t  size,
Buffer buf 
)
inlinestatic

Definition at line 1552 of file proto.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ APP_MSG_MAX

constexpr size_t openvpn::ProtoContext::APP_MSG_MAX = 65536
staticconstexprprotected

Definition at line 214 of file proto.hpp.

◆ config

ProtoConfig::Ptr openvpn::ProtoContext::config
private

Definition at line 5537 of file proto.hpp.

◆ dc_deferred

bool openvpn::ProtoContext::dc_deferred = false
private

Definition at line 5588 of file proto.hpp.

◆ dynamic_tls_crypt_keyed

bool openvpn::ProtoContext::dynamic_tls_crypt_keyed = false
private

Whether set_dynamic_tls_crypt() has keyed this session already.

Makes it idempotent: it derives from the wrap mode it then overwrites, so only the first call for a session may derive, and later ones must leave the key installed. Cleared with the contexts in reset().

Definition at line 5578 of file proto.hpp.

◆ EARLY_NEG_MASK

constexpr PacketIDControl::id_t openvpn::ProtoContext::EARLY_NEG_MASK = 0xff000000
staticconstexprprotected

Definition at line 309 of file proto.hpp.

◆ EARLY_NEG_START

constexpr PacketIDControl::id_t openvpn::ProtoContext::EARLY_NEG_START = 0x0f000000
staticconstexprprotected

a peer announces EARLY_NEG_START/CONTROL_WKC_V1 support by numbering its first sent control packet EARLY_NEG_START instead of 0; EARLY_NEG_MASK selects the bits that carry the announcement – see supports_early_negotiation()

Definition at line 308 of file proto.hpp.

◆ hmac_size

size_t openvpn::ProtoContext::hmac_size
private

Definition at line 5540 of file proto.hpp.

◆ keepalive_expire

Time openvpn::ProtoContext::keepalive_expire
private

Definition at line 5548 of file proto.hpp.

◆ keepalive_xmit

Time openvpn::ProtoContext::keepalive_xmit
private

Definition at line 5547 of file proto.hpp.

◆ MAX_CONTROL_WRAP_OVERHEAD

constexpr size_t openvpn::ProtoContext::MAX_CONTROL_WRAP_OVERHEAD
staticconstexpr
Initial value:

Definition at line 352 of file proto.hpp.

◆ mode_

Mode openvpn::ProtoContext::mode_
private

Definition at line 5542 of file proto.hpp.

◆ n_key_ids

unsigned int openvpn::ProtoContext::n_key_ids
private

Definition at line 5544 of file proto.hpp.

◆ now_

TimePtr openvpn::ProtoContext::now_
private

Definition at line 5546 of file proto.hpp.

◆ OPCODE_SIZE

constexpr size_t openvpn::ProtoContext::OPCODE_SIZE = 1
staticconstexprprotected

Definition at line 216 of file proto.hpp.

◆ primary

KeyContext::Ptr openvpn::ProtoContext::primary
private

Definition at line 5586 of file proto.hpp.

◆ proto_callback

ProtoContextCallbackInterface* openvpn::ProtoContext::proto_callback
private

the class that uses this class needs to be called back on a few things. Typically a class that uses this class as field for composition. This parent/callback class needs to ensure that it lives longer than this class, e.g. by having this class as field as this class blindly assumes that this pointer is always valid for its lifetime

Definition at line 5535 of file proto.hpp.

◆ psid_peer

ProtoSessionID openvpn::ProtoContext::psid_peer
private

Definition at line 5584 of file proto.hpp.

◆ psid_self

ProtoSessionID openvpn::ProtoContext::psid_self
private

Definition at line 5583 of file proto.hpp.

◆ secondary

KeyContext::Ptr openvpn::ProtoContext::secondary
private

Definition at line 5587 of file proto.hpp.

◆ slowest_handshake_

Time::Duration openvpn::ProtoContext::slowest_handshake_
private

Definition at line 5550 of file proto.hpp.

◆ stats

SessionStats::Ptr openvpn::ProtoContext::stats
private

Definition at line 5538 of file proto.hpp.

◆ ta_hmac_recv

OvpnHMACInstance::Ptr openvpn::ProtoContext::ta_hmac_recv
private

Definition at line 5553 of file proto.hpp.

◆ ta_hmac_send

OvpnHMACInstance::Ptr openvpn::ProtoContext::ta_hmac_send
private

Definition at line 5552 of file proto.hpp.

◆ ta_pid_recv

PacketIDControlReceive openvpn::ProtoContext::ta_pid_recv
private

Definition at line 5581 of file proto.hpp.

◆ ta_pid_send

PacketIDControlSend openvpn::ProtoContext::ta_pid_send
private

Definition at line 5580 of file proto.hpp.

◆ tls_crypt_client_key

OpenVPNStaticKey openvpn::ProtoContext::tls_crypt_client_key
private

Kc, the tls-crypt-v2 client key this session's control channel is keyed with.

Per session: a server has one per client, unwrapped from that client's WKc, where ProtoConfig::tls_crypt_key holds the server key every WKc is wrapped with – or, with tls_crypt_v2_serverkey_id, nothing at all. A client has only its own. The contexts above do the encrypting; this is kept because set_dynamic_tls_crypt() has to mix the same key in at both ends.

Definition at line 5569 of file proto.hpp.

◆ tls_crypt_recv

TLSCryptInstance::Ptr openvpn::ProtoContext::tls_crypt_recv
private

Definition at line 5556 of file proto.hpp.

◆ tls_crypt_send

TLSCryptInstance::Ptr openvpn::ProtoContext::tls_crypt_send
private

Definition at line 5555 of file proto.hpp.

◆ tls_crypt_server

TLSCryptInstance::Ptr openvpn::ProtoContext::tls_crypt_server
private

Definition at line 5558 of file proto.hpp.

◆ tls_wrap_mode

TLSWrapMode openvpn::ProtoContext::tls_wrap_mode
private

Definition at line 5541 of file proto.hpp.

◆ upcoming_key_id

unsigned int openvpn::ProtoContext::upcoming_key_id = 0
private

Definition at line 5543 of file proto.hpp.


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