473,783 Members | 2,564 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 6308
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
3110
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
3559
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
1994
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
11476
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
2769
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
2266
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
12520
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
3384
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
1719
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
9643
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
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
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
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
6737
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
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.