8#include "Stroika/Foundation/StroikaPreComp.h"
17using namespace Stroika::Foundation::Cryptography;
18using namespace Stroika::Foundation::Cryptography::Digest;
21 inline uint16_t get16bits_ (
const byte* p)
26 case Common::Endian::eLittle:
27 (void)::memcpy (&result, p, 2);
29 case Common::Endian::eBig:
30 result = (to_integer<uint16_t> (p[1]) << 8) + to_integer<uint16_t> (p[0]);
47#if qStroika_Foundation_Debug_AssertionsChecked
48 Require (not fCompleted_);
57 size_t len =
static_cast<size_t> (end - start);
58 Require (len < numeric_limits<uint32_t>::max ());
60 fRemainder_ +=
static_cast<uint32_t
> (len);
62 Assert (0 <= fRemainder_ && fRemainder_ <= 3);
64 const byte* data = start;
70 for (; len > 0; len--) {
71 hash += get16bits_ (data);
72 uint32_t tmp = (get16bits_ (data + 2) << 11) ^ hash;
73 hash = (hash << 16) ^ tmp;
74 data += 2 *
sizeof (uint16_t);
78 Assert (0 <= fRemainder_ and fRemainder_ <= 3);
79 copy (data, data + fRemainder_, fFinalBytes_.data ());
84#if qStroika_Foundation_Debug_AssertionsChecked
85 Require (not fCompleted_);
88 const byte* data = &fFinalBytes_[0];
91 switch (fRemainder_) {
93 hash += get16bits_ (data);
95 hash ^= ((
signed char)data[
sizeof (uint16_t)]) << 18;
99 hash += get16bits_ (data);
104 hash += (
signed char)*data;
#define RequireNotNull(p)
#define AssertNotReached()
DigesterAlgorithm is specialized for each algorithm; generally don't use this directly,...
constexpr Endian GetEndianness()
returns native (std::endian::native) Endianness flag. Can be complicated (mixed, etc)....