aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2023-07-18 16:52:08 -0400
committerPieter Wuille <pieter@wuille.net>2023-08-17 15:31:56 -0400
commitda0ec62e34cc56bf8990e28c6ec12683d4752305 (patch)
treeb9f2e9dab5642ad60a9af112c77b95b57ad6733e
parentbdcbc8594c208f11e7d5221700bfa7f7a874aec9 (diff)
downloadbitcoin-da0ec62e34cc56bf8990e28c6ec12683d4752305.tar.xz
tests: miscellaneous hex / std::byte improvements
-rw-r--r--src/test/crypto_tests.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp
index 52ac7cff5b..0a6378adf4 100644
--- a/src/test/crypto_tests.cpp
+++ b/src/test/crypto_tests.cpp
@@ -226,10 +226,9 @@ static void TestPoly1305(const std::string &hexmessage, const std::string &hexke
{
auto key = ParseHex<std::byte>(hexkey);
auto m = ParseHex<std::byte>(hexmessage);
- auto tag = ParseHex<std::byte>(hextag);
std::vector<std::byte> tagres(Poly1305::TAGLEN);
Poly1305{key}.Update(m).Finalize(tagres);
- BOOST_CHECK(tag == tagres);
+ BOOST_CHECK_EQUAL(HexStr(tagres), hextag);
// Test incremental interface
for (int splits = 0; splits < 10; ++splits) {
@@ -243,7 +242,7 @@ static void TestPoly1305(const std::string &hexmessage, const std::string &hexke
}
tagres.assign(Poly1305::TAGLEN, std::byte{});
poly1305.Update(data).Finalize(tagres);
- BOOST_CHECK(tag == tagres);
+ BOOST_CHECK_EQUAL(HexStr(tagres), hextag);
}
}
}
@@ -922,15 +921,15 @@ BOOST_AUTO_TEST_CASE(poly1305_testvector)
auto total_key = ParseHex<std::byte>("01020304050607fffefdfcfbfaf9ffffffffffffffffffffffffffff00000000");
Poly1305 total_ctx(total_key);
for (unsigned i = 0; i < 256; ++i) {
- std::vector<std::byte> key(32, std::byte{(uint8_t)i});
- std::vector<std::byte> msg(i, std::byte{(uint8_t)i});
+ std::vector<std::byte> key(32, std::byte{uint8_t(i)});
+ std::vector<std::byte> msg(i, std::byte{uint8_t(i)});
std::array<std::byte, Poly1305::TAGLEN> tag;
Poly1305{key}.Update(msg).Finalize(tag);
total_ctx.Update(tag);
}
std::vector<std::byte> total_tag(Poly1305::TAGLEN);
total_ctx.Finalize(total_tag);
- BOOST_CHECK(total_tag == ParseHex<std::byte>("64afe2e8d6ad7bbdd287f97c44623d39"));
+ BOOST_CHECK_EQUAL(HexStr(total_tag), "64afe2e8d6ad7bbdd287f97c44623d39");
}
// Tests with sparse messages and random keys.