473,472 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

System.Security.Cryptography.CryptographicExceptio n; bug in .NET 1.1 ?

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.CryptographicExceptio n: The parameter is
incorrect.

at System.Security.Cryptography.MD5CryptoServiceProvi der._HashData(IntPtr
hHash, Byte[] rgbData, Int32 ibStart, Int32 cbSize)

at System.Security.Cryptography.MD5CryptoServiceProvi der.HashCore(Byte[]
rgb, Int32 ibStart, Int32 cbSize)

at System.Security.Cryptography.HashAlgorithm.Compute Hash(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.
Jul 31 '07 #1
6 6275
On Jul 31, 11:01 am, "andrew" <myemail@workwrote:
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"
Can you produce a short but complete program which demonstrates the
problem?
Your code doesn't show what content you're trying to pass it - a null
reference, for example.

Jon

Jul 31 '07 #2
I forgot to mention that Im using ASP.NET 1.1.4322 and .NET 1.1 SP1

Meanwhile i found this old KB also: http://support.microsoft.com/kb/319014
but it says it applies to ASP .NET 1.0 i think it should be fixed now.
Jul 31 '07 #3
When the exception is thrown, I stepped into the debugger and the data is
valid.
As I said, the code runs fine but after a while it throws at each call the
CryptographicException.

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...
On Jul 31, 11:01 am, "andrew" <myemail@workwrote:
>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"

Can you produce a short but complete program which demonstrates the
problem?
Your code doesn't show what content you're trying to pass it - a null
reference, for example.

Jon

Jul 31 '07 #4
On Jul 31, 11:21 am, "andrew" <myemail@workwrote:
When the exception is thrown, I stepped into the debugger and the data is
valid.
As I said, the code runs fine but after a while it throws at each call the
CryptographicException.
Does this only occur under heavy load?

You might try serializing the calls to the hashing - use a lock around
the call. If it's due to a race condition, that could sort it out.

Jon

Jul 31 '07 #5
I cannot say if its really a heavy load. It happens after some time.
I start 4 test client applications each one making requests on the web
service. The web service code includes that cryptographic class.

I cant say this is heavy load. If this is not working here, on programming
stage, it sure wont work on the production.

Meanwhile i found a similar post from some time ago about the same problem
on .NET 1.1
http://www.derkeiler.com/Newsgroups/...3-08/0260.html
The guy says this problem can be reproduced. It appears after a large number
of encryption.

A simple fix would be as suggested in the post to recreate the object (it
seems that it had the same behaviour as mine, reusing the provider
instance).

need to know if this a true known bug on .NET 1.1 because I want to
actually know the cause.

thanks.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
On Jul 31, 11:21 am, "andrew" <myemail@workwrote:
>When the exception is thrown, I stepped into the debugger and the data is
valid.
As I said, the code runs fine but after a while it throws at each call
the
CryptographicException.

Does this only occur under heavy load?

You might try serializing the calls to the hashing - use a lock around
the call. If it's due to a race condition, that could sort it out.

Jon

Jul 31 '07 #6
On Jul 31, 12:08 pm, "andrew" <myemail@workwrote:

<snip>
A simple fix would be as suggested in the post to recreate the object (it
seems that it had the same behaviour as mine, reusing the provider
instance).

need to know if this a true known bug on .NET 1.1 because I want to
actually know the cause.
Well, the KB article referred to in the original post suggested that
it was indeed a bug in .NET 1.1, a race condition in the hashing
object.

Jon

Jul 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jasonjbwalton | last post by:
Hi I am implementing a solution based upon Sitecore CMS version 4.3.2.6 ..Net 1.1 on a Windows 2003 server We are experiencing an error once in a while when transforming XML with XSLT. We...
0
by: Andrzej | last post by:
Hi, I have to figure out why we have a problem with special characters in encrypted usernames and passwords. Case: Username: r&bgeorge Password: tigger
0
by: Ebert | last post by:
hi I am just trying out some example in the help, however, it is stranged that I can't imports system.security.cryptography.Xml namespace, I only have cryptography.X509 and the rest but not .XML,...
3
by: segue | last post by:
I have VS 2005, .NET 2.0, no girlfriend and this article: http://msdn2.microsoft.com/en-us/library/ms278836.aspx. Yet, I can't successfully import this namespace. ...
1
by: muthu | last post by:
Hi, I have two web applications running on my machine.The application is developed using asp.net 1.1 and vb.net.When i try to run both the applications in the same browsers, i get the following...
1
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
Hi, everybody here. I am implementing data encryption/decryption, and try to use System.Security.Cryptography.TripleDESCryptoServiceProvider. But I can not find it in MS Visual Studio when I...
1
by: Eric Simmons | last post by:
Hello, I am trying to run a .NET 2.0 application that I developed and I am getting the following error: Key not valid for use in specified state I am attempting to retrieve the...
0
by: Amelyan | last post by:
Why does this happen? How to fix it? Once in a while I get error in ~/ScriptResource.axd?d=... System.Reflection.TargetInvocationException: Exception has been thrown by the target of an...
0
by: a.bavdhankar | last post by:
Hi, I am using System.Security.Cryptography.RijndaelManaged in web application that is executed under annonymous user. I am getting access denied error message. It seems annonymous user does...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.