Groups | Blog | Home
all groups > dotnet security > december 2006 >

dotnet security : Digitally Sign a file


msnews.microsoft.com
12/10/2006 12:45:20 AM
I encountered a very weird scenario with the following code:

CspParameters csp = new CspParameters(1, "Tev CSP v3.0");
csp.KeyNumber = 2;

RSACryptoServiceProvider rsa = new
RSACryptoServiceProvider(csp);
byte[] data = new byte[2];
data[0] = 0;
data[1] = 1;

byte[] sig = rsa.SignData(data, "SHA1");

I m trying to sign a data using a certificate that resides in a smart card.
The above code works perfectly well with .NET framework 1.1. However, when i
compile and run it on .NET framework 2.0, exception was caught when calling
byte[] sig = rsa.SignData(data, "SHA1");

The error is as follow :

An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll
Additional information: The keyset is not defined.

Any idea why this happened ? Thanks.

msnews.microsoft.com
12/10/2006 1:28:12 AM
Sorry.. the error message is:

An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll
Additional information: The parameter is incorrect.


[quoted text, click to view]

AddThis Social Bookmark Button