1#include <xrpl/basics/hardened_hash.h>
3#include <xrpl/beast/hash/hash_append.h>
5#include <gtest/gtest.h>
31 template <
class Hasher>
52 template <
class Hasher>
84template <std::
size_t Bits,
class UInt = std::u
int64_t>
90 "UInt must be an unsigned integral type");
92 static_assert(Bits % (8 *
sizeof(UInt)) == 0,
"Bits must be a multiple of 8*sizeof(UInt)");
94 static_assert(Bits >= (8 *
sizeof(UInt)),
"Bits must be at least 8*sizeof(UInt)");
123 [[nodiscard]]
void const*
129 template <
class Hasher>
148#ifndef __INTELLISENSE__
170 template <
template <
class T>
class U>
195 template <
template <
class T>
class C>
200 C<detail::TestUserTypeMember<std::string>>
const c;
206 C<detail::TestUserTypeFree<std::string>>
const c;
215 checkUserType<detail::TestUserTypeMember>();
216 checkUserType<detail::TestUserTypeFree>();
221 checkContainer<detail::test_hardened_unordered_set>();
222 checkContainer<detail::test_hardened_unordered_map>();
223 checkContainer<detail::test_hardened_unordered_multiset>();
224 checkContainer<detail::test_hardened_unordered_multimap>();
static void checkContainer()
static void checkUserType()
Seed functor once per construction.
static UnsignedInteger fronumber(Int v)
static std::size_t const kBits
static std::size_t const kBytes
std::array< std::size_t, kSize > vec_
friend void hash_append(Hasher &h, UnsignedInteger const &a) noexcept
void const * data() const noexcept
friend std::ostream & operator<<(std::ostream &s, UnsignedInteger const &v)
static std::size_t const kSize
TestUserTypeFree(T const &t=T())
friend void hash_append(Hasher &h, TestUserTypeFree const &a) noexcept
friend void hash_append(Hasher &h, TestUserTypeMember const &a) noexcept
TestUserTypeMember(T const &t=T())
void hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
std::unordered_multiset< T, HardenedHash<> > test_hardened_unordered_multiset
std::unordered_set< T, HardenedHash<> > test_hardened_unordered_set
std::unordered_multimap< T, int, HardenedHash<> > test_hardened_unordered_multimap
std::unordered_map< T, int, HardenedHash<> > test_hardened_unordered_map
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TEST_F(HardenedHashTest, user_types)
UnsignedInteger< 256, std::size_t > sha256_t