Skip to content

Commit

Permalink
Replace static_assert with runtime assert
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Oct 31, 2024
1 parent 2a2dae0 commit 5272f79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/crypt/hash/detail/sha3_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ template <boost::crypt::size_t digest_size, bool is_xof>
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED constexpr auto sha3_base<digest_size, is_xof>::xof_digest_impl(ForwardIter return_buffer, boost::crypt::size_t len) noexcept -> boost::crypt::size_t
{
static_assert(is_xof, "Producing a digest of variable size is only allowed with SHAKE128 and SHAKE256 (XOF hashers)");
BOOST_CRYPT_ASSERT_MSG(is_xof, "Producing a digest of variable size is only allowed with SHAKE128 and SHAKE256 (XOF hashers)");

if (corrupted_)
{
Expand Down
2 changes: 2 additions & 0 deletions test/link_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/crypt/hash/sha512_224.hpp>
#include <boost/crypt/hash/sha512_256.hpp>
#include <boost/crypt/hash/sha3_512.hpp>
#include <boost/crypt/hash/shake128.hpp>

void test_odr_use();

Expand All @@ -34,5 +35,6 @@ void f1()
test<boost::crypt::sha512_224_hasher>();
test<boost::crypt::sha512_256_hasher>();
test<boost::crypt::sha3_512_hasher>();
test<boost::crypt::shake128_hasher>();
}
// LCOV_EXCL_STOP
2 changes: 2 additions & 0 deletions test/link_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/crypt/hash/sha512_224.hpp>
#include <boost/crypt/hash/sha512_256.hpp>
#include <boost/crypt/hash/sha3_512.hpp>
#include <boost/crypt/hash/shake128.hpp>

void test_odr_use();

Expand All @@ -34,5 +35,6 @@ void f2()
test<boost::crypt::sha512_224_hasher>();
test<boost::crypt::sha512_256_hasher>();
test<boost::crypt::sha3_512_hasher>();
test<boost::crypt::shake128_hasher>();
}
// LCOV_EXCL_STOP
1 change: 1 addition & 0 deletions test/link_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/crypt/hash/sha512_224.hpp>
#include <boost/crypt/hash/sha512_256.hpp>
#include <boost/crypt/hash/sha3_512.hpp>
#include <boost/crypt/hash/shake128.hpp>

// LCOV_EXCL_START
void f1();
Expand Down

0 comments on commit 5272f79

Please sign in to comment.