OpenVPN 3 Core Library
Loading...
Searching...
No Matches
PsidCookieTlsCryptV2Test Class Reference

Tests for the tls-crypt-v2 arm of intercept() More...

Inheritance diagram for PsidCookieTlsCryptV2Test:
[legend]
Collaboration diagram for PsidCookieTlsCryptV2Test:
[legend]

Protected Member Functions

 PsidCookieTlsCryptV2Test ()
 
BufferAllocated make_wkc (const std::string &metadata, int metadata_type=0x00)
 Build the WKc a client appends to its handshake packets.
 
BufferAllocated wrap_wkc (const unsigned char *kc, const std::string &metadata, int metadata_type, size_t kc_size=OpenVPNStaticKey::KEY_SIZE)
 
BufferAllocated build_third_packet_tls_crypt_v2 (const ProtoSessionID &cli_psid, const ProtoSessionID &cookie_psid, const BufferAllocated &wkc, unsigned char op_field)
 Build the tls-crypt-v2 third packet of the 3-way handshake: a CONTROL_WKC_V1 wrapped with Kc, ACKing the server's HARD_RESET and echoing the cookie psid back, with the WKc appended.
 
BufferAllocated wrap_third_packet (const OpenVPNStaticKey &kc, const ProtoSessionID &cli_psid, const ProtoSessionID &cookie_psid, const BufferAllocated &wkc, unsigned char op_field, std::uint32_t own_pktid_be)
 
BufferAllocated build_foreign_third_packet (const ProtoSessionID &cookie_psid, std::uint32_t own_pktid_be=0)
 The handshake packet a client of this server can forge for another's address.
 
BufferAllocated build_first_packet_tls_crypt_v2 (const ProtoSessionID &cli_psid, const BufferAllocated &wkc)
 Build the tls-crypt-v2 first handshake packet: a CONTROL_HARD_RESET_CLIENT_V3 with the WKc behind the tls-crypt frame.
 
- Protected Member Functions inherited from PsidCookieInterceptTest
BufferAllocated build_third_packet_tls_auth (const ProtoSessionID &cli_psid, const ProtoSessionID &cookie_psid, std::uint32_t acked_pktid_be, std::uint32_t own_pktid_be, unsigned char ack_count, unsigned char op_field)
 
Fixture make_fixture ()
 
- Protected Member Functions inherited from PsidCookieTest
 PsidCookieTest ()
 
Time set_clock (Time setting)
 
Time advance_clock (uint64_t binary_ms)
 
void SetUp () override
 
void TearDown () override
 

Static Protected Member Functions

static unsigned char wkc_v1_op_field ()
 the opcode of the third packet, the one whose WKc keys the session behind it
 
static unsigned char control_v1_op_field ()
 the opcode of the packets that follow, which carry no WKc to key a session from
 

Protected Attributes

RCPtr< MetadataRecorderFactorymeta_factory
 
unsigned char client_key_raw_ [OpenVPNStaticKey::KEY_SIZE]
 
OpenVPNStaticKey client_key_
 Kc, as the client keys its tls-crypt instance.
 
OpenVPNStaticKey server_key_
 Ka/Ke, used here to wrap the WKc.
 
- Protected Attributes inherited from PsidCookieTest
ServerProto::Factory::Ptr spf
 the server factory each session's ProtoConfig is cloned from
 
std::unique_ptr< PsidCookieImplpcookie_impl
 

Static Protected Attributes

static constexpr std::uint32_t SERVER_KEY_ID = 0x063FE634
 K_id of test/ssl/06/063FE634.key, the server key the WKc names.
 

Detailed Description

Tests for the tls-crypt-v2 arm of intercept()

The client's third packet (CONTROL_WKC_V1) carries the WKc, and unwrap_tls_crypt_wkc() strips it there, so this is the only place its metadata can be parsed; the handler that parsed the cookie layer judges it before a session exists.

The server this configures holds a tls-auth key as well, which is what PG deploys and the case reset_tls_wrap_mode() resolves to TLS_AUTH.

Definition at line 441 of file test_psid_cookie.cpp.

Constructor & Destructor Documentation

◆ PsidCookieTlsCryptV2Test()

PsidCookieTlsCryptV2Test::PsidCookieTlsCryptV2Test ( )
inlineprotected

Definition at line 444 of file test_psid_cookie.cpp.

Member Function Documentation

◆ build_first_packet_tls_crypt_v2()

BufferAllocated PsidCookieTlsCryptV2Test::build_first_packet_tls_crypt_v2 ( const ProtoSessionID cli_psid,
const BufferAllocated wkc 
)
inlineprotected

Build the tls-crypt-v2 first handshake packet: a CONTROL_HARD_RESET_CLIENT_V3 with the WKc behind the tls-crypt frame.

The cookie layer answers this one without decrypting it, so only the cleartext fields mean anything. What has to be exact is the geometry: on this opcode the unwrap expects the WKc to begin where the frame ends.

