SHA 256 .NET vs FIPS-180-2 compliant SHA-256

  • Thread starter Thread starter Ravi Singh (UCSD)
  • Start date Start date
R

Ravi Singh (UCSD)

Hello all


I am trying to compare the SHA 256 algorithm as implemented by
Christophe Devine and on using the .NET "SHA256Managed" but they do not
give me similar hashes.


Here is the Christophes implementation .


http://www.cr0.net:8040/code/crypto/sha256/


In .NET
SHA256Managed sha256 = new SHA256Managed();
sha256.ComputeHash( Encoding.ASCII.GetBytes("jonny") );
but I do not get similar hashes. Any ideas?


Thanks


Ravi Singh
 
Ravi Singh (UCSD) said:
I am trying to compare the SHA 256 algorithm as implemented by
Christophe Devine and on using the .NET "SHA256Managed" but they do not
give me similar hashes.


Here is the Christophes implementation .


http://www.cr0.net:8040/code/crypto/sha256/


In .NET
SHA256Managed sha256 = new SHA256Managed();
sha256.ComputeHash( Encoding.ASCII.GetBytes("jonny") );
but I do not get similar hashes. Any ideas?

Well, the two test strings in the C source seem to give the expected
results... what are you getting as the hash from each?
 
Thank you for replying .

7a29dc9b52b3e44eef25e0441853324c97489f5e626fc1aa97e4ede646b50a45 ---
thats with the FIPS-180-2 compliant SHA-256 Christophes implementation

0fae56d5786cade88b348cf55a9e4a217406ff5359e517cddf9fea2bb686ea6f on
..NET C# after converting it to a HEX string.

is C# not FIPS-180-2 compliant or is there some other problem.
Ravi Singh.
 
Ravi Singh (UCSD) said:
Thank you for replying .

7a29dc9b52b3e44eef25e0441853324c97489f5e626fc1aa97e4ede646b50a45 ---
thats with the FIPS-180-2 compliant SHA-256 Christophes implementation

0fae56d5786cade88b348cf55a9e4a217406ff5359e517cddf9fea2bb686ea6f on
.NET C# after converting it to a HEX string.

is C# not FIPS-180-2 compliant or is there some other problem.
Ravi Singh.

Having compiled the C code myself now, I'm getting the same result as
..NET is (ie 0fae...)

It looks like you're doing something wrong on the C side.

(I tested it by just taking the sample code, adding "jonny" as an extra
test, and making it print out the output of the test.)
 
Thank you very much for your time and answers, it seems the error was
on my side. My understanding of the FIPS-180-2 spec was a little off.
Ravi Singh.
 
Back
Top