Re: Exception applying Digital Signature in VS.NET



Thanks for your cooperation.
I changed the code and declared the two Byte array in the same way (to
be sure I tried one time with dim XXX() as byte and another time with
dim XXX as byte()).
Unfortunately, I receive the same exception.

Alexpicchio



DXRick ha scritto:

I am not a VB pro, but this looks fishy:

Dim originalData As Byte() = ByteConverter.GetBytes(dataString)
Dim signedData() As Byte

You have declared a Byte array in two different ways.


"alexpicchio@xxxxxxxxxx" wrote:

Hi!
I'm trying to apply a digital signature using a SYSGILLO CSP Provider
in the Visual Studio .NET environment (framework 1.1/2.0).

When I run the following code, the program prompts me for PIN and then
I receive the following
exception at the last line of the code below (rsa.SignData).

An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll
Additional information: The operation completed successfully.

This is my code:

' Create a new CspParameters object that identifies a
type_provider = 1
name_provider = "SysGillo Cryptographic Service Provider"
Dim csp As New CspParameters(type_provider, name_provider)

csp.Flags = CspProviderFlags.UseDefaultKeyContainer

' Specify a signature key (digital signature)
csp.KeyNumber = 2

' Initialize an RSACryptoServiceProvider object using the
CspParameters object.
Dim rsa As New RSACryptoServiceProvider(csp)

' Create a UnicodeEncoder to convert between byte array and
string.
Dim ByteConverter As New ASCIIEncoding()

Dim dataString As String = "Data to Sign"

' Create byte arrays to hold original, encrypted, and decrypted
data.
Dim originalData As Byte() = ByteConverter.GetBytes(dataString)
Dim signedData() As Byte

' Hash and sign the data.
signedData = rsa.SignData(originalData, New
SHA1CryptoServiceProvider())


Can anyone help me?

Thanks to all.
Alexpicchio



.



Relevant Pages

  • Re: Detecting a running process.
    ... Private Declare Function EnumProcessModules Lib "psapi.dll" _ ... (ByVal dwProcessID As Long, _ ... Dim nProcesses As Long ... 'fill an array of longs with the ...
    (microsoft.public.vb.winapi)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Max/Min Functions
    ... You said the Array function won't work here. ... Dim myArray() As Variant ... > Dim vMax As Variant ...
    (microsoft.public.word.vba.general)