Fix the build time implementation of tiger hash.
Result for "message digest", "abc" and "" are correct.
This commit is contained in:
parent
caa0a683fb
commit
6a39b82e5e
2 changed files with 26 additions and 2 deletions
|
@ -425,7 +425,7 @@ namespace dk {
|
|||
constexpr HashType tiger_block (const TigerBlock& parBlock, HashType parHash) {
|
||||
return finalize_tiger_step(
|
||||
parHash,
|
||||
pass(1, 2, 0, 9, key_sched(parBlock),
|
||||
pass(1, 2, 0, 9, key_sched(key_sched(parBlock)),
|
||||
pass(2, 0, 1, 7, key_sched(parBlock),
|
||||
pass(0, 1, 2, 5, parBlock, parHash)
|
||||
)
|
||||
|
@ -467,7 +467,7 @@ namespace dk {
|
|||
parLen,
|
||||
implem::tiger_chunk(
|
||||
parStr,
|
||||
parLen bitand static_cast<uint64_t>(-64),
|
||||
parLen bitand ~static_cast<uint64_t>(0x3f),
|
||||
HashType(0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL, 0xF096A5B4C3B2E187ULL)
|
||||
),
|
||||
parPad
|
||||
|
|
|
@ -44,6 +44,30 @@ namespace {
|
|||
int main() {
|
||||
static constexpr auto h = dk::tiger("message digest", 14, 0x01);
|
||||
std::cout << std::hex << h.a << '\n' << 0x951A2078CBF881D9ULL << std::endl;
|
||||
|
||||
static constexpr auto h2 = dk::tiger("abc", 3, 0x01);
|
||||
std::cout << std::hex << h2.a << '\n' << 0xF258C1E88414AB2AULL << std::endl;
|
||||
|
||||
static constexpr auto h3 = dk::tiger("", 0, 0x01);
|
||||
std::cout << std::hex << h3.a << '\n' << 0x24F0130C63AC9332ULL << std::endl;
|
||||
|
||||
{
|
||||
static constexpr dk::HashType hashtest(1, 2, 3);
|
||||
static_assert(hashtest.a == 1, "wrong value");
|
||||
static_assert(hashtest.b == 2, "wrong value");
|
||||
static_assert(hashtest.c == 3, "wrong value");
|
||||
}
|
||||
{
|
||||
static constexpr dk::HashType hashtest(2, 'c', 0, 'a', 1, 'b');
|
||||
static_assert(hashtest.a == 'a', "wrong value");
|
||||
static_assert(hashtest.b == 'b', "wrong value");
|
||||
static_assert(hashtest.c == 'c', "wrong value");
|
||||
}
|
||||
{
|
||||
const uint64_t test = *reinterpret_cast<const uint64_t*>("A\0\0\0\0\0\0");
|
||||
if ((test & 0xFF) != 'A')
|
||||
throw 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
typedef dk::Tyler<2>::coords coords2;
|
||||
|
|
Loading…
Reference in a new issue