From: Remi Gacogne Date: Tue, 3 Feb 2026 09:33:43 +0000 (+0100) Subject: Cleanup of base64-related header and unit tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdd5c57f56d5222fad81c86b39d19063256cc89e;p=thirdparty%2Fpdns.git Cleanup of base64-related header and unit tests Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-crypto.hh b/pdns/dnsdistdist/dnsdist-crypto.hh index 74e1c04696..b164c49fed 100644 --- a/pdns/dnsdistdist/dnsdist-crypto.hh +++ b/pdns/dnsdistdist/dnsdist-crypto.hh @@ -23,7 +23,6 @@ #include "config.h" #include #include -#include #include #if defined(HAVE_LIBSODIUM) @@ -65,7 +64,7 @@ constexpr size_t getEncryptedSize(size_t plainTextSize) #if defined(HAVE_LIBSODIUM) return plainTextSize + crypto_secretbox_MACBYTES; #elif defined(HAVE_LIBCRYPTO) - return plainTextSize + 16; + return plainTextSize + 16U; #else return plainTextSize; #endif diff --git a/pdns/test-base64_cc.cc b/pdns/test-base64_cc.cc index d246b0d18e..c2d4ee3722 100644 --- a/pdns/test-base64_cc.cc +++ b/pdns/test-base64_cc.cc @@ -3,9 +3,7 @@ #endif #define BOOST_TEST_NO_MAIN -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif + #include #include @@ -16,21 +14,23 @@ using namespace boost; BOOST_AUTO_TEST_SUITE(test_base64_cc) BOOST_AUTO_TEST_CASE(test_Base64_Roundtrip) { - std::string before("Some Random String"), after; - std::string encoded = Base64Encode(before); + const std::string before("Some Random String"); + const auto encoded = Base64Encode(before); + + std::string after; B64Decode(encoded, after); BOOST_CHECK_EQUAL(before, after); } -/* for a in $(seq 1 32); - do - plain=$(pwgen -1 -s $a) - echo \(\"$plain\",\"$(echo -n $plain | openssl enc -base64)\"\) ; +/* for a in $(seq 1 32); + do + plain=$(pwgen -1 -s $a) + echo \(\"$plain\",\"$(echo -n $plain | openssl enc -base64)\"\) ; done */ BOOST_AUTO_TEST_CASE(test_Base64_Encode) { - typedef std::map cases_t; + using cases_t = std::map; cases_t cases; assign::insert(cases) ("", "") @@ -67,10 +67,10 @@ BOOST_AUTO_TEST_CASE(test_Base64_Encode) { ("eSHBt7Xx5F7A4HFtabXEzDLD01bnSiG","ZVNIQnQ3WHg1RjdBNEhGdGFiWEV6RExEMDFiblNpRw==") ("dq4KydZjmcoQQ45VYBP2EDR8FqKaMul0","ZHE0S3lkWmptY29RUTQ1VllCUDJFRFI4RnFLYU11bDA="); - for(const cases_t::value_type& val : cases) { - std::string encoded = Base64Encode(val.first), decoded; + for (const auto& val : cases) { + const auto encoded = Base64Encode(val.first); BOOST_CHECK_EQUAL(encoded, val.second); - decoded.clear(); + std::string decoded; B64Decode(val.second, decoded); BOOST_CHECK_EQUAL(decoded, val.first); }