OpenVPN 3 Core Library
Loading...
Searching...
No Matches
test_proto.cpp File Reference

Unit test for OpenVPN Protocol implementation (class ProtoContext) More...

#include "test_common.hpp"
#include <iostream>
#include <string>
#include <sstream>
#include <deque>
#include <algorithm>
#include <cstring>
#include <limits>
#include <thread>
#include <gmock/gmock.h>
#include <openvpn/common/platform.hpp>
#include <openvpn/ssl/sslchoose.hpp>
#include <openvpn/client/cliproto.hpp>
#include <openvpn/common/exception.hpp>
#include <openvpn/common/file.hpp>
#include <openvpn/common/count.hpp>
#include <openvpn/time/time.hpp>
#include <openvpn/random/mtrandapi.hpp>
#include <openvpn/frame/frame.hpp>
#include <openvpn/ssl/proto.hpp>
#include <openvpn/init/initprocess.hpp>
#include <openvpn/crypto/cryptodcsel.hpp>
#include <openvpn/crypto/selftest.hpp>
Include dependency graph for test_proto.cpp:

Go to the source code of this file.

Classes

class  DroughtMeasure
 
class  TestProto
 
class  TestProtoClient
 
class  TestProtoServer
 
class  NoisyWire
 
class  MySessionStats
 
class  ProtoUnitTest
 
class  MockCallback
 
class  EventQueueVector
 

Macros

#define OPENVPN_DEBUG
 
#define USE_TLS_CRYPT_V2
 
#define BF   0
 
#define TLS_TIMEOUT_CLIENT   2000
 
#define TLS_TIMEOUT_SERVER   2000
 
#define SIMULATE_OOO
 
#define SIMULATE_DROPPED
 
#define SIMULATE_CORRUPTED
 
#define RENEG   900
 
#define FEEDBACK   1
 
#define ITER   1000000
 
#define SITER   1
 
#define N_RETRIES   2
 
#define STRINGIZE1(x)   #x
 
#define STRINGIZE(x)   STRINGIZE1(x)
 
#define PROTO_CIPHER   "AES-128-CBC"
 
#define TLS_VER_MIN   TLSVersion::Type::UNDEF
 
#define PROTO_DIGEST   "SHA1"
 
#define COMP_METH   CompressContext::LZO_STUB
 

Functions

static auto create_client_ssl_config (Frame::Ptr frame, ClientRandomAPI::Ptr rng, bool tls_version_mismatch=false)
 
static auto create_client_proto_context (ClientSSLAPI::Config::Ptr cc, Frame::Ptr frame, ClientRandomAPI::Ptr rng, MySessionStats::Ptr cli_stats, Time &time, const std::string &tls_crypt_v2_key_fn="")
 
int test (const int thread_num, bool use_tls_ekm, bool tls_version_mismatch, const std::string &tls_crypt_v2_key_fn="", bool use_tls_auth_with_tls_crypt_v2=false)
 
int test_retry (const int thread_num, const int n_retries, bool use_tls_ekm)
 
 TEST_F (ProtoUnitTest, base_single_thread_tls_ekm)
 
 TEST_F (ProtoUnitTest, base_single_thread_no_tls_ekm)
 
 TEST_F (ProtoUnitTest, base_single_thread_tls_crypt_v2_with_embedded_serverkey)
 
 TEST_F (ProtoUnitTest, base_single_thread_tls_crypt_v2_with_missing_embedded_serverkey)
 
 TEST_F (ProtoUnitTest, base_single_thread_tls_crypt_v2_with_tls_auth_also_active)
 
 TEST_F (ProtoUnitTest, base_multiple_thread)
 
 TEST (proto, iv_ciphers_aead)
 
 TEST (proto, iv_ciphers_non_preferred)
 
 TEST (proto, iv_ciphers_legacy)
 
 TEST (proto, controlmessage_invalidchar)
 
 TEST (proto, client_proto_check_cc_msg)
 

Variables

const char message []
 

Detailed Description

Unit test for OpenVPN Protocol implementation (class ProtoContext)

Definition in file test_proto.cpp.

Macro Definition Documentation

◆ BF

#define BF   0

Definition at line 44 of file test_proto.cpp.

◆ COMP_METH

#define COMP_METH   CompressContext::LZO_STUB

Definition at line 162 of file test_proto.cpp.

◆ FEEDBACK

#define FEEDBACK   1

Definition at line 101 of file test_proto.cpp.

◆ ITER

#define ITER   1000000

Definition at line 110 of file test_proto.cpp.

◆ N_RETRIES

#define N_RETRIES   2

Definition at line 122 of file test_proto.cpp.

◆ OPENVPN_DEBUG

#define OPENVPN_DEBUG

Definition at line 34 of file test_proto.cpp.

◆ PROTO_CIPHER

#define PROTO_CIPHER   "AES-128-CBC"

Definition at line 144 of file test_proto.cpp.

◆ PROTO_DIGEST

#define PROTO_DIGEST   "SHA1"

Definition at line 151 of file test_proto.cpp.

◆ RENEG

#define RENEG   900

