I am trying to create a signature from a private key that i have been provided and a hashed value. I am using DSA and the following code but receive the following error:
Invalid type specified. source mscorlib
The error is thrown on this line: ImportCspBlob(pk)
Private Function key() As String
Dim privatekey As String = "-----BEGIN DSA PRIVATE KEY-----" _
& "Key Data"
& "-----END DSA PRIVATE KEY-----"
Dim dsa As DSACryptoServiceProvider = New DSACryptoServiceProvider()
Dim pk As Byte() = Encoding.ASCII.GetBytes(privatekey)
dsa.ImportCspBlob(pk)
Dim st As Byte() = Encoding.ASCII.GetBytes("THIS IS THE HASH STRING")))
Dim signedValue As Byte() = dsa.SignHash(st, "SHA1")
Return Encoding.ASCII.GetString(signedValue)
End Function
Can anyone tell me if I am on the right lines herE or am I way out?
Any help on this would be much appreciated.