65 unsigned char c[slab_size_];
87 const std::string tls_key_fn = UNITTEST_SOURCE_DIR
"/input/psid_cookie_tls.key";
88 pcfg->tls_auth_key.parse_from_file(tls_key_fn);
92 pcfg->handshake_window = Time::Duration::seconds(60);
93 pcfg->key_direction = 0;
98 spf->proto_context_config =
pcfg;
111 now += Time::Duration::binary_ms(binary_ms);
130 ASSERT_NE(pci_dut,
nullptr);
134 EXPECT_TRUE(start == *pci_dut->
now_);
157 EXPECT_TRUE(hmac_ok);
159 advance_clock(interval);
162 EXPECT_TRUE(hmac_ok);
164 advance_clock(interval);
167 EXPECT_FALSE(hmac_ok);
184 std::uint32_t acked_pktid_be,
185 std::uint32_t own_pktid_be,
186 unsigned char ack_count,
187 unsigned char op_field)
200 buf.
prepend(&own_pktid_be,
sizeof(own_pktid_be));
202 buf.
prepend(&acked_pktid_be,
sizeof(acked_pktid_be));
241 auto f = make_fixture();
249 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
250 EXPECT_TRUE(pcookie_impl->get_cookie_psid().match(
f.cookie_psid));
257 auto f = make_fixture();
265 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
270 auto f = make_fixture();
278 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
283 auto f = make_fixture();
291 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
296 auto f = make_fixture();
304 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
309 auto f = make_fixture();
317 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
326 auto f = make_fixture();
334 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
339 auto f = make_fixture();
347 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::EARLY_DROP);
352 auto f = make_fixture();
357 bogus.
randomize(*pcookie_impl->pcfg_.rng);
366 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
371 auto f = make_fixture();
381 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
451 pcfg.set_tls_crypt_algs();
452 pcfg.tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V2;
453 pcfg.tls_crypt_v2_serverkey_id =
true;
454 pcfg.tls_crypt_v2_serverkey_dir = UNITTEST_SOURCE_DIR
"/../ssl";
463 SSLLib::SSLAPI::Config::Ptr sslcfg(
new SSLLib::SSLAPI::Config());
465 sslcfg->set_frame(
pcfg.frame);
466 sslcfg->set_rng(
pcfg.rng);
467 sslcfg->load_ca(
read_text(UNITTEST_SOURCE_DIR
"/../ssl/ca.crt"),
true);
468 sslcfg->load_cert(
read_text(UNITTEST_SOURCE_DIR
"/../ssl/server.crt"));
469 sslcfg->load_private_key(
read_text(UNITTEST_SOURCE_DIR
"/../ssl/server.key"));
470 pcfg.ssl_factory = sslcfg->new_factory();
504 const std::string &metadata,
511 const std::optional<std::uint32_t> k_id =
pcfg.tls_crypt_v2_serverkey_id ? std::optional<std::uint32_t>(
SERVER_KEY_ID)
521 pcfg.ssl_factory->libctx());
532 unsigned char op_field)
543 unsigned char op_field,
544 std::uint32_t own_pktid_be)
547 const size_t hmac_size =
pcfg.tls_crypt_context->digest_size();
551 send->
init(
pcfg.ssl_factory->libctx(),
559 const std::uint32_t acked_pktid_be = 0;
560 payload.
write(&acked_pktid_be,
sizeof(acked_pktid_be));
561 cookie_psid.
write(payload);
562 payload.
write(&own_pktid_be,
sizeof(own_pktid_be));
567 work.prepend_alloc(hmac_size);
571 work.push_front(op_field);
577 work.data() + data_offset,
578 work.max_size() - data_offset,
581 work.inc_size(encrypt_bytes);
598 std::uint32_t own_pktid_be = 0)
601 pcookie_impl->pcfg_.prng->rand_bytes(kc_raw,
sizeof(kc_raw));
603 std::memcpy(kc.
raw_alloc(), kc_raw,
sizeof(kc_raw));
611 wrap_wkc(kc_raw,
"v=1,type=external", 0x00),
635 pkt.
write(&early_neg_be,
sizeof(early_neg_be));
636 const std::uint32_t pid_time_be = 0;
637 pkt.
write(&pid_time_be,
sizeof(pid_time_be));
640 while (pkt.
size() < frame_size)
672 auto f = make_fixture();
675 make_wkc(
"v=1,type=external"),
678 const size_t wire_size = pkt.
size();
681 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
683 EXPECT_EQ(pkt.
size(), wire_size);
687 EXPECT_LT(pkt.
size(), wire_size);
695 auto f = make_fixture();
698 make_wkc(
"v=1,type=external"),
701 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
705 EXPECT_TRUE(pcookie_impl->pcfg_.tls_crypt_v2_serverkey_id);
706 EXPECT_FALSE(pcookie_impl->pcfg_.tls_crypt_key.defined());
707 EXPECT_FALSE(spf->clone_proto_config()->tls_crypt_key.defined());
754 void error(
const size_t type,
const std::string *text =
nullptr)
override
804 auto f = make_fixture();
807 make_wkc(
"v=1,type=external"),
810 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
812 ASSERT_EQ(meta_factory->n_created, 0u);
815 EXPECT_GT(session.
recv(pkt), 0u);
818 EXPECT_EQ(meta_factory->n_created, 1u);
819 EXPECT_EQ(meta_factory->last->n_calls, 1u);
824 auto f = make_fixture();
825 const std::string metadata =
"v=1,type=external,sn=04:e3,time=1750000000,tenant=acme";
832 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
833 EXPECT_TRUE(pcookie_impl->get_cookie_psid().match(
f.cookie_psid));
837 ASSERT_GT(session.
recv(pkt), 0u);
839 ASSERT_EQ(meta_factory->n_created, 1u);
840 ASSERT_TRUE(meta_factory->last);
841 EXPECT_EQ(meta_factory->last->n_calls, 1u);
842 EXPECT_EQ(meta_factory->last->type_seen, 0x00);
843 EXPECT_EQ(meta_factory->last->payload_seen, metadata);
851 auto f = make_fixture();
854 make_wkc(
"v=1,type=external"),
857 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
860 pkt.
data()[pkt.
size() - 32] ^= 0x01;
863 EXPECT_EQ(session.
recv(pkt), 0u);
877 pcfg.tls_crypt_v2_serverkey_id =
false;
878 pcfg.tls_crypt_v2_serverkey_dir.clear();
889 auto f = make_fixture();
892 make_wkc(
"v=1,type=external"),
895 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
902 auto f = make_fixture();
905 make_wkc(
"v=1,type=external"),
908 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
911 EXPECT_GT(session.
recv(pkt), 0u);
912 EXPECT_EQ(meta_factory->n_created, 1u);
922 auto f = make_fixture();
928 wrap_wkc(client_key_raw_,
"", 0x00, short_kc),
932 ASSERT_NO_THROW(ret = pcookie_impl->intercept(pkt,
f.cli_addr));
933 EXPECT_NE(ret, PsidCookie::Intercept::HANDLE_2ND);
940 wrap_wkc(client_key_raw_,
"", 0x00, short_kc),
956 pcookie_impl->provide_psid_cookie_transport(transport);
958 auto f = make_fixture();
959 BufferAllocated pkt = build_first_packet_tls_crypt_v2(
f.cli_psid, make_wkc(
"v=1,type=external"));
961 const size_t wire_size = pkt.
size();
964 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_1ST);
965 EXPECT_EQ(transport->n_sent, 1u);
967 EXPECT_EQ(pkt.
size(), wire_size);
991 auto f = make_fixture();
994 make_wkc(
"v=1,type=external"),
997 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1007 EXPECT_GT(session.
recv(pkt), 0u);
1015 auto f = make_fixture();
1018 make_wkc(
"v=1,type=external"),
1021 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1024 ASSERT_TRUE(pcookie_impl->pcfg_.tls_auth_enabled());
1034 EXPECT_GT(session.
recv(pkt), 0u);
1041 auto f = make_fixture();
1044 make_wkc(
"v=1,type=external"),
1045 control_v1_op_field());
1068 pcfg.tls_auth_key.erase();
1069 pcfg.tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::V1;
1070 pcfg.tls_crypt_v2_serverkey_id =
false;
1071 pcfg.tls_crypt_v2_serverkey_dir.clear();
1091 auto f = make_fixture();
1095 other_psid.
randomize(*pcookie_impl->pcfg_.rng);
1105 EXPECT_TRUE(
validate(v1_packet(other_psid,
f.cookie_psid)));
1106 EXPECT_TRUE(
validate(v1_packet(
f.cli_psid,
f.cookie_psid)));
1120 pcfg.tls_crypt_ = ProtoContext::ProtoConfig::TLSCrypt::None;
1121 pcfg.tls_crypt_key.erase();
1122 pcfg.tls_crypt_v2_serverkey_id =
false;
1123 pcfg.tls_crypt_v2_serverkey_dir.clear();
1131 auto f = make_fixture();
1153 auto f = make_fixture();
1155 for (
size_t size = 1; size <= 96; ++size)
1170 ASSERT_NO_THROW(ret = pcookie_impl->intercept(pkt,
f.cli_addr)) <<
"size " << size;
1171 EXPECT_NE(ret, PsidCookie::Intercept::HANDLE_2ND) <<
"size " << size;
1181 auto f = make_fixture();
1184 make_wkc(
"v=1,type=external"),
1187 ASSERT_EQ(pcookie_impl->intercept(good,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1193 pcookie_impl->pcfg_.prng->rand_bytes(foreign_key_raw,
sizeof(foreign_key_raw));
1196 wrap_wkc(foreign_key_raw,
"v=1,type=external", 0x00),
1200 EXPECT_EQ(session.
recv(spoofed), 0u);
1203 EXPECT_GT(session.
recv(good), 0u);
1213 auto f = make_fixture();
1216 make_wkc(
"v=1,type=external"),
1219 ASSERT_EQ(pcookie_impl->intercept(good,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1222 bogus_cookie_psid.
randomize(*pcookie_impl->pcfg_.rng);
1225 EXPECT_EQ(session.
recv(build_foreign_third_packet(bogus_cookie_psid)), 0u);
1228 EXPECT_GT(session.
recv(good), 0u);
1237 auto f = make_fixture();
1240 make_wkc(
"v=1,type=external"),
1243 ASSERT_EQ(pcookie_impl->intercept(good,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1248 session.
recv(wrap_third_packet(client_key_,
1251 make_wkc(
"v=1,type=external"),
1259 control_v1_op_field(),
1262 session.
recv(no_wkc);
1274 auto f = make_fixture();
1277 make_wkc(
"v=1,type=external"),
1282 EXPECT_GT(session.
recv(pkt), 0u);
1284 EXPECT_EQ(meta_factory->n_created, 1u);
1285 EXPECT_EQ(meta_factory->last->n_calls, 1u);
1293 auto f = make_fixture();
1297 pcookie_impl->pcfg_.prng->rand_bytes(foreign_key_raw,
sizeof(foreign_key_raw));
1300 wrap_wkc(foreign_key_raw,
"v=1,type=ATTACKER", 0x00),
1305 EXPECT_EQ(session.
recv(spoofed), 0u);
1306 EXPECT_EQ(meta_factory->n_created, 0u);
1309 EXPECT_EQ(session.
recv(spoofed), 0u);
1310 EXPECT_EQ(meta_factory->n_created, 0u);
1311 EXPECT_FALSE(meta_factory->last);
1316 make_wkc(
"v=1,type=external"),
1318 EXPECT_GT(session.
recv(good), 0u);
1319 EXPECT_EQ(meta_factory->n_created, 1u);
1320 EXPECT_EQ(meta_factory->last->payload_seen,
"v=1,type=external");
1328 auto f = make_fixture();
1331 make_wkc(
"v=1,type=external"),
1334 pcookie_impl->pcfg_.tls_crypt_metadata_factory.reset();
1335 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1338 EXPECT_GT(session.
recv(pkt), 0u);
1339 EXPECT_EQ(meta_factory->n_created, 0u);
1346 auto f = make_fixture();
1349 make_wkc(std::string(
"\x68\x74\x9f\x00", 4), 0x01),
1352 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1355 ASSERT_GT(session.
recv(pkt), 0u);
1357 ASSERT_TRUE(meta_factory->last);
1358 EXPECT_EQ(meta_factory->last->n_calls, 1u);
1359 EXPECT_EQ(meta_factory->last->type_seen, 0x01);
1364 auto f = make_fixture();
1370 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1373 ASSERT_GT(session.
recv(pkt), 0u);
1375 ASSERT_TRUE(meta_factory->last);
1376 EXPECT_EQ(meta_factory->last->n_calls, 1u);
1377 EXPECT_EQ(meta_factory->last->type_seen, -1);
1385 auto f = make_fixture();
1387 bogus.
randomize(*pcookie_impl->pcfg_.rng);
1391 make_wkc(
"v=1,type=external"),
1394 EXPECT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::DROP_2ND);
1396 EXPECT_EQ(meta_factory->n_created, 0u);
1397 EXPECT_FALSE(meta_factory->last);
1405 auto f = make_fixture();
1406 meta_factory->accept =
false;
1410 make_wkc(
"v=1,type=external"),
1414 ASSERT_EQ(pcookie_impl->intercept(pkt,
f.cli_addr), PsidCookie::Intercept::HANDLE_2ND);
1417 EXPECT_EQ(session.
recv(pkt), 0u);
1418 EXPECT_EQ(session.
rec->
names,
"TLS_CRYPT_META_FAIL");
static constexpr size_t slab_size_
ClientAddressMock(RandomAPI &prng)
union ClientAddressMock::@119 addrport_
const unsigned char * get_abstract_cli_addrport(size_t &slab_size) const override
virtual ~ClientAddressMock()=default
const void * get_impl_info() const override
A ProtoContext needs one of these; it counts what the session puts on the wire.
bool supports_epoch_data() override
void control_net_send(const Buffer &net_buf) override
void active(bool primary) override
Called when KeyContext transitions to ACTIVE state.
void control_recv(BufferPtr &&app_bp) override
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)
A server with one tls-crypt-v2 key in its config for every client.
PsidCookieSingleServerKeyTest()
Time advance_clock(uint64_t binary_ms)
Time set_clock(Time setting)
ProtoContext::ProtoConfig::Ptr pcfg
ServerProto::Factory::Ptr spf
the server factory each session's ProtoConfig is cloned from
openvpn_io::io_context dummy_io_context
std::unique_ptr< PsidCookieImpl > pcookie_impl
A server holding a tls-crypt-v2 key and no tls-auth one.
PsidCookieTlsCryptV2OnlyTest()
Tests for the tls-crypt-v2 arm of intercept()
static unsigned char control_v1_op_field()
the opcode of the packets that follow, which carry no WKc to key a session from
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 make_wkc(const std::string &metadata, int metadata_type=0x00)
Build the WKc a client appends to its handshake packets.
static unsigned char wkc_v1_op_field()
the opcode of the third packet, the one whose WKc keys the session behind it
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,...
RCPtr< MetadataRecorderFactory > meta_factory
OpenVPNStaticKey client_key_
Kc, as the client keys its tls-crypt instance.
BufferAllocated wrap_wkc(const unsigned char *kc, const std::string &metadata, int metadata_type, size_t kc_size=OpenVPNStaticKey::KEY_SIZE)
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...
PsidCookieTlsCryptV2Test()
unsigned char client_key_raw_[OpenVPNStaticKey::KEY_SIZE]
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.
TLSCryptV2ServerKey server_key_
Ka/Ke, used here to wrap the WKc.
static constexpr std::uint32_t SERVER_KEY_ID
K_id of test/ssl/06/063FE634.key, the server key the WKc names.
Names every error the session reports, so a test can say why a packet was dropped.
void error(const size_t type, const std::string *text=nullptr) override
Stands in for the transport the cookie layer answers a first packet through.
bool psid_cookie_send_const(Buffer &send_buf, const PsidCookieAddrInfoBase &pcaib) override
A plain tls-auth server: no tls-crypt of either version.
A tls-crypt v1 server: one key shared with every client, no tls-auth, no WKc.
OpenVPNStaticKey shared_key_
The one key a v1 server shares with every client, in the form both sides slice.
BufferAllocated v1_packet(const ProtoSessionID &cli_psid, const ProtoSessionID &srv_psid)
A CONTROL_V1 frame from cli_psid, wrapped with the shared key and echoing srv_psid.
void reset(const size_t min_capacity, const BufferFlags flags=BufAllocFlags::NO_FLAGS)
Resets the buffer with the specified minimum capacity and flags.
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 push_back(const T &value)
Append a T object to the end of the array, resizing the array if necessary.
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.
bool empty() const
Returns true if the buffer is empty.
void write(const T *data, const size_t size)
Write data to 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,...
unsigned char * raw_alloc()
StaticKey slice(unsigned int key_specifier) const
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 size_t output_size() const =0
void write_next(Buffer &buf, const bool prepend, const PacketIDControl::time_t now)
static bool strip_resent_wkc(Buffer &recv, const ProtoConfig &proto_config)
Virtually remove a resent WKc from the end of a CONTROL_WKC_V1 packet.
static size_t tls_crypt_frame_size(const ProtoConfig &proto_config)
Smallest tls-crypt frame a WKc can be appended to.
static Error::Type unwrap_tls_crypt_wkc(Buffer &recv, const ProtoConfig &proto_config, TLSCryptInstance &tls_crypt_server, UnwrappedWkc &unwrapped)
Extract and process the TLS crypt WKc information.
Time::Duration handshake_window
OpenVPNStaticKey tls_auth_key
leave this undefined to disable tls_auth
bool control_net_recv(const PacketType &type, BufferPtr &&net_bp)
void flush(const bool control_channel)
PacketType packet_type(const Buffer &buf)
@ CONTROL_HARD_RESET_CLIENT_V3
static unsigned char op_compose(const unsigned int opcode, const unsigned int key_id)
bool control_net_validate(const PacketType &type, const Buffer &net_buf)
static constexpr PacketIDControl::id_t EARLY_NEG_START
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.
void write(Buffer &buf) const
void randomize(StrongRandomAPI &rng)
void prepend(Buffer &buf) const
Interface to communicate the server's address semantics.
Implements the PsidCookie interface.
OvpnHMACInstance::Ptr ta_hmac_recv_
bool check_session_id_hmac(const ProtoSessionID &srv_psid, const ProtoSessionID &cli_psid, const PsidCookieAddrInfoBase &pcaib)
static constexpr int SID_SIZE
ProtoContext::ProtoConfig & pcfg_
ProtoSessionID calculate_session_id_hmac(const ProtoSessionID &cli_psid, const PsidCookieAddrInfoBase &pcaib, unsigned int offset)
Calculate the psid cookie, the ProtoSessionID hmac.
static void pre_threading_setup()
static constexpr int OPCODE_SIZE
Interface to provide access to the server's transport capability.
Interface to integrate this component into the server implementation.
Intercept
Values returned by the intercept() function.
void reset() noexcept
Points this RCPtr<T> to nullptr safely.
T * get() const noexcept
Returns the raw pointer to the object T, or nullptr.
Abstract base class for random number generators.
void rand_fill(T &obj)
Fill a data object with random bytes.
static Ptr Create(ArgsT &&...args)
Creates a new instance of RcEnable with the given arguments.
constexpr static const size_t hmac_offset
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
static BufferAllocated wrap(TLSCryptContext &context, const TLSCryptV2ServerKey &server_key, const unsigned char *kc, const size_t kc_size, const std::string &metadata, const int metadata_type, const std::optional< std::uint32_t > key_id, SSLLib::Ctx libctx=nullptr)
Wrap client key material and metadata into a WKc.
void parse(const std::string &key_text)
void extract_key(OpenVPNStaticKey &tls_key) const
base_type seconds_since_epoch() const
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 CONSTRUCT_ZERO(1U<< 0)
if enabled, constructors/init will zero allocated space
Type lookup(const std::string &name)
const char * name(const size_t type)
Frame::Ptr frame_init_simple(const size_t payload)
std::string read_text(const std::string &filename, const std::uint64_t max_size=0)
BufferAllocatedType< unsigned char > BufferAllocated
std::string buf_to_string(const Buffer &buf)
The session kotun.hpp creates once intercept() has returned HANDLE_2ND.
CookieSession(const ProtoContext::ProtoConfig::Ptr &cfg, const ProtoSessionID &cookie_psid)
RCPtr< RecordingStats > rec
size_t recv(const BufferAllocated &pkt)
ProtoSessionID cookie_psid
ClientAddressMock cli_addr
static constexpr size_t idsize
What a WKc yields, owned by whoever asked for the unwrap.
OpenVPNStaticKey client_key
Kc, the client key the WKc wrapped.
TEST_F(PsidCookieTest, CheckSetup)
void validate(const ValidateCreds::Type type, const bool expected_result, const std::string &cred, const bool strict)