From 24bc97444f6bf6ca107de1eec27f6585f6dbad9b Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:01:06 -0500 Subject: [PATCH 01/12] Allow updates from fixed and dynamic spans --- .../hash/detail/sha_1_2_hasher_base.hpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/include/boost/crypt2/hash/detail/sha_1_2_hasher_base.hpp b/include/boost/crypt2/hash/detail/sha_1_2_hasher_base.hpp index d80699b7..551ab560 100644 --- a/include/boost/crypt2/hash/detail/sha_1_2_hasher_base.hpp +++ b/include/boost/crypt2/hash/detail/sha_1_2_hasher_base.hpp @@ -36,7 +36,8 @@ class sha_1_2_hasher_base bool computed_ {}; bool corrupted_ {}; - [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto update(compat::span data) noexcept -> state; + template + [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto update(compat::span data) noexcept -> state; [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto get_digest_impl(compat::span data) const noexcept -> state; @@ -47,7 +48,8 @@ class sha_1_2_hasher_base BOOST_CRYPT_GPU_ENABLED_CONSTEXPR sha_1_2_hasher_base() noexcept { base_init(); } BOOST_CRYPT_GPU_ENABLED_CONSTEXPR ~sha_1_2_hasher_base() noexcept; - BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; + template + BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; template BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(SizedRange&& data) noexcept -> state; @@ -236,19 +238,29 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha_1_2_hasher_base -BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha_1_2_hasher_base::process_bytes(compat::span data) noexcept -> state +template +BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha_1_2_hasher_base::process_bytes(compat::span data) noexcept -> state { return update(data); } template +template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR -auto sha_1_2_hasher_base::update(compat::span data) noexcept -> state +auto sha_1_2_hasher_base::update(compat::span data) noexcept -> state { - if (data.empty()) + if constexpr (Extent == compat::dynamic_extent) + { + if (data.empty()) + { + return state::success; + } + } + else if constexpr (Extent == 0U) { return state::success; } + if (computed_) { corrupted_ = true; From 9a4149761644cf28ddf1928648a5e59067768edd Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:01:19 -0500 Subject: [PATCH 02/12] Pass spans instead of arrays --- include/boost/crypt2/mac/hmac.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/boost/crypt2/mac/hmac.hpp b/include/boost/crypt2/mac/hmac.hpp index 8a4eb53a..bf1c671d 100644 --- a/include/boost/crypt2/mac/hmac.hpp +++ b/include/boost/crypt2/mac/hmac.hpp @@ -26,6 +26,8 @@ class hmac private: + using key_span = compat::span; + key_type inner_key_ {}; key_type outer_key_ {}; HasherType inner_hash_; @@ -125,8 +127,8 @@ hmac::init_impl(const compat::span data) outer_key_[i] = k0[i] ^ compat::byte{0x5C}; } - const auto inner_result {inner_hash_.process_bytes(inner_key_)}; - const auto outer_result {outer_hash_.process_bytes(outer_key_)}; + const auto inner_result {inner_hash_.process_bytes(key_span{inner_key_})}; + const auto outer_result {outer_hash_.process_bytes(key_span{outer_key_})}; if (inner_result == state::success && outer_result == state::success) [[likely]] { @@ -177,8 +179,8 @@ hmac::init_from_keys(const hmac::key_type& inner_key, const hmac::ke inner_key_ = inner_key; outer_key_ = outer_key; - const auto inner_result {inner_hash_.process_bytes(inner_key)}; - const auto outer_result {outer_hash_.process_bytes(outer_key)}; + const auto inner_result {inner_hash_.process_bytes(key_span{inner_key})}; + const auto outer_result {outer_hash_.process_bytes(key_span{outer_key})}; if (inner_result == state::success && outer_result == state::success) [[likely]] { @@ -275,7 +277,8 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto hmac::finalize() noexcept -> const auto r_inner {inner_hash_.get_digest()}; BOOST_CRYPT_ASSERT(r_inner.has_value()); - outer_hash_.process_bytes(r_inner.value()); + compat::span r_inner_span {r_inner.value()}; + outer_hash_.process_bytes(r_inner_span); [[maybe_unused]] const auto outer_final_state {outer_hash_.finalize()}; BOOST_CRYPT_ASSERT(outer_final_state == state::success); From 83a92d77f42351b6179f78e37daf7b07b0af6078 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:01:36 -0500 Subject: [PATCH 03/12] Add sha1 immediate test --- test/test_hmac.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/test_hmac.cpp b/test/test_hmac.cpp index 0600ff24..d7986306 100644 --- a/test/test_hmac.cpp +++ b/test/test_hmac.cpp @@ -128,6 +128,44 @@ void test_edges() BOOST_TEST(hmac_tester.finalize() == boost::crypt::state::state_error); } +template +consteval bool immediate_test() +{ + const std::byte vals[] = {std::byte{0x61}, std::byte{0x62}, std::byte{0x63}}; + std::span byte_span {vals}; + constexpr std::array message { + std::byte{0xdd}, std::byte{0xaf}, std::byte{0x35}, std::byte{0xa1}, std::byte{0x93}, std::byte{0x61}, + std::byte{0x7a}, std::byte{0xba}, std::byte{0xcc}, std::byte{0x41}, std::byte{0x73}, std::byte{0x49}, + std::byte{0xae}, std::byte{0x20}, std::byte{0x41}, std::byte{0x31}, std::byte{0x12}, std::byte{0xe6}, + std::byte{0xfa}, std::byte{0x4e}, std::byte{0x89}, std::byte{0xa9}, std::byte{0x7e}, std::byte{0xa2}, + std::byte{0x0a}, std::byte{0x9e}, std::byte{0xee}, std::byte{0xe6}, std::byte{0x4b}, std::byte{0x55}, + std::byte{0xd3}, std::byte{0x9a}, std::byte{0x21}, std::byte{0x92}, std::byte{0x99}, std::byte{0x2a}, + std::byte{0x27}, std::byte{0x4f}, std::byte{0xc1}, std::byte{0xa8}, std::byte{0x36}, std::byte{0xba}, + std::byte{0x3c}, std::byte{0x23}, std::byte{0xa3}, std::byte{0xfe}, std::byte{0xeb}, std::byte{0xbd}, + std::byte{0x45}, std::byte{0x4d}, std::byte{0x44}, std::byte{0x23}, std::byte{0x64}, std::byte{0x3c}, + std::byte{0xe8}, std::byte{0x0e}, std::byte{0x2a}, std::byte{0x9a}, std::byte{0xc9}, std::byte{0x4f}, + std::byte{0xa5}, std::byte{0x4c}, std::byte{0xa4}, std::byte{0x9f} + }; + std::span message_span {message}; + + boost::crypt::hmac hmac_tester; + hmac_tester.init(byte_span); + hmac_tester.process_bytes(message_span); + hmac_tester.finalize(); + const auto res = hmac_tester.get_digest().value(); + + std::size_t zero_counter {}; + for (const auto val : res) + { + if (val == std::byte{}) + { + ++zero_counter; + } + } + + return zero_counter != res.size(); +} + int main() { basic_tests(); @@ -138,5 +176,10 @@ int main() test_edges(); test_edges(); + // GCC-14 has an internal compiler error here + #if defined(__GNUC__) && __GNUC__ != 14 + static_assert(immediate_test()); + #endif + return boost::report_errors(); } From a5e81b141eb06159e66c93aed3fdf3fba1a44d2c Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:06:16 -0500 Subject: [PATCH 04/12] Include all the available hashers --- test/test_hmac.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/test_hmac.cpp b/test/test_hmac.cpp index d7986306..87853fef 100644 --- a/test/test_hmac.cpp +++ b/test/test_hmac.cpp @@ -4,8 +4,16 @@ #include #include +#include #include +#include #include +#include +#include +#include +#include +#include +#include #include template @@ -66,6 +74,19 @@ void basic_tests() BOOST_TEST(res[i] == static_cast(soln[i])); } } + else + { + std::size_t zero_counter {}; + for (const auto val : res) + { + if (val == std::byte{}) + { + ++zero_counter; + } + } + + BOOST_TEST(zero_counter < res.size()); + } } template @@ -169,12 +190,28 @@ consteval bool immediate_test() int main() { basic_tests(); + basic_tests(); basic_tests(); + basic_tests(); basic_tests(); + basic_tests(); + basic_tests(); + basic_tests(); + basic_tests(); + basic_tests(); + basic_tests(); test_edges(); + test_edges(); test_edges(); + test_edges(); test_edges(); + test_edges(); + test_edges(); + test_edges(); + test_edges(); + test_edges(); + test_edges(); // GCC-14 has an internal compiler error here #if defined(__GNUC__) && __GNUC__ != 14 From 5e66cb33181575e5c3ee71c79fd4117d213e5b01 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:07:26 -0500 Subject: [PATCH 05/12] Add immediate tests of SHA224/256 since they share implementation --- test/test_hmac.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_hmac.cpp b/test/test_hmac.cpp index 87853fef..1ddb4890 100644 --- a/test/test_hmac.cpp +++ b/test/test_hmac.cpp @@ -216,6 +216,8 @@ int main() // GCC-14 has an internal compiler error here #if defined(__GNUC__) && __GNUC__ != 14 static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); #endif return boost::report_errors(); From 903ec3865ef6c7e5218b04e84f1e8ebc732f86c9 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:12:23 -0500 Subject: [PATCH 06/12] Allow fixed and dynamic extent updates --- .../boost/crypt2/hash/detail/sha512_base.hpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/include/boost/crypt2/hash/detail/sha512_base.hpp b/include/boost/crypt2/hash/detail/sha512_base.hpp index c0eaf717..8efb740f 100644 --- a/include/boost/crypt2/hash/detail/sha512_base.hpp +++ b/include/boost/crypt2/hash/detail/sha512_base.hpp @@ -42,7 +42,8 @@ class sha512_base final BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_message_block() noexcept -> void; - [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto update(compat::span data) noexcept -> state; + template + [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto update(compat::span data) noexcept -> state; BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto pad_message() noexcept -> void; @@ -56,7 +57,8 @@ class sha512_base final BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto init() noexcept -> void; - BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; + template + BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; template BOOST_CRYPT_GPU_ENABLED auto process_bytes(SizedRange&& data) noexcept -> state; @@ -193,13 +195,22 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha512_base::finalize() noex } template +template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR -auto sha512_base::update(compat::span data) noexcept -> state +auto sha512_base::update(compat::span data) noexcept -> state { - if (data.empty()) + if constexpr (Extent == compat::dynamic_extent) + { + if (data.empty()) + { + return state::success; + } + } + else if constexpr (Extent == 0U) { return state::success; } + if (computed_) { corrupted_ = true; @@ -485,7 +496,8 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha512_base::process_message } template -BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha512_base::process_bytes(compat::span data) noexcept -> state +template +BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha512_base::process_bytes(compat::span data) noexcept -> state { return update(data); } From d7655f05caaa5e654bb48afca51136756317e1d3 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:12:40 -0500 Subject: [PATCH 07/12] Fix sizing of span for XOF get_digest --- include/boost/crypt2/hash/detail/sha3_base.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/crypt2/hash/detail/sha3_base.hpp b/include/boost/crypt2/hash/detail/sha3_base.hpp index 3485aaf0..199bd806 100644 --- a/include/boost/crypt2/hash/detail/sha3_base.hpp +++ b/include/boost/crypt2/hash/detail/sha3_base.hpp @@ -499,7 +499,6 @@ compat::enable_if_t sha3_base::get_digest(Ran return state::state_error; } - const auto data_size {std::size(data)}; auto data_span {compat::span(compat::forward(data))}; #if defined(__clang__) && __clang_major__ >= 19 @@ -507,7 +506,7 @@ compat::enable_if_t sha3_base::get_digest(Ran #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container" #endif - xof_digest_impl(compat::span(compat::as_writable_bytes(data_span).data(), data_size), data_size); + xof_digest_impl(compat::span(compat::as_writable_bytes(data_span).data(), data.size_bytes()), data.size_bytes()); #if defined(__clang__) && __clang_major__ >= 19 #pragma clang diagnostic pop From 65aeac526addb0b897185b4ccb47f8bec045e5e8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:13:38 -0500 Subject: [PATCH 08/12] Add consteval sha512 family testing --- test/test_hmac.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_hmac.cpp b/test/test_hmac.cpp index 1ddb4890..0a4a9b1d 100644 --- a/test/test_hmac.cpp +++ b/test/test_hmac.cpp @@ -218,6 +218,10 @@ int main() static_assert(immediate_test()); static_assert(immediate_test()); static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); #endif return boost::report_errors(); From 08c94bb95115d89e987dd307d6aa44ac20e604b4 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:44:38 -0500 Subject: [PATCH 09/12] Allow dynamic extents and fix sizing of writeable spans --- .../boost/crypt2/hash/detail/sha3_base.hpp | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/include/boost/crypt2/hash/detail/sha3_base.hpp b/include/boost/crypt2/hash/detail/sha3_base.hpp index 199bd806..6c9b616c 100644 --- a/include/boost/crypt2/hash/detail/sha3_base.hpp +++ b/include/boost/crypt2/hash/detail/sha3_base.hpp @@ -37,11 +37,13 @@ class sha3_base final { BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_message_block() noexcept -> void; + template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR - auto update(compat::span data) noexcept -> state; + auto update(compat::span data) noexcept -> state; + template BOOST_CRYPT_GPU_ENABLED_CONSTEXPR - auto xof_digest_impl(compat::span data, compat::size_t amount) noexcept -> void; + auto xof_digest_impl(compat::span data, compat::size_t amount) noexcept -> void; BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha_digest_impl(compat::span data) const noexcept -> void; @@ -57,7 +59,8 @@ class sha3_base final { BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto init() noexcept -> void; - BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; + template + BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto process_bytes(compat::span data) noexcept -> state; template BOOST_CRYPT_GPU_ENABLED auto process_bytes(SizedRange&& data) noexcept -> state; @@ -242,13 +245,22 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha3_base::process_m } template +template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR -auto sha3_base::update(compat::span data) noexcept -> state +auto sha3_base::update(compat::span data) noexcept -> state { - if (data.empty()) + if constexpr (Extent == compat::dynamic_extent) + { + if (data.empty()) + { + return state::success; + } + } + else if constexpr (Extent == 0U) { return state::success; } + if (computed_) { corrupted_ = true; @@ -292,8 +304,9 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha3_base::init() no } template +template BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto -sha3_base::process_bytes(compat::span data) noexcept -> state +sha3_base::process_bytes(compat::span data) noexcept -> state { return update(data); } @@ -333,8 +346,9 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha3_base::finalize( } template +template BOOST_CRYPT_GPU_ENABLED_CONSTEXPR -auto sha3_base::xof_digest_impl(compat::span data, std::size_t amount) noexcept -> void +auto sha3_base::xof_digest_impl(compat::span data, std::size_t amount) noexcept -> void { static_assert(is_xof, "Calling for variable amounts of data is not allowed with non-XOF hashers"); @@ -404,7 +418,14 @@ compat::enable_if_t sha3_base::get_digest(com { return state::state_error; } - if (data.size() < digest_size) + if constexpr (Extent == compat::dynamic_extent) + { + if (data.size() < digest_size) + { + return state::insufficient_output_length; + } + } + else if constexpr (Extent < digest_size) { return state::insufficient_output_length; } @@ -459,15 +480,13 @@ compat::enable_if_t sha3_base::get_digest(Ran return state::state_error; } - const auto data_size {std::size(data)}; + auto data_span {compat::span(compat::forward(data))}; - if (data_size < digest_size) + if (data_span.size_bytes() < digest_size) { return state::insufficient_output_length; } - auto data_span {compat::span(compat::forward(data))}; - #if defined(__clang__) && __clang_major__ >= 19 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container" @@ -525,7 +544,7 @@ compat::enable_if_t sha3_base::get_digest(com return state::state_error; } - if (data.size() < amount) + if (data.size_bytes() < amount) { return state::insufficient_output_length; } @@ -548,13 +567,13 @@ compat::enable_if_t sha3_base::get_digest(Ran return state::state_error; } - if (std::size(data) < amount) + auto data_span {compat::span(compat::forward(data))}; + + if (data.size_bytes() < amount) { return state::insufficient_output_length; } - auto data_span {compat::span(compat::forward(data))}; - #if defined(__clang__) && __clang_major__ >= 19 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container" From 28fd48d0aab90269a96e4012525fbb4454a237dd Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:45:19 -0500 Subject: [PATCH 10/12] Add testing of sha3 family --- test/test_hmac.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_hmac.cpp b/test/test_hmac.cpp index 0a4a9b1d..3feb5064 100644 --- a/test/test_hmac.cpp +++ b/test/test_hmac.cpp @@ -222,6 +222,10 @@ int main() static_assert(immediate_test()); static_assert(immediate_test()); static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); + static_assert(immediate_test()); #endif return boost::report_errors(); From ddac8a7fc0ab4ceffe81823ac064191bcdf03711 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 11:54:53 -0500 Subject: [PATCH 11/12] Fix byte conversions --- include/boost/crypt2/hash/detail/sha3_base.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/crypt2/hash/detail/sha3_base.hpp b/include/boost/crypt2/hash/detail/sha3_base.hpp index 6c9b616c..918abd3d 100644 --- a/include/boost/crypt2/hash/detail/sha3_base.hpp +++ b/include/boost/crypt2/hash/detail/sha3_base.hpp @@ -404,7 +404,8 @@ sha3_base::get_digest() noexcept } return_type digest {}; - xof_digest_impl(digest, digest_size); + compat::span digest_span {digest}; + xof_digest_impl(digest_span, digest_size); return digest; } @@ -525,7 +526,7 @@ compat::enable_if_t sha3_base::get_digest(Ran #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container" #endif - xof_digest_impl(compat::span(compat::as_writable_bytes(data_span).data(), data.size_bytes()), data.size_bytes()); + xof_digest_impl(compat::span(compat::as_writable_bytes(data_span).data(), data_span.size_bytes()), data_span.size_bytes()); #if defined(__clang__) && __clang_major__ >= 19 #pragma clang diagnostic pop @@ -569,7 +570,7 @@ compat::enable_if_t sha3_base::get_digest(Ran auto data_span {compat::span(compat::forward(data))}; - if (data.size_bytes() < amount) + if (data_span.size_bytes() < amount) { return state::insufficient_output_length; } From 007f0c56068283fc195f5c7c288a2f1d476c1716 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 17 Jan 2025 12:26:43 -0500 Subject: [PATCH 12/12] Ignore MSVC unreachable code warnings --- .../boost/crypt2/hash/detail/sha3_base.hpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/boost/crypt2/hash/detail/sha3_base.hpp b/include/boost/crypt2/hash/detail/sha3_base.hpp index 918abd3d..697c3397 100644 --- a/include/boost/crypt2/hash/detail/sha3_base.hpp +++ b/include/boost/crypt2/hash/detail/sha3_base.hpp @@ -244,6 +244,13 @@ BOOST_CRYPT_GPU_ENABLED_CONSTEXPR auto sha3_base::process_m buffer_index_ = 0U; } +// In the fixed extent case where we check Extent == 0 this can make the rest of the code unreachable +// We consider this a good thing since this means our compile time checks are working +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4702) +#endif + template template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR @@ -283,6 +290,10 @@ auto sha3_base::update(compat::span BOOST_CRYPT_GPU_ENABLED_CONSTEXPR sha3_base::~sha3_base() noexcept { @@ -410,6 +421,13 @@ sha3_base::get_digest() noexcept return digest; } +// In the fixed extent case where we check Extent < digest_size this can make the rest of the code unreachable +// We consider this a good thing since this means our compile time checks are working +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4702) +#endif + template template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR @@ -419,6 +437,7 @@ compat::enable_if_t sha3_base::get_digest(com { return state::state_error; } + if constexpr (Extent == compat::dynamic_extent) { if (data.size() < digest_size) @@ -453,6 +472,10 @@ compat::enable_if_t sha3_base::get_digest(com return state::success; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + template template [[nodiscard]] BOOST_CRYPT_GPU_ENABLED_CONSTEXPR