57 :
pcfg_(*psfp->proto_context_config),
126 pctb_ = std::move(pctb);
146 static const size_t reqd_packet_size
151 if (pkt_buf.
size() < reqd_packet_size)
162 recv_buf_copy.
advance(hmac_size);
165 cli_auth_pktid.
read(recv_buf_copy);
167 uint8_t cli_net_id[4];
169 recv_buf_copy.
read(cli_net_id,
sizeof(cli_net_id));
179 send_buf.
prepend(
static_cast<const void *
>(&net_id),
sizeof(net_id));
183 send_buf.
prepend(cli_net_id,
sizeof(cli_net_id));
221 static const size_t reqd_packet_size
228 if (pkt_buf.
size() < reqd_packet_size)
239 recv_buf_copy.
advance(hmac_size);
242 cli_auth_pktid.
read(recv_buf_copy);
244 unsigned int ack_count = recv_buf_copy[0];
304 uint32_t valid_time =
static_cast<uint32_t
>(
now_->
raw() / interval - offset);
306 hmac_ctx_.update(
reinterpret_cast<const unsigned char *
>(&valid_time),
311 size_t cli_addrport_size;
313 hmac_ctx_.update(cli_addr_port, cli_addrport_size);
320 BufferAllocated hmac_result(SSLLib::CryptoAPI::HMACContext::MAX_HMAC_SIZE);
323 srv_psid.
read(hmac_result);
334 for (
unsigned int offset = 0; offset <= 1; ++offset)
338 if (srv_psid.
match(calc_psid))
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.
T * write_alloc(const size_t size)
Allocate space for writing data to the buffer.
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.
void push_front(const T &value)
Append a T object to the array, with possible resize.
void read(NCT *data, const size_t size)
Read data from the buffer into the specified memory location.
size_t prepare(const unsigned int context, Buffer &buf) const
StaticKey slice(unsigned int key_specifier) const
virtual OvpnHMACInstance::Ptr new_obj()=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
virtual size_t output_size() const =0
void write_next(Buffer &buf, const bool prepend, const PacketIDControl::time_t now)
OpenVPNStaticKey tls_auth_key
leave this undefined to disable tls_auth
OvpnHMACContext::Ptr tls_auth_context
static unsigned char get_server_hard_reset_opfield()
bool is_clients_server_reset_ack() const
bool is_clients_initial_reset() const
bool match(const ProtoSessionID &other) const
const Buffer get_buf() const
void prepend(Buffer &buf) const
Interface to communicate the server's address semantics.
virtual const unsigned char * get_abstract_cli_addrport(size_t &slab_size) const =0
Implements the PsidCookie interface.
static StaticKey create_key()
SSLLib::CryptoAPI::HMACContext hmac_ctx_
OvpnHMACInstance::Ptr ta_hmac_recv_
ProtoSessionID get_cookie_psid() override
Get the cookie psid from client's 2nd packet.
static const StaticKey & get_key()
ProtoSessionID cookie_psid_
const Time::Duration & handwindow_
bool check_session_id_hmac(const ProtoSessionID &srv_psid, const ProtoSessionID &cli_psid, const PsidCookieAddrInfoBase &pcaib)
const ProtoContext::ProtoConfig & pcfg_
Intercept intercept(ConstBuffer &pkt_buf, const PsidCookieAddrInfoBase &pcaib) override
Called when a potential new client session packet is received.
PsidCookieTransportBase::Ptr pctb_
Intercept process_clients_initial_reset(ConstBuffer &pkt_buf, const PsidCookieAddrInfoBase &pcaib)
virtual ~PsidCookieImpl()=default
static constexpr int SID_SIZE
ProtoSessionID calculate_session_id_hmac(const ProtoSessionID &cli_psid, const PsidCookieAddrInfoBase &pcaib, unsigned int offset)
Calculate the psid cookie, the ProtoSessionID hmac.
static constexpr CryptoAlgs::Type digest_
static void pre_threading_setup()
void provide_psid_cookie_transport(PsidCookieTransportBase::Ptr pctb) override
Give this component the transport needed to send the server's HARD_RESET.
PsidCookieImpl(ServerProto::Factory *psfp)
Intercept process_clients_server_reset_ack(ConstBuffer &pkt_buf, const PsidCookieAddrInfoBase &pcaib)
OvpnHMACInstance::Ptr ta_hmac_send_
virtual bool psid_cookie_send_const(Buffer &send_buf, const PsidCookieAddrInfoBase &pcaib)=0
Interface to integrate this component into the server implementation.
Intercept
Values returned by the intercept() function.
void init_from_rng(StrongRandomAPI &rng, const size_t key_size)
const unsigned char * data() const
base_type seconds_since_epoch() const
const Alg & get(const Type type)
static constexpr std::size_t id_size
Support deferred server-side state creation when client connects.
static constexpr size_t size()
static constexpr size_t idsize