473,672 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Security .Cryptography.C ryptographicExc eption; bug in .NET 1.1 ?

Hi,
I have a web service application written in C# .NET 1.1 using
MD5CryptoServic eProvider.Compu teHash(Byte[])

The problem is that after a while(web service processes requests) the call
throws CryptographicEx ception "the parameter is incorrect"

Here's the stack trace:

System.Security .Cryptography.C ryptographicExc eption: The parameter is
incorrect.

at System.Security .Cryptography.M D5CryptoService Provider._HashD ata(IntPtr
hHash, Byte[] rgbData, Int32 ibStart, Int32 cbSize)

at System.Security .Cryptography.M D5CryptoService Provider.HashCo re(Byte[]
rgb, Int32 ibStart, Int32 cbSize)

at System.Security .Cryptography.H ashAlgorithm.Co mputeHash(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 HashMembershipC ondition 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 MD5CryptoServic eProvider 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 MD5CryptoServic eProvider();

}

static public string Hash(byte[] content)

{

// Compute hash

byte[] rawHash = md5.ComputeHash (content);
<------------------- throws exception

// Convert to base 64

string hash = Convert.ToBase6 4String(rawHash );

return hash;

}

Thank you.
Jul 31 '07 #1
6 6297
On Jul 31, 11:01 am, "andrew" <myemail@workwr ote:
I have a web service application written in C# .NET 1.1 using
MD5CryptoServic eProvider.Compu teHash(Byte[])

The problem is that after a while(web service processes requests) the call
throws CryptographicEx ception "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
CryptographicEx ception.

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@d 55g2000hsg.goog legroups.com...
On Jul 31, 11:01 am, "andrew" <myemail@workwr ote:
>I have a web service application written in C# .NET 1.1 using
MD5CryptoServi ceProvider.Comp uteHash(Byte[])

The problem is that after a while(web service processes requests) the
call
throws CryptographicEx ception "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@workwr ote:
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
CryptographicEx ception.
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.co mwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 31, 11:21 am, "andrew" <myemail@workwr ote:
>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
CryptographicE xception.

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@workwr ote:

<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
3078
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 receive an exception System.Security.Cryptography.CryptographicException (incorrect parameter)
0
3544
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
1981
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, do I miss something? I am using VS2003 with .net framework 1.1.4322, can anyone please help Thank you, Ebert
3
11464
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. System.Security.Cryptography.Xml. error message:
1
2759
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 error. (System.Security.Cryptography.CryptographicException: Bad Data. at System.Security.Cryptography.CryptoAPITransform._DecryptData(IntPtr hKey, Byte rgb, Int32 ib, Int32 cb, Boolean fDone) at...
1
2249
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 wrote code like (C#) using System.Security.Cryptography.TripleDESCryptoServiceProvider; Under System.Security.Cryptography, only have X509Certificates.
1
12508
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 X509Certificate2.PrivateKey as an XML string via the ToXmlString() function and this error occurs. Below is an example of the command line call that I used to make my test
0
3364
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 invocation. ---> System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at
0
1709
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 not have access to a specific registry but i am unable to figure it out which registry setting i must look upon. Annonymous user is member of guest account only.
0
8486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8608
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.