2

Hashlib team,

I am not sure whether the SHA3 library (Keccak) returns correct encryption. I used the latest source code (changeset 78295) downloaded from codeplex but it does not match the vector and result provided in the Wikipedia (sha3 page)

When I use the following code

IHash hash = HashFactory.Crypto.SHA3.CreateKeccak512();
HashResult res = hash.ComputeString("", System.Text.Encoding.ASCII);
string dd = res.ToString();

in my VS 2012 IDE, I am getting a result as

DF987CFD-23FBC92E-7E87FAAC-A300EC3F-AA1DBADC-678E8EE9-4A830968-F22D9209-64AB402D-C5D0F7B2-0C9644BE-08056555-C789D295-8BDA3DF9-8C94BACC-EA25D3C1

This actually should return:

0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e

As per the following post Simple implementation of SHA-3 Keccak hashing to the wrong output in C#? David answered that the latest codebase should return the correct result. I am not sure whether the changes are in place.

When I used the test vector which was taken from the file ExtremelyLongMsgKAT_512.txt

abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno

and using the code

hash.ComputeString("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno").ToString();

the result is also different from the expected. The test vector file says the result would be:

3E122EDAF37398231CFACA4C7C216C9D66D5B899EC1D7AC617C40C7261906A45FC01617A021E5DA3BD8D4182695B5CB785A28237CBB167590E34718E56D8AAB8

However, the actual result was

"B9942109-EB762527-FB384E14-7EDA2DAA-71CA782F-4819B53E-E13C1C13-1C572D99-2B387FA7-212FF624-6EED988D-31AFB23B-4D1B7C44-BC38F908-46EE25F4-AABD5920"
Community
  • 1
  • 1

1 Answers1

0

While I can't speak for Hashlib, ExtremelyLongMsgKAT_512.txt states that the input should be repeated 16777216 times. In my port at https://bitbucket.org/jdluzen/sha3, I included most of the built in tests, including the extremely long ones.

joe
  • 1,125
  • 9
  • 18
  • Yes it looks like after that many repeatations the hash i got is showing correctly. but the problem is it ran for around 3 hours to complete – Albert Arul prakash Aug 25 '13 at 09:33
  • That is a heck of a long time! I'm running in Release mode, WITH the debugger, and it takes around a minute on an i5. Is something else going on? – joe Aug 27 '13 at 01:07
  • can you share the code snippet tat you used, may be my loopings/repeatations might be wrongly done. Also i am on AMD – Albert Arul prakash Sep 02 '13 at 08:40
  • Sure, [here it is in the test app](https://bitbucket.org/jdluzen/sha3/src/d1fd55dc225d18a7fb61515b62d3c8f164d2e788/SHA3Tests/Program.cs?at=default#cl-123). I just continuously pass in the same byte[]. – joe Sep 02 '13 at 19:22