28#include <gmock/gmock.h>
36#if !defined(USE_TLS_AUTH) && !defined(USE_TLS_CRYPT)
39#define USE_TLS_CRYPT_V2
47#define PROTO_CIPHER "BF-CBC"
48#define TLS_VER_MIN TLSVersion::UNDEF
49#define HANDSHAKE_WINDOW 60
50#define BECOME_PRIMARY_CLIENT 5
51#define BECOME_PRIMARY_SERVER 5
52#define TLS_TIMEOUT_CLIENT 1000
53#define TLS_TIMEOUT_SERVER 1000
56#define PROTO_CIPHER "BF-CBC"
57#define TLS_VER_MIN TLSVersion::UNDEF
58#define HANDSHAKE_WINDOW 10
59#define BECOME_PRIMARY_CLIENT 10
60#define BECOME_PRIMARY_SERVER 10
61#define TLS_TIMEOUT_CLIENT 2000
62#define TLS_TIMEOUT_SERVER 1000
65#define PROTO_CIPHER "BF-CBC"
66#define TLS_VER_MIN TLSVersion::UNDEF
67#define HANDSHAKE_WINDOW 60
68#define BECOME_PRIMARY_CLIENT 60
69#define BECOME_PRIMARY_SERVER 10
70#define TLS_TIMEOUT_CLIENT 2000
71#define TLS_TIMEOUT_SERVER 1000
74#error unknown BF value
78#ifndef TLS_TIMEOUT_CLIENT
79#define TLS_TIMEOUT_CLIENT 2000
81#ifndef TLS_TIMEOUT_SERVER
82#define TLS_TIMEOUT_SERVER 2000
88#define SIMULATE_DROPPED
89#define SIMULATE_CORRUPTED
94#define RENEG PROTO_RENEG
108#define ITER PROTO_ITER
115#define SITER PROTO_SITER
131#if !defined(PROTO_VERBOSE) && !defined(QUIET) && ITER <= 10000
135#define STRINGIZE1(x) #x
136#define STRINGIZE(x) STRINGIZE1(x)
141#define PROTO_CIPHER "AES-256-GCM"
142#define TLS_VER_MIN TLSVersion::Type::V1_2
144#define PROTO_CIPHER "AES-128-CBC"
145#define TLS_VER_MIN TLSVersion::Type::UNDEF
151#define PROTO_DIGEST "SHA1"
157#define COMP_METH CompressContext::LZ4v2
159#define COMP_METH CompressContext::COMP_STUBv2
162#define COMP_METH CompressContext::LZO_STUB
176#ifdef USE_MBEDTLS_APPLE_HYBRID
180#if !(defined(USE_OPENSSL) || defined(USE_MBEDTLS) || defined(USE_APPLE_SSL))
181#error Must define one or more of USE_OPENSSL, USE_MBEDTLS, USE_APPLE_SSL.
184#if defined(USE_OPENSSL) && (defined(USE_MBEDTLS) || defined(USE_APPLE_SSL))
186#define USE_OPENSSL_SERVER
187#elif !defined(USE_OPENSSL) && defined(USE_MBEDTLS)
188#define USE_MBEDTLS_SERVER
189#elif defined(USE_OPENSSL) && !defined(USE_MBEDTLS)
190#define USE_OPENSSL_SERVER
192#error no server setup
195#if defined(USE_OPENSSL) || defined(USE_OPENSSL_SERVER)
201#if defined(USE_APPLE_SSL) || defined(USE_MBEDTLS_APPLE_HYBRID)
207#if defined(USE_MBEDTLS) || defined(USE_MBEDTLS_SERVER)
211#include <mbedtls/debug.h>
219#ifdef USE_MBEDTLS_SERVER
223#elif defined(USE_OPENSSL_SERVER)
228#error No server SSL implementation defined
233#if defined(USE_MBEDTLS_APPLE_HYBRID)
240#elif defined(USE_APPLE_SSL)
244#elif defined(USE_OPENSSL)
249#error No client SSL implementation defined
252const char message[] =
"Message _->_ 0000000000 It was a bright cold day in April, and the clocks\n"
253 "were striking thirteen. Winston Smith, his chin nuzzled\n"
254 "into his breast in an effort to escape the vile wind,\n"
255 "slipped quickly through the glass doors of Victory\n"
256 "Mansions, though not quickly enough to prevent a\n"
257 "swirl of gritty dust from entering along with him.\n"
259 "It was a bright cold day in April, and the clocks\n"
260 "were striking thirteen. Winston Smith, his chin nuzzled\n"
261 "into his breast in an effort to escape the vile wind,\n"
262 "slipped quickly through the glass doors of Victory\n"
263 "Mansions, though not quickly enough to prevent a\n"
264 "swirl of gritty dust from entering along with him.\n"
265 "It was a bright cold day in April, and the clocks\n"
266 "were striking thirteen. Winston Smith, his chin nuzzled\n"
267 "into his breast in an effort to escape the vile wind,\n"
268 "slipped quickly through the glass doors of Victory\n"
269 "Mansions, though not quickly enough to prevent a\n"
270 "swirl of gritty dust from entering along with him.\n"
271 "It was a bright cold day in April, and the clocks\n"
272 "were striking thirteen. Winston Smith, his chin nuzzled\n"
273 "into his breast in an effort to escape the vile wind,\n"
274 "slipped quickly through the glass doors of Victory\n"
275 "Mansions, though not quickly enough to prevent a\n"
276 "swirl of gritty dust from entering along with him.\n"
277 "It was a bright cold day in April, and the clocks\n"
278 "were striking thirteen. Winston Smith, his chin nuzzled\n"
279 "into his breast in an effort to escape the vile wind,\n"
280 "slipped quickly through the glass doors of Victory\n"
281 "Mansions, though not quickly enough to prevent a\n"
282 "swirl of gritty dust from entering along with him.\n"
307#if defined(VERBOSE) || defined(DROUGHT_LIMIT)
311 std::cout <<
"*** Drought " <<
name <<
" has reached " << r <<
"\n";
314 if (r > DROUGHT_LIMIT)
315 throw drought_limit_exceeded();
373 const size_t msglen = std::strlen(
msg) + 1;
383 const size_t msglen = std::strlen(
msg) + 1;
391 if (
bool(iteration++ & 1) == is_server())
428 bp->write((
unsigned char *)
str, std::strlen(
str));
511 if (
work->size() >= 23)
516 const ssize_t trunc = 64;
517 const std::string show((
char *)
work->data(), trunc);
518 std::cout << now().raw() <<
" " << mode().str() <<
" " << show <<
"\n";
537 char *
msg = (
char *)buf->data();
550 for (
int i = 22; i >= 13; i--)
569 size_t iteration = 0;
589 const std::string username(
"foo");
590 const std::string password(
"bar");
617 const std::string &peer_info,
621 std::cout <<
"**** AUTHENTICATE " << username <<
'/' << password <<
" PEER INFO:\n";
622 std::cout << peer_info;
624 if (username !=
"foo" || password !=
"bar")
637 const unsigned int reorder_prob_arg,
638 const unsigned int drop_prob_arg,
639 const unsigned int corrupt_prob_arg)
651 template <
typename T1,
typename T2>
655 a.check_invalidated();
656 b.check_invalidated();
659 if (a.do_housekeeping())
662 std::cout << now->raw() <<
" " <<
title <<
" Housekeeping\n";
670 if (a.proto_context.data_channel_ready())
672 BufferPtr bp = a.data_encrypt_string(
"Waiting for godot A... Waiting for godot B... Waiting for godot C... Waiting for godot D... Waiting for godot E... Waiting for godot F... Waiting for godot G... Waiting for godot H... Waiting for godot I... Waiting for godot J...");
677 while (!a.net_out.empty())
681 std::cout << now->raw() <<
" " <<
title <<
" " << a.dump_packet(*bp) <<
"\n";
683 a.net_out.pop_front();
697 if (!b.control_net_validate(pt, *bp))
698 std::cout << now->raw() <<
" " <<
title <<
" CONTROL PACKET VALIDATION FAILED\n";
700 b.proto_context.control_net_recv(pt, std::move(bp));
706 b.data_decrypt(pt, *bp);
710 const std::string show((
char *)bp->data(), std::min(bp->size(),
size_t(40)));
711 std::cout << now->raw() <<
" " <<
title <<
" DATA CHANNEL DECRYPT: " << show <<
"\n";
715 catch ([[maybe_unused]]
const std::exception &e)
718 std::cout << now->raw() <<
" " <<
title <<
" Exception on data channel decrypt: " << e.what() <<
"\n";
725 std::cout << now->raw() <<
" " <<
title <<
" KEY_STATE_ERROR\n";
730#ifdef SIMULATE_UDP_AMPLIFY_ATTACK
731 if (b.proto_context.is_state_client_wait_reset_ack())
735 std::cout << now->raw() <<
" " <<
title <<
" SIMULATE_UDP_AMPLIFY_ATTACK disable client xmit\n";
740 b.proto_context.flush(
true);
752 std::cout << now->raw() <<
" " <<
title <<
" Simulating packet reordering " << i <<
" -> 0\n";
764 std::cout << now->raw() <<
" " <<
title <<
" Received packet, size=" << bp->size() <<
"\n";
767#ifdef SIMULATE_DROPPED
772 std::cout << now->raw() <<
" " <<
title <<
" Simulating a dropped packet\n";
778#ifdef SIMULATE_CORRUPTED
783 std::cout << now->raw() <<
" " <<
title <<
" Simulating a corrupted packet\n";
786 const unsigned char value =
random.
randrange(std::numeric_limits<unsigned char>::max());
796 unsigned int rand(
const unsigned int prob)
824 void error(
const size_t err_type,
const std::string *text =
nullptr)
override
857 const std::string client_crt =
read_text(TEST_KEYCERT_DIR
"client.crt");
858 const std::string client_key =
read_text(TEST_KEYCERT_DIR
"client.key");
859 const std::string ca_crt =
read_text(TEST_KEYCERT_DIR
"ca.crt");
862 ClientSSLAPI::Config::Ptr cc(
new ClientSSLAPI::Config());
864 cc->set_frame(frame);
867 cc->load_identity(
"etest");
869 cc->load_ca(ca_crt,
true);
870 cc->load_cert(client_crt);
871 cc->load_private_key(client_key);
873 if (tls_version_mismatch)
874 cc->set_tls_version_max(TLSVersion::Type::V1_2);
878 cc->set_debug_level(1);
886 const std::string tls_auth_key =
read_text(TEST_KEYCERT_DIR
"tls-auth.key");
887 const std::string tls_crypt_v2_client_key = tls_crypt_v2_key_fn.empty()
888 ?
read_text(TEST_KEYCERT_DIR
"tls-crypt-v2-client.key")
889 :
read_text(TEST_KEYCERT_DIR + tls_crypt_v2_key_fn);
893 ClientProtoContext::ProtoConfig::Ptr cp(
new ClientProtoContext::ProtoConfig);
894 cp->ssl_factory = cc->new_factory();
895 CryptoAlgs::allow_default_dc_algs<ClientCryptoAPI>(cp->ssl_factory->libctx(),
false,
false);
898 cp->frame = std::move(frame);
905 cp->enable_op32 =
true;
906 cp->remote_peer_id = 100;
914 cp->tls_auth_key.parse(tls_auth_key);
916 cp->key_direction = 0;
920 cp->tls_crypt_key.parse(tls_auth_key);
921 cp->set_tls_crypt_algs();
922 cp->tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V1;
924#ifdef USE_TLS_CRYPT_V2
926 cp->set_tls_crypt_algs();
929 tls_crypt_v2_key.
parse(tls_crypt_v2_client_key);
933 cp->tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V2;
935#ifdef HANDSHAKE_WINDOW
936 cp->handshake_window = Time::Duration::seconds(HANDSHAKE_WINDOW);
938 cp->handshake_window = Time::Duration::seconds(30);
940 cp->handshake_window = Time::Duration::seconds(18);
942#ifdef BECOME_PRIMARY_CLIENT
943 cp->become_primary = Time::Duration::seconds(BECOME_PRIMARY_CLIENT);
945 cp->become_primary = cp->handshake_window;
948#ifdef CLIENT_NO_RENEG
951 cp->renegotiate = Time::Duration::seconds(
RENEG);
953 cp->expire = cp->renegotiate + cp->renegotiate;
954 cp->keepalive_ping = Time::Duration::seconds(5);
955 cp->keepalive_timeout = Time::Duration::seconds(60);
956 cp->keepalive_timeout_early = cp->keepalive_timeout;
959 std::cout <<
"CLIENT OPTIONS: " << cp->options_string() <<
"\n";
960 std::cout <<
"CLIENT PEER INFO:\n";
961 std::cout << cp->peer_info_string();
969 bool tls_version_mismatch,
970 const std::string &tls_crypt_v2_key_fn =
"",
971 bool use_tls_auth_with_tls_crypt_v2 =
false)
979 ClientRandomAPI::Ptr prng_cli(
new ClientRandomAPI());
980 ServerRandomAPI::Ptr prng_serv(
new ServerRandomAPI());
985 const Time::Duration time_step = Time::Duration::binary_ms(100);
988 const std::string ca_crt =
read_text(TEST_KEYCERT_DIR
"ca.crt");
989 const std::string server_crt =
read_text(TEST_KEYCERT_DIR
"server.crt");
990 const std::string server_key =
read_text(TEST_KEYCERT_DIR
"server.key");
991 const std::string dh_pem =
read_text(TEST_KEYCERT_DIR
"dh.pem");
992 const std::string tls_auth_key =
read_text(TEST_KEYCERT_DIR
"tls-auth.key");
993 const std::string tls_crypt_v2_server_key = tls_crypt_v2_key_fn.empty()
994 ?
read_text(TEST_KEYCERT_DIR
"tls-crypt-v2-server.key")
1003 cp->dc.set_key_derivation(CryptoAlgs::KeyDerivation::TLS_EKM);
1008 ServerSSLAPI::Config::Ptr sc(
new ClientSSLAPI::Config());
1010 sc->set_frame(frame);
1011 sc->set_rng(prng_serv);
1012 sc->load_ca(ca_crt,
true);
1013 sc->load_cert(server_crt);
1014 sc->load_private_key(server_key);
1015 sc->load_dh(dh_pem);
1016 sc->set_tls_version_min(tls_version_mismatch ? TLSVersion::Type::V1_3 :
TLS_VER_MIN);
1018 sc->set_debug_level(1);
1023 ServerProtoContext::ProtoConfig::Ptr sp(
new ServerProtoContext::ProtoConfig);
1024 sp->ssl_factory = sc->new_factory();
1029 sp->rng = prng_serv;
1030 sp->prng = prng_serv;
1034 sp->enable_op32 =
true;
1035 sp->remote_peer_id = 101;
1041 sp->dc.set_key_derivation(CryptoAlgs::KeyDerivation::TLS_EKM);
1044 sp->tls_auth_key.parse(tls_auth_key);
1046 sp->key_direction = 1;
1050 sp->tls_crypt_key.parse(tls_auth_key);
1051 sp->set_tls_crypt_algs();
1052 cp->tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V1;
1054#ifdef USE_TLS_CRYPT_V2
1057 if (tls_crypt_v2_key_fn.empty())
1060 tls_crypt_v2_key.
parse(tls_crypt_v2_server_key);
1064 sp->set_tls_crypt_algs();
1066 sp->tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V2;
1067 sp->tls_crypt_v2_serverkey_id = !tls_crypt_v2_key_fn.empty();
1068 sp->tls_crypt_v2_serverkey_dir = TEST_KEYCERT_DIR;
1070 if (use_tls_auth_with_tls_crypt_v2)
1073 sp->tls_auth_key.parse(tls_auth_key);
1075 sp->key_direction = 1;
1078#ifdef HANDSHAKE_WINDOW
1079 sp->handshake_window = Time::Duration::seconds(HANDSHAKE_WINDOW);
1081 sp->handshake_window = Time::Duration::seconds(30);
1083 sp->handshake_window = Time::Duration::seconds(17) + Time::Duration::binary_ms(512);
1085#ifdef BECOME_PRIMARY_SERVER
1086 sp->become_primary = Time::Duration::seconds(BECOME_PRIMARY_SERVER);
1088 sp->become_primary = sp->handshake_window;
1091#ifdef SERVER_NO_RENEG
1100 sp->renegotiate = Time::Duration::seconds(
RENEG) + sp->handshake_window;
1102 sp->expire = sp->renegotiate + sp->renegotiate;
1103 sp->keepalive_ping = Time::Duration::seconds(5);
1104 sp->keepalive_timeout = Time::Duration::seconds(60);
1105 sp->keepalive_timeout_early = Time::Duration::seconds(10);
1108 std::cout <<
"SERVER OPTIONS: " << sp->options_string() <<
"\n";
1109 std::cout <<
"SERVER PEER INFO:\n";
1110 std::cout << sp->peer_info_string();
1116 for (
int i = 0; i <
SITER; ++i)
1119 std::cout <<
"***** SITER " << i <<
"\n";
1124 NoisyWire client_to_server(
"Client -> Server", &time, rng_noncrypto, 8, 16, 32);
1125 NoisyWire server_to_client(
"Server -> Client", &time, rng_noncrypto, 8, 16, 32);
1140 for (j = 0; j <
ITER; ++j)
1142 client_to_server.
xfer(cli_proto, serv_proto);
1143 server_to_client.
xfer(serv_proto, cli_proto);
1147 catch (
const std::exception &e)
1149 std::cerr <<
"Exception[" << i <<
'/' << j <<
"]: " << e.what() <<
'\n';
1161 std::cerr <<
"*** app bytes=" << ab
1162 <<
" net_bytes=" << nb
1163 <<
" data_bytes=" << db
1175 std::cerr <<
"-------- CLIENT STATS --------\n";
1177 std::cerr <<
"-------- SERVER STATS --------\n";
1180#ifdef OPENVPN_MAX_DATALIMIT_BYTES
1181 std::cerr <<
"------------------------------\n";
1182 std::cerr <<
"MAX_DATALIMIT_BYTES=" << DataLimit::max_bytes() <<
"\n";
1185 catch (
const std::exception &e)
1187 std::cerr <<
"Exception: " << e.what() <<
'\n';
1194 const int n_retries,
1196 bool tls_version_mismatch =
false,
1197 const std::string &tls_crypt_v2_key_fn =
"",
1198 bool use_tls_auth_with_tls_crypt_v2 =
false)
1201 for (
int i = 0; i < n_retries; ++i)
1203 ret =
test(thread_num, use_tls_ekm, tls_version_mismatch, tls_crypt_v2_key_fn, use_tls_auth_with_tls_crypt_v2);
1206 std::cout <<
"Retry " << (i + 1) <<
'/' << n_retries <<
'\n';
1208 std::cout <<
"Failed\n";
1218 mbedtls_debug_set_threshold(1);
1234 mbedtls_debug_set_threshold(4);
1243 if (!openvpn::SSLLib::SSLAPI::support_key_material_export())
1244 GTEST_SKIP_(
"our mbed TLS implementation does not support TLS EKM");
1268 int ret =
test(1,
false,
true);
1273#ifdef USE_TLS_CRYPT_V2
1282 int ret =
test(1,
false,
false,
"tls-crypt-v2-client-with-missing-serverkey.key");
1295 unsigned int num_threads = std::thread::hardware_concurrency();
1296#if defined(PROTO_N_THREADS) && PROTO_N_THREADS >= 1
1297 num_threads = PROTO_N_THREADS;
1300 std::vector<std::thread> running_threads{};
1301 std::vector<int> results(num_threads, -777);
1303 for (
unsigned int i = 0; i < num_threads; ++i)
1305 running_threads.emplace_back([i, &results]()
1308 const bool use_ekm = openvpn::SSLLib::SSLAPI::support_key_material_export() && (i % 2 == 0);
1311 for (
unsigned int i = 0; i < num_threads; ++i)
1313 running_threads[i].join();
1318 const std::vector<int> expected_results(num_threads, 0);
1320 EXPECT_THAT(expected_results, ::testing::ContainerEq(results));
1325 CryptoAlgs::allow_default_dc_algs<SSLLib::CryptoAPI>(
nullptr,
true,
false);
1329 auto infostring = protoConf.peer_info_string(
false);
1331 auto ivciphers = infostring.substr(infostring.find(
"IV_CIPHERS="));
1332 ivciphers = ivciphers.substr(0, ivciphers.find(
"\n"));
1335 std::string expectedstr{
"IV_CIPHERS=AES-128-GCM:AES-192-GCM:AES-256-GCM"};
1337 expectedstr +=
":CHACHA20-POLY1305";
1339 EXPECT_EQ(ivciphers, expectedstr);
1344 CryptoAlgs::allow_default_dc_algs<SSLLib::CryptoAPI>(
nullptr,
false,
false);
1348 auto infostring = protoConf.peer_info_string(
true);
1350 auto ivciphers = infostring.substr(infostring.find(
"IV_CIPHERS="));
1351 ivciphers = ivciphers.substr(0, ivciphers.find(
"\n"));
1354 std::string expectedstr{
"IV_CIPHERS=AES-128-CBC:AES-192-CBC:AES-256-CBC:AES-128-GCM:AES-192-GCM:AES-256-GCM"};
1356 expectedstr +=
":CHACHA20-POLY1305";
1358 EXPECT_EQ(ivciphers, expectedstr);
1365 SSLLib::SSLAPI::Config::Ptr
config =
new SSLLib::SSLAPI::Config;
1373 config->set_local_cert_enabled(
false);
1374 config->enable_legacy_algorithms(
true);
1376 auto factory_client =
config->new_factory();
1377 EXPECT_TRUE(factory_client);
1379 auto client = factory_client->ssl();
1380 auto libctx = factory_client->libctx();
1383 CryptoAlgs::allow_default_dc_algs<SSLLib::CryptoAPI>(libctx,
false,
true);
1387 auto infostring = protoConf.peer_info_string(
false);
1389 auto ivciphers = infostring.substr(infostring.find(
"IV_CIPHERS="));
1390 ivciphers = ivciphers.substr(0, ivciphers.find(
"\n"));
1394 std::string expectedstr{
"IV_CIPHERS=none:AES-128-CBC:AES-192-CBC:AES-256-CBC:DES-CBC:DES-EDE3-CBC"};
1397 expectedstr +=
":BF-CBC";
1399 expectedstr +=
":AES-128-GCM:AES-192-GCM:AES-256-GCM";
1402 expectedstr +=
":CHACHA20-POLY1305";
1404 EXPECT_EQ(ivciphers, expectedstr);
1407TEST(Proto, ControlmessageInvalidchar)
1409 std::string valid_auth_fail{
"AUTH_FAILED: go away"};
1410 std::string valid_auth_fail_newline_end{
"AUTH_FAILED: go away\n"};
1411 std::string invalid_auth_fail{
"AUTH_FAILED: go\n away\n"};
1412 std::string lot_of_whitespace{
"AUTH_FAILED: a lot of white space\n\n\r\n\r\n\r\n"};
1413 std::string only_whitespace{
"\n\n\r\n\r\n\r\n"};
1414 std::string empty{
""};
1423 auto msg = ProtoContext::read_control_string<std::string>(valid_auth_fail_buf);
1424 EXPECT_EQ(
msg, valid_auth_fail);
1427 auto msg2 = ProtoContext::read_control_string<std::string>(valid_auth_fail_newline_end_buf);
1428 EXPECT_EQ(msg2, valid_auth_fail);
1431 auto msg3 = ProtoContext::read_control_string<std::string>(invalid_auth_fail_buf);
1432 EXPECT_EQ(msg3,
"AUTH_FAILED: go\n away");
1435 auto msg4 = ProtoContext::read_control_string<std::string>(lot_of_whitespace_buf);
1436 EXPECT_EQ(msg4,
"AUTH_FAILED: a lot of white space");
1439 auto msg5 = ProtoContext::read_control_string<std::string>(only_whitespace_buf);
1440 EXPECT_EQ(msg5,
"");
1443 auto msg6 = ProtoContext::read_control_string<std::string>(empty_buf);
1444 EXPECT_EQ(msg6,
"");
1463 std::vector<openvpn::ClientEvent::Base::Ptr>
events;
1468 asio::io_context io_context;
1469 ClientRandomAPI::Ptr rng_cli(
new ClientRandomAPI());
1485 std::move(cli_stats),
1487 clisessconf.cli_events = std::move(eqv_ptr);
1490 clisession->validate_and_post_cc_msg(
"valid message");
1493 EXPECT_TRUE(eqv->
events.empty());
1495 clisession->validate_and_post_cc_msg(
"invalid\nmessage");
1496 EXPECT_EQ(eqv->
events.size(), 1);
1497 auto ev = eqv->
events.back();
1501 EXPECT_EQ(uf->name,
"Invalid chars in control message");
1502 EXPECT_EQ(uf->reason,
"Control channel message with invalid characters not allowed to be send with post_cc_msg");
Time::Duration operator()() const
DroughtMeasure(const std::string &name_arg, TimePtr now_arg)
OPENVPN_SIMPLE_EXCEPTION(drought_limit_exceeded)
void add_event(openvpn::ClientEvent::Base::Ptr event) override
std::vector< openvpn::ClientEvent::Base::Ptr > events
void client_proto_terminate()
count_t errors[Error::N_ERRORS]
void error(const size_t err_type, const std::string *text=nullptr) override
count_t get_error_count(const Error::Type type) const
void show_error_counts() const
std::deque< BufferPtr > wire
unsigned int rand(const unsigned int prob)
unsigned int reorder_prob
NoisyWire(const std::string &title_arg, TimePtr now_arg, RandomAPI &rand_arg, const unsigned int reorder_prob_arg, const unsigned int drop_prob_arg, const unsigned int corrupt_prob_arg)
unsigned int corrupt_prob
TestProtoClient(const ProtoContext::ProtoConfig::Ptr &config, const SessionStats::Ptr &stats)
void client_auth(Buffer &buf) override
void server_auth(const std::string &username, const SafeString &password, const std::string &peer_info, const AuthCert::Ptr &auth_cert) override
TestProtoServer(const ProtoContext::ProtoConfig::Ptr &config, const SessionStats::Ptr &stats)
OPENVPN_SIMPLE_EXCEPTION(auth_failed)
TestProto(const ProtoContext::ProtoConfig::Ptr &config, const SessionStats::Ptr &stats)
void control_recv(BufferPtr &&app_bp) override
DroughtMeasure data_drought
void modmsg(BufferPtr &buf)
void data_decrypt(const ProtoContext::PacketType &type, BufferAllocated &in_out)
void control_send(BufferPtr &&app_bp)
void data_encrypt(BufferAllocated &in_out)
void initial_app_send(const char *msg)
const char * progress() const
void control_send(BufferAllocated &&app_buf)
ProtoContext proto_context
void active(bool primary) override
Called when KeyContext transitions to ACTIVE state.
size_t n_control_recv() const
DroughtMeasure control_drought
BufferPtr data_encrypt_string(const char *str)
size_t n_control_send() const
OPENVPN_EXCEPTION(session_invalidated)
void app_send_templ_init(const char *msg)
void control_net_send(const Buffer &net_buf) override
bool supports_epoch_data() override
size_t data_bytes() const
void copy_progress(Buffer &buf)
std::deque< BufferPtr > net_out
size_t size() const
Returns the size of the buffer in T objects.
T * data()
Get a mutable pointer to the start of the array.
bool empty() const
Returns true if the buffer is empty.
size_t prepare(const unsigned int context, Buffer &buf) const
const Time::Duration & slowest_handshake()
void flush(const bool control_channel)
void control_send(BufferPtr &&app_bp)
void data_encrypt(BufferAllocated &in_out)
static void write_auth_string(const S &str, Buffer &buf)
bool data_decrypt(const PacketType &type, BufferAllocated &in_out)
Error::Type invalidation_reason() const
unsigned int negotiations() const
Time next_housekeeping() const
void reset(const ProtoSessionID cookie_psid=ProtoSessionID())
Resets ProtoContext *this to it's initial state.
void start(const ProtoSessionID cookie_psid=ProtoSessionID())
Initialize the state machine and start protocol negotiation.
const ProtoConfig & conf() const
void swap(RCPtr &rhs) noexcept
swaps the contents of two RCPtr<T>
T * get() const noexcept
Returns the raw pointer to the object T, or nullptr.
Abstract base class for random number generators.
T randrange(const T end)
Return a uniformly distributed random number in the range [0, end)
static Ptr Create(ArgsT &&...args)
Creates a new instance of RcEnable with the given arguments.
@ LF_ALLOW_CLIENT_CERT_NOT_REQUIRED
A string-like type that clears the buffer contents on delete.
void parse(const std::string &key_text)
void extract_wkc(BufferAllocated &wkc_out) const
void extract_key(OpenVPNStaticKey &tls_key)
void extract_key(OpenVPNStaticKey &tls_key)
void parse(const std::string &key_text)
static TimeType infinite()
static constexpr int default_log_level
static void set_log_level(int level)
set the log level for all loggigng
void work(openvpn_io::io_context &io_context, ThreadCommon &tc, MyRunContext &runctx, const unsigned int unit)
constexpr BufferFlags GROW(1U<< 2)
if enabled, buffer will grow (otherwise buffer_full exception will be thrown)
constexpr BufferFlags NO_FLAGS(0U)
no flags set
Type lookup(const std::string &name)
const char * name(const size_t type)
bool is_valid_utf8(const STRING &str, const size_t max_len_flags=0)
std::string read_text(const std::string &filename, const std::uint64_t max_size=0)
RCPtr< BufferAllocatedRc > BufferPtr
ProtoContext::ProtoConfig::Ptr proto_context_config
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'
static const char config[]
#define TLS_TIMEOUT_CLIENT
int test_retry(const int thread_num, const int n_retries, bool use_tls_ekm, bool tls_version_mismatch=false, const std::string &tls_crypt_v2_key_fn="", bool use_tls_auth_with_tls_crypt_v2=false)
#define TLS_TIMEOUT_SERVER
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="")
TEST_F(ProtoUnitTest, BaseSingleThreadTlsEkm)
TEST(Proto, IvCiphersAead)
static auto create_client_ssl_config(Frame::Ptr frame, ClientRandomAPI::Ptr rng, bool tls_version_mismatch=false)