15#ifndef OPENVPN_SSL_PROTO_H
16#define OPENVPN_SSL_PROTO_H
80#ifndef OPENVPN_DEBUG_PROTO
81#define OPENVPN_DEBUG_PROTO 1
115namespace proto_context_private {
118const unsigned char auth_prefix[] = { 0, 0, 0, 0, 2 };
120const unsigned char keepalive_message[] = {
121 0x2a, 0x18, 0x7b, 0xf3, 0x64, 0x1e, 0xb4, 0xcb,
122 0x07, 0xed, 0x2d, 0x0a, 0x98, 0x1f, 0xc7, 0x48
127 KEEPALIVE_FIRST_BYTE = 0x2a
130inline bool is_keepalive(
const Buffer &buf)
132 return buf.
size() >=
sizeof(keepalive_message)
133 && buf[0] == KEEPALIVE_FIRST_BYTE
134 && !std::memcmp(keepalive_message, buf.
c_data(),
sizeof(keepalive_message));
137const unsigned char explicit_exit_notify_message[] = {
138 0x28, 0x7f, 0x34, 0x6b, 0xd4, 0xef, 0x7a, 0x81,
139 0x2d, 0x56, 0xb8, 0xd3, 0xaf, 0xc5, 0x45, 0x9c,
146 EXPLICIT_EXIT_NOTIFY_FIRST_BYTE = 0x28
181 const std::string &peer_info,
192 uint8_t empty[]{0x00, 0x00};
193 buf.
write(&empty, 2);
206 logging::LOG_LEVEL_VERB,
316 static unsigned char op_compose(
const unsigned int opcode,
const unsigned int key_id)
320 return static_cast<unsigned char>((opcode <<
OPCODE_SHIFT) | key_id);
324 const unsigned int key_id,
325 const int op_peer_id)
327 return (
op_compose(opcode, key_id) << 24) | (op_peer_id & 0x00FFFFFF);
473 const int default_key_direction,
493 throw proto_option_error(ERR_INVALID_CONFIG,
"missing dev-type or dev option");
494 const std::string &dev_type = dev->
get(1, 64);
495 if (dev_type.starts_with(
"tun"))
497 else if (dev_type.starts_with(
"tap"))
498 throw proto_option_error(ERR_INVALID_CONFIG,
"TAP mode is not supported");
500 throw proto_option_error(ERR_INVALID_OPTION_VAL,
"bad dev-type");
513 const std::string &cipher_name = o->
get(1, 128);
514 if (cipher_name !=
"none")
526 const std::string &auth_name = o->
get(1, 128);
527 if (auth_name !=
"none")
542 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"tls-auth and tls-crypt are mutually exclusive");
560 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"tls-auth and tls-crypt are mutually exclusive");
562 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"tls-crypt and tls-crypt-v2 are mutually exclusive");
577 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"tls-auth and tls-crypt-v2 are mutually exclusive");
579 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"tls-crypt and tls-crypt-v2 are mutually exclusive");
584 std::string keyfile = o->
get(1, 0);
590 tls_crypt_v2_key.
parse(keyfile);
600 tls_crypt_v2_key.
parse(keyfile);
616 const std::string &dir = o->
get(1, 16);
621 else if (dir ==
"bidirectional" || dir ==
"bi")
624 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"bad key-direction parameter");
628 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"bad key-direction default");
638 const std::string meth_name = o->
get(1, 128);
641 OPENVPN_THROW_ARG1(proto_option_error, ERR_INVALID_OPTION_VAL,
"Unknown compressor: '" << meth_name <<
'\'');
652 if (o->
size() == 2 && o->
ref(1) ==
"no")
723 catch (
const std::exception &e)
725 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed parameter: " << e.what());
740 const auto &
flags = o->
get(2, 1024);
741 const auto &protocols = o->
get(3, 1024);
749 OPENVPN_LOG(
"Warning: custom app control requires base64 encoding to properly work");
753 catch (
const std::exception &e)
755 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed parameter: " << e.what());
763 std::string new_cipher;
769 new_cipher = o->
get(1, 128);
770 if (new_cipher !=
"none")
774 catch (
const std::exception &e)
776 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed cipher '" << new_cipher <<
"': " << e.what());
780 std::string new_digest;
786 new_digest = o->
get(1, 128);
787 if (new_digest !=
"none")
791 catch (
const std::exception &e)
793 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed digest '" << new_digest <<
"': " << e.what());
804 bool status = parse_number_validate<int>(o->
get(1, 16),
814 catch (
const std::exception &e)
816 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed peer-id: " << e.what());
823 std::string key_method;
829 key_method = o->
get(1, 128);
830 if (key_method ==
"tls-ekm")
833 OPENVPN_THROW(process_server_push_error,
"Problem accepting key-derivation method '" << key_method <<
"'");
838 catch (
const std::exception &e)
840 OPENVPN_THROW(process_server_push_error,
"Problem accepting key-derivation method '" << key_method <<
"': " << e.what());
849 for (std::size_t i = 1; i < o->
size(); i++)
851 std::string flag = o->
get(i, 128);
852 if (flag ==
"cc-exit")
856 else if (flag ==
"dyn-tls-crypt")
860 else if (flag ==
"tls-ekm")
865 else if (flag ==
"aead-epoch")
871 OPENVPN_THROW(process_server_push_error,
"unknown flag '" << flag <<
"'");
876 catch (
const std::exception &e)
878 OPENVPN_THROW(process_server_push_error,
"Problem accepting protocol-flags: " << e.what());
884 std::string new_comp;
891 new_comp = o->
get(1, 128);
907 <<
", but client has disabled compression, switching to asymmetric");
917 if (o->
size() == 2 && o->
ref(1) ==
"no")
928 catch (
const std::exception &e)
930 OPENVPN_THROW(process_server_push_error,
"Problem accepting server-pushed compressor '" << new_comp <<
"': " << e.what());
936 os <<
" data channel:";
944 os <<
", aead-epoch";
953 os <<
" control channel: tls-auth enabled\n";
957 os <<
" control channel: tls-crypt v2 enabled\n";
961 os <<
" control channel: tls-crypt enabled\n";
965 os <<
" control channel: dynamic tls-crypt enabled\n";
971 std::ostringstream
os;
972 os <<
"PROTOCOL OPTIONS:\n";
1008 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"missing support for tls-crypt algorithms");
1048 std::ostringstream
out;
1063 out <<
',' << compstr;
1081 out <<
",key-method 2";
1084 out <<
",tls-server";
1086 out <<
",tls-client";
1107 if (!hwaddr.empty())
1117 std::ostringstream
out;
1118 const char *compstr =
nullptr;
1129 if (supports_epoch_data)
1135 if (SSLLib::SSLAPI::support_key_material_export())
1142 out <<
"IV_NCP=2\n";
1143 out <<
"IV_TCPNL=1\n";
1144 out <<
"IV_PROTO=" << iv_proto <<
'\n';
1156 out <<
"IV_CIPHERS=";
1165 out.seekp(-1, std::ios_base::cur);
1177 out <<
"IV_BS64DL=1\n";
1179 out <<
"IV_RELAY=1\n";
1182 const std::string
ret =
out.str();
1210 return (
unsigned int)adj;
1325 const unsigned int op = buf[0];
1346 std::memcpy(&opi, buf.
c_data(),
sizeof(opi));
1347 opi = ntohl(opi) & 0x00FFFFFF;
1405 return "CONTROL_SOFT_RESET_V1";
1407 return "CONTROL_V1";
1415 return "CONTROL_HARD_RESET_CLIENT_V2";
1417 return "CONTROL_HARD_RESET_CLIENT_V3";
1419 return "CONTROL_HARD_RESET_SERVER_V2";
1421 return "CONTROL_WKC_V1";
1428 std::ostringstream
out;
1432 const size_t orig_size = b.
size();
1440 return "BAD_PACKET";
1449 const unsigned int peer_id = (p1 << 16) + (p2 << 8) + p3;
1450 if (peer_id != 0xFFFFFF)
1451 out <<
" PEER_ID=" << peer_id;
1453 out <<
" SIZE=" << b.
size() <<
'/' << orig_size;
1459 out <<
" SRC_PSID=" << src_psid.
str();
1466 out <<
" PID=" << pid.
str();
1470 out <<
" TLS-CRYPT ENCRYPTED PAYLOAD=" << b.
size() <<
" bytes";
1481 out <<
" PID=" << pid.
str();
1486 const bool dest_psid_defined = !ack.empty();
1488 while (!ack.empty())
1490 out <<
" " << ack.front();
1495 if (dest_psid_defined)
1498 out <<
" DEST_PSID=" << dest_psid.
str();
1504 out <<
" SIZE=" << b.
size() <<
'/' << orig_size;
1507#ifdef OPENVPN_DEBUG_PROTO_DUMP
1512 catch (
const std::exception &e)
1514 out <<
" EXCEPTION: " << e.what();
1524 throw proto_error(
"auth_string_overflow");
1525 const std::uint16_t net_size = htons(
static_cast<std::uint16_t
>(size));
1526 buf.
write((
const unsigned char *)&net_size,
sizeof(net_size));
1533 std::uint16_t net_size;
1534 buf.
read((
unsigned char *)&net_size,
sizeof(net_size));
1535 return ntohs(net_size);
1541 template <
typename S>
1544 const size_t len =
str.length();
1548 buf.
write((
const unsigned char *)
str.c_str(), len);
1555 template <
typename S>
1561 const char *data = (
const char *)buf.
read_alloc(len);
1563 return S(data, len - 1);
1568 template <
typename S>
1571 const size_t len =
str.length();
1572 buf.
write((
const unsigned char *)
str.c_str(), len);
1581 template <
typename S>
1584 size_t size = buf.
size();
1589 while (size > 0 && (buf[size - 1] == 0 || buf[size - 1] ==
'\r' || buf[size - 1] ==
'\n'))
1596 return S{
reinterpret_cast<const char *
>(buf.
c_data()), size};
1602 template <
typename S>
1605 const size_t len =
str.length();
1624 :
opcode(opcode_arg),
buf(std::move(buf_arg))
1658 operator bool()
const
1783 return "KEV_ACTIVE";
1785 return "KEV_NEGOTIATE";
1787 return "KEV_BECOME_PRIMARY";
1789 return "KEV_PRIMARY_PENDING";
1791 return "KEV_RENEGOTIATE";
1793 return "KEV_RENEGOTIATE_FORCE";
1795 return "KEV_RENEGOTIATE_QUEUE";
1797 return "KEV_EXPIRE";
1855 if (cookie_psid.defined())
1905 throw proto_error(
"app_send: sent control message is too large");
1962 const unsigned char *op32 = (head_size ==
OP_SIZE_V2) ? buf.
c_data() :
nullptr;
1977 throw proto_option_error(ERR_INVALID_OPTION_CRYPTO,
"Unable to add data limit");
1990 catch (std::exception &)
2102 sizeof(proto_context_private::keepalive_message));
2112 sizeof(proto_context_private::explicit_exit_notify_message));
2128 pkt.
buf->write(data, size);
2191 <<
" " <<
proto.
mode().
str() <<
' ' << dck->key.render());
2215 OPENVPN_LOG(
"mssfix disabled since tun-mtu is non-default ("
2220 auto payload_overhead = size_t(0);
2230 payload_overhead += 1;
2238 payload_overhead += 20 + 20;
2252 : sizeof(struct IPv4Header);
2254 ? sizeof(struct TCPHeader)
2255 : sizeof(struct UDPHeader);
2258 auto target = c.mss_parms.mssfix - overhead;
2259 if (CryptoAlgs::mode(c.dc.cipher()) == CryptoAlgs::CBC_HMAC)
2267 auto block_size = CryptoAlgs::block_size(c.
dc.
cipher());
2268 target += block_size;
2269 target = (target / block_size) * block_size;
2275 OPENVPN_LOG(
"mssfix disabled since computed value is outside type bounds ("
2281 c.
mss_fix =
static_cast<decltype(c.mss_fix)
>(target - payload_overhead);
2284 <<
", overhead=" << overhead
2285 <<
", payload_overhead=" << payload_overhead
2286 <<
", target=" << target <<
")");
2298 bool enable_compress =
true;
2340 if (enable_compress)
2392 const unsigned char *orig_data = recv.
data();
2393 const size_t orig_size = recv.
size();
2403 if (orig_size < (tls_frame_size +
hmac_size))
2407 const unsigned char *wkc_raw = orig_data + tls_frame_size;
2408 size_t wkc_raw_size = orig_size - tls_frame_size -
sizeof(uint16_t);
2412 std::memcpy(&wkc_len, wkc_raw + wkc_raw_size,
sizeof(wkc_len));
2413 wkc_len = ntohs(wkc_len);
2420 wkc_raw = orig_data + orig_size - wkc_len;
2421 wkc_raw_size = wkc_len -
sizeof(uint16_t);
2429 std::memcpy(&k_id, wkc_raw + wkc_raw_size - serverkey_id_size,
sizeof(k_id));
2434 if ((wkc_len -
sizeof(uint16_t)) != wkc_raw_size)
2440 const uint16_t net_wkc_len = htons(wkc_len);
2441 plaintext.
write(&net_wkc_len,
sizeof(net_wkc_len));
2445 std::stringstream ss;
2446 ss << std::hex << std::setfill(
'0') << std::uppercase << std::setw(8) << k_id;
2448 const std::string serverkey_fn = ss.str() +
".key";
2450 + serverkey_fn.substr(0, 2) +
"/" + serverkey_fn;
2454 const std::string serverkey =
read_text(serverkey_path);
2459 tls_crypt_v2_key.
parse(serverkey);
2469 plaintext.
write(&k_id,
sizeof(k_id));
2472 if (plaintext.
max_size() <= 2 + serverkey_id_size)
2476 plaintext.
data() + 2 + serverkey_id_size,
2477 plaintext.
max_size() - 2 - serverkey_id_size,
2479 wkc_raw_size -
hmac_size - serverkey_id_size);
2491 plaintext.
advance(
sizeof(wkc_len));
2494 plaintext.
advance(
sizeof(k_id));
2499 int metadata_type = -1;
2500 if (!plaintext.
empty())
2507 recv.
set_size(orig_size - wkc_len);
2515 const unsigned char *orig_data = recv.
data();
2516 const size_t orig_size = recv.
size();
2563 const unsigned char *orig_data = recv.
data();
2564 const size_t orig_size = recv.
size();
2577 if (orig_size < data_offset)
2652 if (!is_safe_conversion<uint16_t>(
proto.
config->mss_fix))
2674 static_assert(
sizeof(op32) ==
OP_SIZE_V2,
"OP_SIZE_V2 inconsistency");
2677 pid_wrap =
crypto->
encrypt(buf, (
const unsigned char *)&op32);
2680 buf.
prepend((
const unsigned char *)&op32,
sizeof(op32));
2703 <<
" KeyContext[" <<
key_id_ <<
"] "
2711 <<
" KeyContext[" <<
key_id_ <<
"] "
2719 <<
" KeyContext[" <<
key_id_ <<
"] "
2764 if (is_safe_conversion<DataLimit::size_type>(size))
2859 unsigned int initial_op(
const bool sender,
const bool tls_crypt_v2)
const
2891 while (!buf.
empty())
2903 if (buf.
size() < len)
2954 throw proto_error(
"app_recv: received control message is too large");
3020 buf->write(proto_context_private::auth_prefix,
sizeof(proto_context_private::auth_prefix));
3023 const std::string options =
proto.
config->options_string();
3045 const unsigned char *buf_pre = buf->read_alloc(
sizeof(proto_context_private::auth_prefix));
3046 if (std::memcmp(buf_pre, proto_context_private::auth_prefix,
sizeof(proto_context_private::auth_prefix)))
3047 throw proto_error(
"bad_auth_prefix");
3049 const std::string options = read_auth_string<std::string>(*buf);
3052 const std::string username = read_auth_string<std::string>(*buf);
3053 const SafeString password = read_auth_string<SafeString>(*buf);
3054 const std::string peer_info = read_auth_string<std::string>(*buf);
3062 if (!bc.
advance(
sizeof(proto_context_private::auth_prefix)))
3113 throw proto_error(
"peer_psid_undef");
3344 const unsigned char *orig_data = recv.
data();
3345 const size_t orig_size = recv.
size();
3377 auto &recv = *pkt.
buf;
3378 const unsigned char *orig_data = recv.data();
3379 const size_t orig_size = recv.size();
3391 if (orig_size < data_offset)
3511 switch (unwrap_wkc_result)
3557 return "C_WAIT_RESET_ACK";
3559 return "C_WAIT_AUTH_ACK";
3561 return "S_WAIT_RESET_ACK";
3563 return "S_WAIT_AUTH_ACK";
3567 return "C_WAIT_RESET";
3569 return "C_WAIT_AUTH";
3573 return "S_WAIT_RESET";
3575 return "S_WAIT_AUTH";
3579 return "STATE_UNDEF";
3586 Time::Duration d = next_time - *
now;
3587 if (d.is_infinite())
3590 return numeric_cast<int>(d.to_seconds());
3630 : op_code_(opcode_extract(op_field)), key_id_(key_id_extract(op_field))
3636 return key_id_ == 0 && (op_code_ == CONTROL_HARD_RESET_CLIENT_V2 || op_code_ == CONTROL_HARD_RESET_CLIENT_V3);
3642 return op_code_ == CONTROL_HARD_RESET_CLIENT_V3 || op_code_ == CONTROL_WKC_V1;
3648 return (pidc.id & EARLY_NEG_MASK) == EARLY_NEG_START;
3653 return key_id_ == 0 && (op_code_ == CONTROL_V1 || op_code_ == ACK_V1 || op_code_ == CONTROL_WKC_V1);
3660 const uint16_t type = htons(EARLY_NEG_FLAGS);
3661 const uint16_t len = htons(
sizeof(uint16_t));
3662 const uint16_t
flags = htons(EARLY_NEG_FLAG_RESEND_WKC);
3665 payload.
prepend(&len,
sizeof(len));
3666 payload.
prepend(&type,
sizeof(type));
3671 return op_compose(CONTROL_HARD_RESET_SERVER_V2, 0);
3683 : proto_field_(peer_info.get_num<unsigned int>(
"IV_PROTO", 1, 0))
3689 return proto_field_ & iv_proto_flag::IV_PROTO_TLS_KEY_EXPORT;
3694 return proto_field_ & iv_proto_flag::IV_PROTO_AUTH_FAIL_TEMP;
3699 return proto_field_ & iv_proto_flag::IV_PROTO_DATA_V2;
3704 return proto_field_ & iv_proto_flag::IV_PROTO_AUTH_PENDING_KW;
3709 return proto_field_ & iv_proto_flag::IV_PROTO_PUSH_UPDATE;
3714 return proto_field_ & iv_proto_flag::IV_PROTO_REQUEST_PUSH;
3720 return proto_field_ & iv_proto_flag::IV_PROTO_CC_EXIT_NOTIFY;
3726 return proto_field_ & iv_proto_flag::IV_PROTO_DYN_TLS_CRYPT;
3732 return proto_field_ & iv_proto_flag::IV_PROTO_DNS_OPTION_V2;
3756 throw tls_auth_pre_validate();
3759 reset_op = server ? CONTROL_HARD_RESET_CLIENT_V2 : CONTROL_HARD_RESET_SERVER_V2;
3769 ? OpenVPNStaticKey::INVERSE
3770 : OpenVPNStaticKey::NORMAL;
3771 ta_hmac_recv->init(c.
tls_auth_key.
slice(OpenVPNStaticKey::HMAC | OpenVPNStaticKey::DECRYPT | key_dir));
3784 if (net_buf.
empty())
3787 const unsigned int op = net_buf[0];
3788 if (opcode_extract(op) != reset_op || key_id_extract(op) != 0)
3791 return ta_hmac_recv->ovpn_hmac_cmp(net_buf.
c_data(),
3793 OPCODE_SIZE + ProtoSessionID::SIZE,
3794 ta_hmac_recv->output_size(),
3795 PacketIDControl::size());
3819 throw tls_crypt_pre_validate();
3822 reset_op = CONTROL_HARD_RESET_SERVER_V2;
3834 reset_op = tls_crypt_v2_enabled
3835 ? CONTROL_HARD_RESET_CLIENT_V3
3836 : CONTROL_HARD_RESET_CLIENT_V2;
3842 const unsigned int key_dir = server ? OpenVPNStaticKey::NORMAL : OpenVPNStaticKey::INVERSE;
3845 c.
tls_crypt_key.
slice(OpenVPNStaticKey::CIPHER | OpenVPNStaticKey::DECRYPT | key_dir));
3858 if (net_buf.
empty())
3861 const unsigned int op = net_buf[0];
3862 if (opcode_extract(op) != reset_op || key_id_extract(op) != 0)
3865 const size_t data_offset = TLSCryptContext::hmac_offset + tls_crypt_recv->output_hmac_size();
3866 if (net_buf.
size() < data_offset)
3872 const size_t decrypt_bytes = tls_crypt_recv->decrypt(net_buf.
c_data() + TLSCryptContext::hmac_offset,
3875 net_buf.
c_data() + data_offset,
3876 net_buf.
size() - data_offset);
3880 work.inc_size(decrypt_bytes);
3883 return tls_crypt_recv->hmac_cmp(net_buf.
c_data(),
3884 TLSCryptContext::hmac_offset,
3901 bool disabled =
false;
3960 return primary->get_tls_warnings();
3962 OPENVPN_LOG(
"TLS: primary key context uninitialized. Can't retrieve TLS warnings");
3990 key_ctx->export_key_material(dyn_key,
"EXPORTER-OpenVPN-dynamic-tls-crypt");
4062 unsigned int key_dir;
4125 if (cookie_psid.defined())
4181 throw proto_error(
"start: no primary key");
4303 throw proto_error(
"data_encrypt: no primary key");
4318 if (!in_out.
empty())
4325 if (proto_context_private::is_keepalive(in_out))
4346#ifndef OPENVPN_DISABLE_EXPLICIT_EXIT
4352 if (
config->cc_exit_notify)
4359 primary->send_explicit_exit_notify();
4398 return primary->invalidation_reason();
4419 config->process_push(opt, pco);
4428 return config->enable_op32 ? 0 : 1;
4434 return config->keepalive_ping.enabled()
4435 ||
config->keepalive_timeout.enabled();
4441 unsigned int &keepalive_timeout)
4443 keepalive_ping =
config->keepalive_ping.enabled()
4446 keepalive_timeout =
config->keepalive_timeout.enabled()
4461 primary->data_limit_notify(cdl_mode, cdl_status);
4463 secondary->data_limit_notify(cdl_mode, cdl_status);
4481 config->local_peer_id = local_peer_id;
4521 return config->protocol.is_tcp();
4525 return config->protocol.is_udp();
4646 throw select_key_context_error();
4659 throw proto_error(
"select_control_send_context: no primary key");
4687 bool did_work =
false;
4715 <<
" New KeyContext SECONDARY id=" <<
secondary->key_id()
4716 << (initiator ?
" local-triggered" :
" remote-triggered"));
4768 primary->set_next_event_if_unspecified();
4810 secondary->set_next_event_if_unspecified();
4855 if (!
config->wkc.defined())
4856 throw proto_error(
"Client Key Wrapper undefined");
#define OPENVPN_BS64_DATA_LIMIT
void swap(BufferAllocatedType< T_ > &other)
Swaps the contents of this BufferAllocatedType object with another BufferAllocatedType object.
bool advance(size_t size)
report various types of exceptions or errors that may occur when working with buffers
static Type parse_method(const std::string &method)
const char * options_string() const
unsigned int extra_payload_bytes() const
static Type stub(const Type t)
const char * peer_info_string() const
static bool is_any_stub(const Type t)
virtual void decompress(BufferAllocated &buf)=0
virtual void compress(BufferAllocated &buf, const bool hint)=0
const T * c_data() const
Returns a const pointer to the start of the buffer.
T * prepend_alloc(const size_t size)
Allocate space for prepending data to the buffer.
void append(const B &other)
Append data from another buffer to this buffer.
void inc_size(const size_t delta)
Increment the size of the array (usually used in a similar context to set_size such as after mutable_...
size_t max_size() const
Return the maximum allowable size value in T objects given the current offset (without considering re...
void prepend(const T *data, const size_t size)
Prepend data to the buffer.
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.
void advance(const size_t delta)
Advances the buffer by the specified delta.
bool empty() const
Returns true if the buffer is empty.
void write(const T *data, const size_t size)
Write data to the buffer.
auto * read_alloc(const size_t size)
Allocate memory and read data from the buffer into the allocated memory.
T pop_front()
Removes and returns the first element from the buffer.
void push_front(const T &value)
Append a T object to the array, with possible resize.
void set_size(const size_t size)
After an external method, operating on the array as a mutable unsigned char buffer,...
void null_terminate()
Null-terminate the array.
void reset_size()
Resets the size of the buffer to zero.
void read(NCT *data, const size_t size)
Read data from the buffer into the specified memory location.
const char * name() const
virtual CryptoDCInstance::Ptr new_obj(const unsigned int key_id)=0
virtual size_t encap_overhead() const =0
virtual void explicit_exit_notify()
virtual void init_pid(const char *recv_name, const int recv_unit, const SessionStats::Ptr &recv_stats_arg)=0
@ EXPLICIT_EXIT_NOTIFY_DEFINED
virtual unsigned int defined() const =0
virtual void init_remote_peer_id(const int remote_peer_id)
virtual void init_hmac(StaticKey &&encrypt_key, StaticKey &&decrypt_key)=0
virtual void rekey(const RekeyType type)=0
virtual bool encrypt(BufferAllocated &buf, const unsigned char *op32)=0
virtual Error::Type decrypt(BufferAllocated &buf, std::time_t now, const unsigned char *op32)=0
virtual bool consider_compression(const CompressContext &comp_ctx)=0
virtual void init_cipher(StaticKey &&encrypt_key, StaticKey &&decrypt_key)=0
CryptoAlgs::Type cipher() const
bool useEpochKeys() const
CryptoAlgs::KeyDerivation key_derivation() const
CryptoAlgs::Type digest() const
void set_key_derivation(CryptoAlgs::KeyDerivation method)
CryptoDCContext & context()
void set_use_epoch_keys(bool at_the_end)
void set_digest(const CryptoAlgs::Type new_digest)
void set_cipher(const CryptoAlgs::Type new_cipher)
static const char * mode_str(const Mode m)
static const char * state_str(const State s)
size_t prepare(const unsigned int context, Buffer &buf) const
const char * dev_type() const
static void mssfix(BufferAllocated &buf, uint16_t mss_fix)
void XOR(const OpenVPNStaticKey &other)
unsigned char * raw_alloc()
void parse(const std::string &key_text)
StaticKey slice(unsigned int key_specifier) const
const Option * get_ptr(const std::string &name) const
bool exists(const std::string &name) const
const std::string & get(const size_t index, const size_t max_len) const
T get_num(const size_t idx) const
void min_args(const size_t n) const
const std::string & ref(const size_t i) const
virtual OvpnHMACInstance::Ptr new_obj()=0
virtual size_t size() const =0
virtual OvpnHMACContext::Ptr new_obj(const CryptoAlgs::Type digest_type)=0
virtual void ovpn_hmac_gen(unsigned char *data, const size_t data_size, const size_t l1, const size_t l2, const size_t l3)=0
virtual void init(const StaticKey &key)=0
virtual bool ovpn_hmac_cmp(const unsigned char *data, const size_t data_size, const size_t l1, const size_t l2, const size_t l3)=0
void init(const char *name_arg, const int unit_arg, const SessionStats::Ptr &stats_arg)
PacketIDControl read_next(Buffer &buf) const
bool test_add(const PacketIDControl &pin, const PacketIDControl::time_t now, const bool mod)
void init(PacketIDControl::id_t start_at=0)
void write_next(Buffer &buf, const bool prepend, const PacketIDControl::time_t now)
virtual void control_net_send(const Buffer &net_buf)=0
static void write_empty_string(Buffer &buf)
virtual bool supports_epoch_data()=0
virtual void client_auth(Buffer &buf)
virtual void control_recv(BufferPtr &&app_bp)=0
virtual void server_auth(const std::string &username, const SafeString &password, const std::string &peer_info, const AuthCert::Ptr &auth_cert)
virtual void active(bool primary)=0
Called when KeyContext transitions to ACTIVE state.
virtual ~ProtoContextCallbackInterface()=default
unsigned int proto_field_
bool client_supports_dns_option() const
Checks if the client can handle dns (as opposed to dhcp-option).
bool client_supports_ekm_key_method() const
bool client_supports_push_update() const
bool client_supports_data_v2() const
bool client_supports_request_push() const
bool client_supports_auth_pending_kwargs() const
IvProtoHelper(const OptionList &peer_info)
bool client_supports_temp_auth_failed() const
bool client_supports_exit_notify() const
Checks if the client is able to send an explicit EXIT message before exiting.
bool client_supports_dynamic_tls_crypt() const
Checks if the client can handle dynamic TLS-crypt.
Time data_limit_expire() const
void encapsulate(id_t id, Packet &pkt)
static const char * event_type_string(const EventType et)
bool decapsulate_post_process(Packet &pkt, ProtoSessionID &src_psid, const PacketIDControl pid)
Time reached_active() const
void kev_error(const EventType ev, const Error::Type reason)
Time reached_active_time_
static BufferAllocated static_work
static bool validate(const Buffer &net_buf, ProtoContext &proto, TimePtr now)
void set_protocol(const Protocol &p)
void prepend_dest_psid_and_acks(Buffer &buf, unsigned int opcode)
void set_next_event_if_unspecified()
TLSPRFInstance::Ptr tlsprf
Time next_retransmit() const
bool net_recv(Packet &&pkt)
void invalidate_callback()
void set_state(const int newstate)
BufferComposed app_recv_buf
std::deque< BufferPtr > app_pre_write_queue
void recv_auth(BufferPtr buf)
bool decapsulate_tls_plain(Packet &pkt)
EventType get_event() const
static bool validate_tls_plain(Buffer &recv, ProtoContext &proto, TimePtr now)
void app_recv(BufferPtr &&to_app_buf)
void net_send(const Packet &net_pkt, const Base::NetSendType nstype)
void app_send(BufferPtr &&bp)
void set_event(const EventType current)
void raw_recv(Packet &&raw_pkt)
void gen_head(const unsigned int opcode, BufferAllocated &buf)
unsigned int crypto_flags
std::unique_ptr< DataLimit > data_limit
void prepare_expire(const EventType current_ev=KeyContext::KEV_NONE)
void decrypt(BufferAllocated &buf)
Time become_primary_time()
void send_data_channel_message(const unsigned char *data, const size_t size)
void gen_head_tls_crypt(const unsigned int opcode, BufferAllocated &buf)
void gen_head_tls_plain(const unsigned int opcode, Buffer &buf)
void encrypt(BufferAllocated &buf)
bool data_limit_defer() const
bool recv_auth_complete(BufferComplete &bc) const
bool data_channel_ready() const
bool verify_src_psid(const ProtoSessionID &src_psid)
void generate_ack(Packet &pkt)
bool verify_dest_psid(Buffer &buf)
Error::Type invalidation_reason() const
bool parse_early_negotiation(const Packet &pkt)
void calculate_mssfix(ProtoConfig &c)
bool decapsulate_tls_crypt(Packet &pkt)
static bool validate_tls_crypt(Buffer &recv, ProtoContext &proto, TimePtr now)
void start(const ProtoSessionID cookie_psid=ProtoSessionID())
Initialize the state machine and start protocol negotiation.
void invalidate(const Error::Type reason)
uint32_t get_tls_warnings() const
static Error::Type unwrap_tls_crypt_wkc(Buffer &recv, ProtoConfig &proto_config, TLSCryptInstance &tls_crypt_server, TLSCryptMetadata::Ptr tls_crypt_metadata=nullptr)
Extract and process the TLS crypt WKc information.
void generate_datachannel_keys()
void gen_head_tls_auth(const unsigned int opcode, Buffer &buf)
void process_next_event()
void app_send_validate(BufferPtr &&bp)
OPENVPN_SIMPLE_EXCEPTION(tls_crypt_unwrap_wkc_error)
void data_limit_event(const DataLimit::Mode mode, const DataLimit::State state)
CryptoDCInstance::Ptr crypto
bool key_limit_renegotiation_fired
KeyContext(ProtoContext &p, const bool initiator, bool psid_cookie_mode=false)
void send_explicit_exit_notify()
unsigned int key_id() const
static bool validate_tls_auth(Buffer &recv, ProtoContext &proto, TimePtr now)
unsigned int initial_op(const bool sender, const bool tls_crypt_v2) const
int seconds_until(const Time &next_time)
static const char * state_string(const int s)
void data_limit_notify(const DataLimit::Mode cdl_mode, const DataLimit::State cdl_status)
bool do_encrypt(BufferAllocated &buf, const bool compress_hint)
std::unique_ptr< DataChannelKey > data_channel_key
bool data_limit_add(const DataLimit::Mode mode, const size_t size)
void set_event(const EventType current, const EventType next, const Time &next_time)
void schedule_key_limit_renegotiation()
void rekey(const CryptoDCInstance::RekeyType type)
bool decapsulate(Packet &pkt)
void key_limit_reneg(const EventType ev, const Time &t)
bool decapsulate_tls_auth(Packet &pkt)
PacketType(const Buffer &buf, class ProtoContext &proto)
bool is_soft_reset() const
bool contains_tls_ciphertext() const
Packet(BufferPtr &&buf_arg, const unsigned int opcode_arg=CONTROL_V1)
void frame_prepare(const Frame &frame, const unsigned int context)
const Buffer & buffer() const
const BufferPtr & buffer_ptr()
void parse_pushed_peer_id(const OptionList &opt)
PeerInfo::Set::Ptr extra_peer_info
extra peer info key/value pairs generated by client app
Time::Duration keepalive_ping
std::string peer_info_string(bool supports_epoch_data) const
void build_connect_time_peer_info_string(TransportClient::Ptr transport)
std::string relay_prefix(const char *optname) const
void enable_dynamic_tls_crypt()
void load_common(const OptionList &opt, const ProtoContextCompressionOptions &pco, const LoadCommonType type)
SSLFactoryAPI::Ptr ssl_factory
bool tls_crypt_enabled() const
void set_protocol(const Protocol &p)
std::string initial_options
unsigned int link_mtu_adjust()
void set_tls_crypt_algs()
TLSCryptContext::Ptr tls_crypt_context
TLSCryptFactory::Ptr tls_crypt_factory
TLSCryptMetadataFactory::Ptr tls_crypt_metadata_factory
Time::Duration become_primary
bool tls_crypt_v2_serverkey_id
do we expect keys to contain a server key ID?
Time::Duration tls_timeout
std::string tls_crypt_v2_serverkey_dir
server keys location, if tls_crypt_v2_serverkey_id is true
void show_cc_enc_option(std::ostringstream &os) const
BufferAllocated wkc
leave this undefined to disable tls-crypt-v2 on client
void set_tls_auth_digest(const CryptoAlgs::Type digest)
void parse_pushed_data_channel_options(const OptionList &opt)
bool tls_auth_enabled() const
AppControlMessageReceiver app_control_recv
void get_data_channel_options(std::ostringstream &os) const
void set_xmit_creds(const bool xmit_creds_arg)
Time::Duration handshake_window
void process_push(const OptionList &opt, const ProtoContextCompressionOptions &pco)
AppControlMessageConfig app_control_config
OpenVPNStaticKey tls_crypt_key
leave this undefined to disable tls-crypt/tls-crypt-v2
void load(const OptionList &opt, const ProtoContextCompressionOptions &pco, const int default_key_direction, const bool server)
bool dynamic_tls_crypt_enabled() const
void parse_pushed_protocol_flags(const OptionList &opt)
OpenVPNStaticKey tls_auth_key
leave this undefined to disable tls_auth
PeerInfo::Set::Ptr extra_peer_info_transport
OpenVPNStaticKey wrapped_tls_crypt_key
For TLS crypt V2, this (if defined()) is the wrapped WKc client key.
std::string options_string()
std::string show_options() const
Time::Duration keepalive_timeout_early
unsigned tls_crypt_
needed to distinguish between tls-crypt and tls-crypt-v2 server mode
void parse_custom_app_control(const OptionList &opt)
void parse_pushed_compression(const OptionList &opt, const ProtoContextCompressionOptions &pco)
OvpnHMACContext::Ptr tls_auth_context
@ LOAD_COMMON_CLIENT_PUSHED
bool extra_peer_info_push_peerinfo
TLSPRFFactory::Ptr tlsprf_factory
bool tls_crypt_v2_enabled() const
Time::Duration renegotiate
Time::Duration keepalive_timeout
OvpnHMACFactory::Ptr tls_auth_factory
const unsigned int key_id_
static unsigned char get_server_hard_reset_opfield()
bool supports_early_negotiation(const PacketIDControl &pidc) const noexcept
Returns true if the peer supports early negotiation (i.e. is able to reply with CONTROL_WKC_V1).
const unsigned int op_code_
PsidCookieHelper(unsigned int op_field)
static void prepend_TLV(Buffer &payload)
Adds an {EARLY_NEG_FLAGS, 2, EARLY_NEG_FLAG_RESEND_WKC} TLV to a payload buffer (use with TLS crypt V...
bool is_clients_server_reset_ack() const
bool is_tls_crypt_v2() const noexcept
Returns true if this is a TLS crypt V2 protocol packet.
bool is_clients_initial_reset() const
OvpnHMACInstance::Ptr ta_hmac_recv
TLSAuthPreValidate(const ProtoConfig &c, const bool server)
OPENVPN_SIMPLE_EXCEPTION(tls_auth_pre_validate)
bool validate(const BufferAllocated &net_buf)
OPENVPN_SIMPLE_EXCEPTION(tls_crypt_pre_validate)
TLSCryptPreValidate(const ProtoConfig &c, const bool server)
bool validate(const BufferAllocated &net_buf)
TLSCryptInstance::Ptr tls_crypt_recv
virtual bool validate(const BufferAllocated &net_buf)=0
void data_limit_notify(const unsigned int key_id, const DataLimit::Mode cdl_mode, const DataLimit::State cdl_status)
bool control_net_recv(const PacketType &type, BufferPtr &&net_bp)
void set_local_peer_id(const int local_peer_id)
uint32_t get_tls_warnings() const
void send_explicit_exit_notify()
OPENVPN_UNTAGGED_EXCEPTION_INHERIT(option_error, process_server_push_error)
void net_send(const unsigned int key_id, const Packet &net_pkt)
const Time::Duration & slowest_handshake()
CryptoDCSettings & dc_settings()
void flush(const bool control_channel)
void set_dynamic_tls_crypt(const ProtoConfig &c, const KeyContext::Ptr &key_ctx)
OPENVPN_SIMPLE_EXCEPTION(select_key_context_error)
void control_send(BufferPtr &&app_bp)
KeyContext & select_control_send_context()
bool uses_bs64_cipher() const
void process_secondary_event()
void reset_tls_crypt(const ProtoConfig &c, const OpenVPNStaticKey &key)
PacketType packet_type(const Buffer &buf)
TLSCryptMetadata::Ptr tls_crypt_metadata
void data_encrypt(BufferAllocated &in_out)
void reset_tls_crypt_server(const ProtoConfig &c)
@ EARLY_NEG_FLAG_RESEND_WKC
TLSCryptInstance::Ptr tls_crypt_recv
bool is_keepalive_enabled() const
TLSCryptInstance::Ptr tls_crypt_server
const Frame & frame() const
OPENVPN_UNTAGGED_EXCEPTION_INHERIT(option_error, proto_error)
static unsigned char op_compose(const unsigned int opcode, const unsigned int key_id)
static S read_auth_string(Buffer &buf)
ProtoConfig::Ptr conf_ptr() const
OPENVPN_UNTAGGED_EXCEPTION_INHERIT(option_error, proto_option_error)
void process_primary_event()
@ CONTROL_HARD_RESET_CLIENT_V3
@ CONTROL_HARD_RESET_CLIENT_V2
@ CONTROL_HARD_RESET_SERVER_V2
const Mode & mode() const
TLSCryptInstance::Ptr tls_crypt_send
void process_push(const OptionList &opt, const ProtoContextCompressionOptions &pco)
static void write_auth_string(const S &str, Buffer &buf)
void client_auth(Buffer &buf)
static const char * opcode_name(const unsigned int opcode)
static unsigned int opcode_extract(const unsigned int op)
void set_protocol(const Protocol &p)
static unsigned int key_id_extract(const unsigned int op)
static S read_control_string(const Buffer &buf)
void write_control_string(const S &str)
bool data_channel_ready() const
void keepalive_housekeeping()
Time::Duration slowest_handshake_
unsigned int upcoming_key_id
static unsigned int op32_compose(const unsigned int opcode, const unsigned int key_id, const int op_peer_id)
size_t align_adjust_hint() const
PacketIDControlReceive ta_pid_recv
ProtoContextCallbackInterface * proto_callback
void reset_tls_wrap_mode(const ProtoConfig &c)
SessionStats & stat() const
OvpnHMACInstance::Ptr ta_hmac_recv
std::string dump_packet(const Buffer &buf)
void disconnect(const Error::Type reason)
static constexpr int OPCODE_SIZE
static uint16_t read_uint16_length(Buffer &buf)
bool control_net_validate(const PacketType &type, const Buffer &net_buf)
KeyContext & select_key_context(const PacketType &type, const bool control)
static void write_empty_string(Buffer &buf)
@ IV_PROTO_TLS_KEY_EXPORT
@ IV_PROTO_AUTH_PENDING_KW
@ IV_PROTO_AUTH_FAIL_TEMP
@ IV_PROTO_CC_EXIT_NOTIFY
TLSWrapMode tls_wrap_mode
void app_recv(const unsigned int key_id, BufferPtr &&to_app_buf)
void keepalive_parms_modified()
int primary_state() const
static void write_control_string(const S &str, Buffer &buf)
void control_send(BufferAllocated &&app_buf)
bool data_decrypt(const PacketType &type, BufferAllocated &in_out)
void disable_keepalive(unsigned int &keepalive_ping, unsigned int &keepalive_timeout)
static constexpr PacketIDControl::id_t EARLY_NEG_MASK
static constexpr PacketIDControl::id_t EARLY_NEG_START
Error::Type invalidation_reason() const
static size_t op_head_size(const unsigned int op)
void new_secondary_key(const bool initiator)
void update_last_received()
void promote_secondary_to_primary()
bool is_state_client_wait_reset_ack() const
unsigned int negotiations() const
PacketIDControlSend ta_pid_send
Time next_housekeeping() const
ProtoContext(ProtoContextCallbackInterface *cb_arg, const ProtoConfig::Ptr &config_arg, const SessionStats::Ptr &stats_arg)
static void write_uint16_length(const size_t size, Buffer &buf)
void tls_crypt_append_wkc(BufferAllocated &dst)
bool control_net_recv(const PacketType &type, BufferAllocated &&net_buf)
pass received control channel network packets (ciphertext) into protocol object
virtual ~ProtoContext()=default
std::string debug_prefix()
static constexpr size_t APP_MSG_MAX
const Frame::Ptr & frameptr() 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.
bool renegotiate_request(Packet &pkt)
KeyContext::Ptr secondary
unsigned int next_key_id()
OvpnHMACInstance::Ptr ta_hmac_send
const ProtoConfig & conf() const
bool match(const ProtoSessionID &other) const
constexpr bool defined() const
void randomize(StrongRandomAPI &rng)
void prepend(Buffer &buf) const
bool net_recv(Packet &&pkt)
ReliableSendTemplate< Packet > ReliableSend
uint32_t get_tls_warnings() const
void raw_send(Packet &&pkt)
Error::Type invalidation_reason() const
const AuthCert::Ptr & auth_cert() const
void app_send(BufferPtr &&buf)
void export_key_material(OpenVPNStaticKey &key, const std::string &label) const
const Time::Duration tls_timeout
Time next_retransmit() const
void invalidate(const Error::Type reason)
ReliableRecvTemplate< Packet > ReliableRecv
std::string ssl_handshake_details() const
const char * occ_str(const bool server) const
unsigned int extra_transport_bytes() const
Reference count base class for objects tracked by RCPtr. Allows copying and assignment.
void reset() noexcept
Points this RCPtr<T> to nullptr safely.
void swap(RCPtr &rhs) noexcept
swaps the contents of two RCPtr<T>
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
static Ptr Create(ArgsT &&...args)
Creates a new instance of RcEnable with the given arguments.
static void prepend_id(Buffer &buf, const id_t id)
void push_back(id_t value)
void prepend(Buffer &buf, bool ackv1)
static id_t read_id(Buffer &buf)
static size_t ack_skip(Buffer &buf)
static size_t ack(REL_SEND &rel_send, Buffer &buf, const bool live)
unsigned int receive(const PACKET &packet, const id_t id)
virtual SSLLib::Ctx libctx()=0
virtual const Mode & mode() const =0
A string-like type that clears the buffer contents on delete.
virtual void error(const size_t type, const std::string *text=nullptr)
virtual TLSCryptInstance::Ptr new_obj_send()=0
virtual TLSCryptInstance::Ptr new_obj_recv()=0
constexpr static const size_t hmac_offset
virtual size_t digest_size() const =0
virtual TLSCryptContext::Ptr new_obj(SSLLib::Ctx libctx, const CryptoAlgs::Type digest_type, const CryptoAlgs::Type cipher_type)=0
virtual bool hmac_cmp(const unsigned char *header, const size_t header_len, const unsigned char *payload, const size_t payload_len)=0
virtual bool hmac_gen(unsigned char *header, const size_t header_len, const unsigned char *payload, const size_t payload_len)=0
virtual size_t encrypt(const unsigned char *iv, unsigned char *out, const size_t olen, const unsigned char *in, const size_t ilen)=0
virtual void init(SSLLib::Ctx libctx, const StaticKey &key_hmac, const StaticKey &key_crypt)=0
virtual size_t decrypt(const unsigned char *iv, unsigned char *out, const size_t olen, const unsigned char *in, const size_t ilen)=0
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)
virtual void self_write(Buffer &buf)=0
virtual void peer_read(Buffer &buf)=0
virtual void self_randomize(StrongRandomAPI &rng)=0
virtual void generate_key_expansion(OpenVPNStaticKey &dest, const ProtoSessionID &psid_self, const ProtoSessionID &psid_peer) const =0
virtual bool peer_read_complete(BufferComplete &bc)=0
static TimeType infinite()
base_type seconds_since_epoch() const
#define OPENVPN_THROW_ARG1(exc, arg, stuff)
#define OPENVPN_THROW(exc, stuff)
#define OPENVPN_LOG(args)
#define OVPN_LOG_DEBUG(args)
#define OVPN_LOG_INFO(args)
#define OVPN_LOG_VERBOSE(args)
void work(openvpn_io::io_context &io_context, ThreadCommon &tc, MyRunContext &runctx, const unsigned int unit)
constexpr BufferFlags DESTRUCT_ZERO(1U<< 1)
if enabled, destructor will zero data before deletion
constexpr BufferFlags CONSTRUCT_ZERO(1U<< 0)
if enabled, constructors/init will zero allocated space
Mode mode(const Type type)
Type lookup(const std::string &name)
size_t key_length(const Type type)
const char * name(const KeyDerivation kd)
size_t size(const Type type)
std::size_t for_each(std::function< bool(Type, const Alg &)> fn)
bool is_safe_conversion(InT inVal)
Returns true if the given value can be contained by the out type.
OutT clamp_to_typerange(InT inVal)
Clamps the input value to the legal range for the output type.
std::vector< T > split(const T &str, const typename T::value_type sep, const int maxsplit=-1)
std::string trim_crlf_copy(std::string str)
const Option * load_duration_parm(Time::Duration &dur, const std::string &name, const OptionList &opt, const unsigned int min_value, const bool x2, const bool allow_ms)
void set_duration_parm(Time::Duration &dur, const std::string &name, const std::string &valstr, const unsigned int min_value, const bool x2, const bool ms)
std::string read_text(const std::string &filename, const std::uint64_t max_size=0)
std::string to_string(const T &t)
Convert a value to a string.
const char * platform_name()
std::string render_hex(const unsigned char *data, size_t size, const bool caps=false)
unsigned int parse_tun_mtu_max(const OptionList &opt, unsigned int default_value)
bool is_bs64_cipher(const CryptoAlgs::Type cipher)
unsigned int parse_tun_mtu(const OptionList &opt, unsigned int default_value)
std::string get_hwaddr(IP::Addr server_addr)
std::string dump_hex(const unsigned char *data, size_t size)
Implementation of the base classes for random number generators.
std::vector< std::string > supported_protocols
List of supported protocols.
int max_msg_size
Maximum size of each individual message/message fragment.
void parse_flags(const std::string &flags)
size_type decrypt_red_limit
size_type encrypt_red_limit
void parse(const OptionList &opt, bool nothrow=false)
static constexpr size_t size()
constexpr std::size_t size() const
bool is_comp_asym() const
std::optional< CryptoDCInstance::RekeyType > rekey_type
virtual IP::Addr server_endpoint_addr() const =0
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'
if(flags &RedirectGatewayFlags::RG_ENABLE) ret+
static std::stringstream out
const std::string optname