Hi,
I have a problem with HMACSHA512 ComputeHash fnction. I need to get same
result on every computer that runs my software.
But I have got different result on two computers (on other 20 results are
correct). They are using same version, same function with same parameters
and this begin to happen this week.
Is this a bug?
What hash function will produce same result on different computers with
different OSs?
My code:
public static string HashIt(byte[] hashKey, byte[] myKey,
HashEncryptionType hashType)
{
System.Security.Cryptography.HMAC hash;
switch (hashType)
{
case HashEncryptionType.SHA1:
hash = new HMACSHA1(hashKey);
break;
case HashEncryptionType.SHA256:
hash = new HMACSHA256(hashKey);
break;
case HashEncryptionType.SHA384:
hash = new HMACSHA384(hashKey);
break;
case HashEncryptionType.SHA512:
hash = new HMACSHA512(hashKey);
break;
default:
hash = new HMACSHA512(hashKey);
break;
}
hash.ComputeHash(myKey);
string hashedBytes = Convert.ToBase64String(hash.Hash);
hash.Clear();
return hashedBytes;
}
Nikolay Unguzov
Nikolay Unguzov - 12 Dec 2007 17:14 GMT
The problem is caused by microsoft update: .NET 2.0 SP1
In .NET 2.0 SP1 HMAC SHA1 and SHA256 returns same values as in .NET 2.0, but
SHA384 and SHA512 returns different values...
I'm not sure if this is new bug, or fix of old bug, but I'm sure that this
is nod a good policy.
Nikolay Unguzov
> Hi,
>
[quoted text clipped - 44 lines]
>
> Nikolay Unguzov
Dominick Baier - 20 Dec 2007 01:39 GMT
have a look here:
http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-h
macsha512-and-hmacsha384-classes.aspx
-----
Dominick Baier (http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
> The problem is caused by microsoft update: .NET 2.0 SP1
>
[quoted text clipped - 50 lines]
>> }
>> Nikolay Unguzov