Definition at line 96 of file test_proto.cpp.

◆ SIMULATE_CORRUPTED

#define SIMULATE_CORRUPTED

Definition at line 89 of file test_proto.cpp.

◆ SIMULATE_DROPPED

#define SIMULATE_DROPPED

Definition at line 88 of file test_proto.cpp.

◆ SIMULATE_OOO

#define SIMULATE_OOO

Definition at line 87 of file test_proto.cpp.

◆ SITER

#define SITER   1

Definition at line 117 of file test_proto.cpp.

◆ STRINGIZE

#define STRINGIZE (   x)    STRINGIZE1(x)

Definition at line 136 of file test_proto.cpp.

◆ STRINGIZE1

#define STRINGIZE1 (   x)    #x

Definition at line 135 of file test_proto.cpp.

◆ TLS_TIMEOUT_CLIENT

#define TLS_TIMEOUT_CLIENT   2000

Definition at line 79 of file test_proto.cpp.

◆ TLS_TIMEOUT_SERVER

#define TLS_TIMEOUT_SERVER   2000

Definition at line 82 of file test_proto.cpp.

◆ TLS_VER_MIN

#define TLS_VER_MIN   TLSVersion::Type::UNDEF

Definition at line 145 of file test_proto.cpp.

◆ USE_TLS_CRYPT_V2

#define USE_TLS_CRYPT_V2

Definition at line 39 of file test_proto.cpp.

Function Documentation

◆ create_client_proto_context()

static auto create_client_proto_context ( ClientSSLAPI::Config::Ptr  cc,
Frame::Ptr  frame,
ClientRandomAPI::Ptr  rng,
MySessionStats::Ptr  cli_stats,
Time time,
const std::string &  tls_crypt_v2_key_fn = "" 
)
static

Definition at line 890 of file test_proto.cpp.

Here is the caller graph for this function:

◆ create_client_ssl_config()

static auto create_client_ssl_config ( Frame::Ptr  frame,
ClientRandomAPI::Ptr  rng,
bool  tls_version_mismatch = false 
)
static

Create a client ssl config for testing.

Returns

Definition at line 862 of file test_proto.cpp.

Here is the caller graph for this function:

◆ test()

int test ( const int  thread_num,
bool  use_tls_ekm,
bool  tls_version_mismatch,
const std::string &  tls_crypt_v2_key_fn = "",
bool  use_tls_auth_with_tls_crypt_v2 = false 
)

Definition at line 974 of file test_proto.cpp.

◆ TEST() [1/5]

TEST ( proto  ,
client_proto_check_cc_msg   
)

Definition at line 1468 of file test_proto.cpp.

◆ TEST() [2/5]

TEST ( proto  ,
controlmessage_invalidchar   
)

Definition at line 1409 of file test_proto.cpp.

◆ TEST() [3/5]

TEST ( proto  ,
iv_ciphers_aead   
)

Definition at line 1325 of file test_proto.cpp.

◆ TEST() [4/5]

TEST ( proto  ,
iv_ciphers_legacy   
)

Definition at line 1363 of file test_proto.cpp.

◆ TEST() [5/5]

TEST ( proto  ,
iv_ciphers_non_preferred   
)

Definition at line 1344 of file test_proto.cpp.

◆ TEST_F() [1/6]

TEST_F ( ProtoUnitTest  ,
base_multiple_thread   
)

Definition at line 1295 of file test_proto.cpp.

◆ TEST_F() [2/6]

TEST_F ( ProtoUnitTest  ,
base_single_thread_no_tls_ekm   
)

Definition at line 1255 of file test_proto.cpp.

◆ TEST_F() [3/6]

TEST_F ( ProtoUnitTest  ,
base_single_thread_tls_crypt_v2_with_embedded_serverkey   
)

Definition at line 1276 of file test_proto.cpp.

◆ TEST_F() [4/6]

TEST_F ( ProtoUnitTest  ,
base_single_thread_tls_crypt_v2_with_missing_embedded_serverkey   
)

Definition at line 1282 of file test_proto.cpp.

◆ TEST_F() [5/6]

TEST_F ( ProtoUnitTest  ,
base_single_thread_tls_crypt_v2_with_tls_auth_also_active   
)

Definition at line 1288 of file test_proto.cpp.

◆ TEST_F() [6/6]

TEST_F ( ProtoUnitTest  ,
base_single_thread_tls_ekm   
)

Definition at line 1243 of file test_proto.cpp.

◆ test_retry()

int test_retry ( const int  thread_num,
const int  n_retries,
bool  use_tls_ekm 
)

Definition at line 1200 of file test_proto.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ message

const char message[]
Initial value:
= "Message _->_ 0000000000 It was a bright cold day in April, and the clocks\n"
"were striking thirteen. Winston Smith, his chin nuzzled\n"
"into his breast in an effort to escape the vile wind,\n"
"slipped quickly through the glass doors of Victory\n"
"Mansions, though not quickly enough to prevent a\n"
"swirl of gritty dust from entering along with him.\n"

Definition at line 255 of file test_proto.cpp.