HighTechTalks DotNet Forums  

HMACSHA512 ComputeHash - workstation or OS depended?!?

Dotnet Security microsoft.public.dotnet.security


Discuss HMACSHA512 ComputeHash - workstation or OS depended?!? in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
news.microsoft.com
 
Posts: n/a

Default HMACSHA512 ComputeHash - workstation or OS depended?!? - 12-12-2007 , 11:16 AM






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



Reply With Quote
  #2  
Old   
Nikolay Unguzov
 
Posts: n/a

Default UPDATE: HMACSHA512 ComputeHash - workstation or OS depended?!? - 12-12-2007 , 12:14 PM






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


"news.microsoft.com" <unguzov (AT) abv (DOT) bg> wrote

Quote:
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




Reply With Quote
  #3  
Old   
Dominick Baier
 
Posts: n/a

Default Re: UPDATE: HMACSHA512 ComputeHash - workstation or OS depended?!? - 12-19-2007 , 08:39 PM



have a look here:

http://blogs.msdn.com/shawnfa/archiv...4-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)

Quote:
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

"news.microsoft.com" <unguzov (AT) abv (DOT) bg> wrote in message
news:eJbhBpNPIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...

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




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.