A
andrew
Hi,
I have a web service application written in C# .NET 1.1 using
MD5CryptoServiceProvider.ComputeHash(Byte[])
The problem is that after a while(web service processes requests) the call
throws CryptographicException "the parameter is incorrect"
Here's the stack trace:
System.Security.Cryptography.CryptographicException: The parameter is
incorrect.
at System.Security.Cryptography.MD5CryptoServiceProvider._HashData(IntPtr
hHash, Byte[] rgbData, Int32 ibStart, Int32 cbSize)
at System.Security.Cryptography.MD5CryptoServiceProvider.HashCore(Byte[]
rgb, Int32 ibStart, Int32 cbSize)
at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer)
I googled a bit and I found similar (at least the same exception appearing
after a while for no reason) but I also found a KB link:
http://support.microsoft.com/kb/922542
but this is related to BizTalk and the condition that "The .NET assembly
uses the HashMembershipCondition class in the System.Security.Policy
namespace.".
The question is if this is a known bug or something else might happen ?
The code is just a simple singleton class with static data:
public class Encryption
{
static protected MD5CryptoServiceProvider md5;
public static byte[] EncryptionKey = new byte[] { ... };
public static byte[] EncryptionIV = new byte[] { ... };
static Encryption()
{
// Initialize objects
// md5 is used for generating hashes
md5 = new MD5CryptoServiceProvider();
}
static public string Hash(byte[] content)
{
// Compute hash
byte[] rawHash = md5.ComputeHash(content);
<------------------- throws exception
// Convert to base 64
string hash = Convert.ToBase64String(rawHash);
return hash;
}
Thank you.
I have a web service application written in C# .NET 1.1 using
MD5CryptoServiceProvider.ComputeHash(Byte[])
The problem is that after a while(web service processes requests) the call
throws CryptographicException "the parameter is incorrect"
Here's the stack trace:
System.Security.Cryptography.CryptographicException: The parameter is
incorrect.
at System.Security.Cryptography.MD5CryptoServiceProvider._HashData(IntPtr
hHash, Byte[] rgbData, Int32 ibStart, Int32 cbSize)
at System.Security.Cryptography.MD5CryptoServiceProvider.HashCore(Byte[]
rgb, Int32 ibStart, Int32 cbSize)
at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer)
I googled a bit and I found similar (at least the same exception appearing
after a while for no reason) but I also found a KB link:
http://support.microsoft.com/kb/922542
but this is related to BizTalk and the condition that "The .NET assembly
uses the HashMembershipCondition class in the System.Security.Policy
namespace.".
The question is if this is a known bug or something else might happen ?
The code is just a simple singleton class with static data:
public class Encryption
{
static protected MD5CryptoServiceProvider md5;
public static byte[] EncryptionKey = new byte[] { ... };
public static byte[] EncryptionIV = new byte[] { ... };
static Encryption()
{
// Initialize objects
// md5 is used for generating hashes
md5 = new MD5CryptoServiceProvider();
}
static public string Hash(byte[] content)
{
// Compute hash
byte[] rawHash = md5.ComputeHash(content);
<------------------- throws exception
// Convert to base 64
string hash = Convert.ToBase64String(rawHash);
return hash;
}
Thank you.