I am trying to run Keccak 224 with this official library. Unfortunately I get a wrong hash from the function. I doubt that it is the fault of the library, rather I do something wrong.
This is what I am trying:
unsigned char input[] = "abc", output[168];
const unsigned long long int inputByteLen = sizeof(input);
FIPS202_SHA3_224(input, inputByteLen, output);
std::stringstream stream;
for (unsigned int i = 0; i < sizeof(output); i++) {
stream << std::hex << static_cast<short>(output[i]);
}
cout << stream.str() << endl;
The correct hash for "abc" with SHA-3-224 (Keccak) should be:
e642824c3f8cf24a d09234ee7d3c766f c9a3a5168d0c94ad 73b46fdf
But I only get nonsense from this way of calling the library. What am I doing wrong? A small example would be great which explains me how I can achieve the expected result and what I was doing wrong.
Have you taken into consideration the null character at the end?
const unsigned long long int inputByteLen = sizeof(input) - 1;