diff --git a/hash/siphash.cpp b/hash/siphash.cpp index fa79b4a8..a580f674 100644 --- a/hash/siphash.cpp +++ b/hash/siphash.cpp @@ -17,7 +17,7 @@ using cruft::hash::siphash; /////////////////////////////////////////////////////////////////////////////// static constexpr -uint64_t INITIALISERS[4] = { +u64 INITIALISERS[4] = { 0x736f6d6570736575, 0x646f72616e646f6d, 0x6c7967656e657261, @@ -27,7 +27,7 @@ uint64_t INITIALISERS[4] = { /////////////////////////////////////////////////////////////////////////////// static void -round (uint64_t v[4]) +round (u64 v[4]) { using cruft::rotatel; @@ -45,7 +45,7 @@ round (uint64_t v[4]) /////////////////////////////////////////////////////////////////////////////// static -std::array +std::array bytes_to_u64 (std::span val) { u64 r0 = @@ -74,7 +74,7 @@ bytes_to_u64 (std::span val) /////////////////////////////////////////////////////////////////////////////// template -siphash::siphash (std::array _key) noexcept: +siphash::siphash (std::array _key) noexcept: m_key (_key) { ; } @@ -89,10 +89,10 @@ siphash::siphash (std::span _key) noexcept /////////////////////////////////////////////////////////////////////////////// template typename siphash::digest_t -siphash::operator() (cruft::view data) const noexcept +siphash::operator() (cruft::view data) const noexcept { // init - uint64_t state[4] = { + u64 state[4] = { m_key[0] ^ INITIALISERS[0], m_key[1] ^ INITIALISERS[1], m_key[0] ^ INITIALISERS[2], @@ -101,8 +101,8 @@ siphash::operator() (cruft::view data) const noexcept // update auto cursor = data.begin (); - for ( ; data.end () - cursor >= 8; cursor += sizeof (uint64_t)) { - auto word = readle (cursor); + for ( ; data.end () - cursor >= 8; cursor += sizeof (u64)) { + auto word = readle (cursor); state[3] ^= word; for (int c = 0; c < C; ++c) @@ -112,8 +112,8 @@ siphash::operator() (cruft::view data) const noexcept // drain union { - uint64_t d64 = 0; - uint8_t d08[8]; + u64 d64 = 0; + u08 d08[8]; } accum; if (cursor != data.cend ()) { diff --git a/hash/siphash.hpp b/hash/siphash.hpp index 8f661074..4d2174a3 100644 --- a/hash/siphash.hpp +++ b/hash/siphash.hpp @@ -18,17 +18,17 @@ namespace cruft::hash { template class siphash { public: - using digest_t = std::uint64_t; + using digest_t = u64; static constexpr auto compression_rounds = CompressionsV; static constexpr auto finalisation_rounds = FinalisationsV; - siphash (std::array) noexcept; + siphash (std::array) noexcept; siphash (std::span) noexcept; - digest_t operator() (cruft::view data) const noexcept; + digest_t operator() (cruft::view data) const noexcept; private: - std::array m_key; + std::array m_key; }; }; \ No newline at end of file