unit->ids = std::move(response.d_idstate);
DNSResponse dnsResponse(unit->ids, unit->response, unit->downstream);
- dnsheader cleartextDH
- {
- };
+ dnsheader cleartextDH{};
memcpy(&cleartextDH, dnsResponse.getHeader(), sizeof(cleartextDH));
if (!response.isAsync()) {
return buffer;
}
-static constexpr size_t MAX_TOKEN_LEN = std::tuple_size<decltype(SodiumNonce::value)>{} /* nonce */ + /* MAC */ crypto_secretbox_MACBYTES + sizeof(uint64_t) /* TTD */ + 16 /* IPv6 */ + QUICHE_MAX_CONN_ID_LEN;
+static constexpr size_t MAX_TOKEN_LEN = dnsdist::crypto::authenticated::getEncryptedSize(std::tuple_size<decltype(SodiumNonce::value)>{} /* nonce */ + sizeof(uint64_t) /* TTD */ + 16 /* IPv6 */ + QUICHE_MAX_CONN_ID_LEN);
static PacketBuffer mintToken(const PacketBuffer& dcid, const ComboAddress& peer)
{
dcid.data(), &dcid_len,
token.data(), &token_len);
if (res != 0) {
- DEBUGLOG("Error in quiche_header_info: "<<res);
+ DEBUGLOG("Error in quiche_header_info: " << res);
continue;
}
std::string sodDecryptSym(const std::string_view& msg, const std::string& key, SodiumNonce& nonce, bool incrementNonce = true);
std::string newKey(bool base64Encoded = true);
bool sodIsValidKey(const std::string& key);
+
+namespace dnsdist::crypto::authenticated
+{
+constexpr size_t getEncryptedSize(size_t plainTextSize)
+{
+#if defined(HAVE_LIBSODIUM)
+ return plainTextSize + crypto_secretbox_MACBYTES;
+#else
+ return plainTextSize;
+#endif
+}
+}