Definition at line 668 of file test_psid_cookie.cpp.

◆ build_foreign_third_packet()

BufferAllocated PsidCookieTlsCryptV2Test::build_foreign_third_packet ( const ProtoSessionID cookie_psid,
std::uint32_t  own_pktid_be = 0 
)
inlineprotected

The handshake packet a client of this server can forge for another's address.

The WKc is the attacker's own, so it unwraps under the server key like any other, and the frame is wrapped with the very Kc that WKc carries, so it authenticates under the key the session installs from it. Nothing in it is the victim's.

Definition at line 641 of file test_psid_cookie.cpp.

◆ build_third_packet_tls_crypt_v2()

BufferAllocated PsidCookieTlsCryptV2Test::build_third_packet_tls_crypt_v2 ( const ProtoSessionID cli_psid,
const ProtoSessionID cookie_psid,
const BufferAllocated wkc,
unsigned char  op_field 
)
inlineprotected

Build the tls-crypt-v2 third packet of the 3-way handshake: a CONTROL_WKC_V1 wrapped with Kc, ACKing the server's HARD_RESET and echoing the cookie psid back, with the WKc appended.

Definition at line 573 of file test_psid_cookie.cpp.

◆ control_v1_op_field()

static unsigned char PsidCookieTlsCryptV2Test::control_v1_op_field ( )
inlinestaticprotected

the opcode of the packets that follow, which carry no WKc to key a session from

Definition at line 698 of file test_psid_cookie.cpp.

Here is the caller graph for this function:

◆ make_wkc()

BufferAllocated PsidCookieTlsCryptV2Test::make_wkc ( const std::string &  metadata,
int  metadata_type = 0x00 
)
inlineprotected

Build the WKc a client appends to its handshake packets.

T = HMAC-SHA256(Ka, len || K_id || Kc || metadata)
WKc = T || AES-256-CTR(Ke, IV = T, Kc || metadata) || K_id || len
Parameters
metadataMetadata payload; empty for a WKc carrying none.
metadata_typeType byte prefixed to metadata: 0x00 for user metadata, 0x01 for the timestamp stock tls-crypt-v2-genkey emits.

Definition at line 502 of file test_psid_cookie.cpp.

◆ wkc_v1_op_field()

static unsigned char PsidCookieTlsCryptV2Test::wkc_v1_op_field ( )
inlinestaticprotected

the opcode of the third packet, the one whose WKc keys the session behind it

Definition at line 692 of file test_psid_cookie.cpp.

Here is the caller graph for this function:

◆ wrap_third_packet()

BufferAllocated PsidCookieTlsCryptV2Test::wrap_third_packet ( const OpenVPNStaticKey kc,
const ProtoSessionID cli_psid,
const ProtoSessionID cookie_psid,
const BufferAllocated wkc,
unsigned char  op_field,
std::uint32_t  own_pktid_be 
)
inlineprotected

As build_third_packet_tls_crypt_v2(), but wrapping the frame with kc and numbering the message own_pktid_be rather than 0.

Definition at line 583 of file test_psid_cookie.cpp.

Here is the caller graph for this function:

◆ wrap_wkc()

BufferAllocated PsidCookieTlsCryptV2Test::wrap_wkc ( const unsigned char *  kc,
const std::string &  metadata,
int  metadata_type,
size_t  kc_size = OpenVPNStaticKey::KEY_SIZE 
)
inlineprotected

As make_wkc(), but wrapping kc_size bytes of kc instead of this client's key. A kc_size below KEY_SIZE builds a WKc no client should ever send: correctly tagged, and with less key inside than it takes to key anything.

Definition at line 510 of file test_psid_cookie.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ client_key_

OpenVPNStaticKey PsidCookieTlsCryptV2Test::client_key_
protected

Kc, as the client keys its tls-crypt instance.

Definition at line 708 of file test_psid_cookie.cpp.

◆ client_key_raw_

unsigned char PsidCookieTlsCryptV2Test::client_key_raw_[OpenVPNStaticKey::KEY_SIZE]
protected

Definition at line 707 of file test_psid_cookie.cpp.

◆ meta_factory

RCPtr<MetadataRecorderFactory> PsidCookieTlsCryptV2Test::meta_factory
protected

Definition at line 706 of file test_psid_cookie.cpp.

◆ server_key_

OpenVPNStaticKey PsidCookieTlsCryptV2Test::server_key_
protected

Ka/Ke, used here to wrap the WKc.

Definition at line 709 of file test_psid_cookie.cpp.

◆ SERVER_KEY_ID

constexpr std::uint32_t PsidCookieTlsCryptV2Test::SERVER_KEY_ID = 0x063FE634
staticconstexprprotected

K_id of test/ssl/06/063FE634.key, the server key the WKc names.

Definition at line 704 of file test_psid_cookie.cpp.


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