#include #include #include "libcrux_sha3_portable.h" using namespace std; typedef vector bytes; vector from_hex(const string& hex) { if (hex.length() % 2 == 1) { throw invalid_argument("Odd-length hex string"); } int len = static_cast(hex.length()) / 2; vector out(len); for (int i = 0; i < len; i += 1) { string byte = hex.substr(2 * i, 2); out[i] = static_cast(strtol(byte.c_str(), nullptr, 16)); } return out; } string bytes_to_hex(const vector& data) { stringstream hex(ios_base::out); hex.flags(ios::hex); for (const auto& byte : data) { hex << setw(2) << setfill('0') << int(byte); } return hex.str(); } TEST(Sha3Test, ConsistencyTest) { const char* message = "Hello, World!"; uint32_t message_size = strlen(message); uint8_t digest[32]; Eurydice_slice input; input.ptr = (void*) message; input.len = message_size; libcrux_sha3_sha256(input,digest); bytes expected_digest = from_hex( "1af17a664e3fa8e419b8ba05c2a173169df76162a5a286e0c405b460d478f7ef"); EXPECT_EQ(strncmp((char*)digest, (char*)expected_digest.data(), 32), 0); }