Import build time tiger hasd from doorkeeper
This commit is contained in:
parent
db554b8b85
commit
d3731253e4
4 changed files with 612 additions and 0 deletions
|
@ -8,6 +8,7 @@ add_executable(${PROJECT_NAME}
|
|||
bitfield_pack_test.cpp
|
||||
resource_pool_test.cpp
|
||||
version_test.cpp
|
||||
tiger_test.cpp
|
||||
)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
|
54
test/unit/tiger_test.cpp
Normal file
54
test/unit/tiger_test.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* Copyright 2016-2021 Michele Santullo
|
||||
* This file is part of "duckhandy".
|
||||
*
|
||||
* "duckhandy" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "duckhandy" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "duckhandy". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "catch2/catch.hpp"
|
||||
#include "duckhandy/tiger_bt.hpp"
|
||||
|
||||
TEST_CASE("Build-time Tiger hash tests", "[hash][bt][tiger]") {
|
||||
using dk::tiger;
|
||||
using dk::HashType;
|
||||
|
||||
constexpr HashType h1 = tiger("", 0, 0x80); //v2
|
||||
CHECK(h1.a == 0x738701f675be4144);
|
||||
CHECK(h1.b == 0x924b374527c206c2);
|
||||
CHECK(h1.c == 0x419f91ef3f31a84a);
|
||||
|
||||
constexpr HashType h2 = tiger("", 0, 0x01); //v1
|
||||
CHECK(h2.a == 0x24f0130c63ac9332);
|
||||
CHECK(h2.b == 0x16166e76b1bb925f);
|
||||
CHECK(h2.c == 0xf373de2d49584e7a);
|
||||
|
||||
constexpr HashType h3 = tiger("message digest", 14, 0x80); //v2
|
||||
CHECK(h3.a == 0x9d25fab5a11994e2);
|
||||
CHECK(h3.b == 0xea7850e77d5e00e8);
|
||||
CHECK(h3.c == 0x2d465225ef42a581);
|
||||
|
||||
constexpr HashType h4 = tiger("message digest", 14, 0x01); //v1
|
||||
CHECK(h4.a == 0x951a2078cbf881d9);
|
||||
CHECK(h4.b == 0x1c441e754830cf0d);
|
||||
CHECK(h4.c == 0xf6295aa51aca7f51);
|
||||
|
||||
constexpr HashType h5 = tiger("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x80); //v2
|
||||
CHECK(h5.a == 0x517bee8c22b69aea);
|
||||
CHECK(h5.b == 0x8c6c06a6fc4475b7);
|
||||
CHECK(h5.c == 0xcd059531e6ba5bbb);
|
||||
|
||||
constexpr HashType h6 = tiger("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x01); //v1
|
||||
CHECK(h6.a == 0xee8375a180a6ce8d);
|
||||
CHECK(h6.b == 0x5186363c8aa32b50);
|
||||
CHECK(h6.c == 0xcca849dcccfb0f89);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue