Trying to sign a hash
Hi all:
I am trying to perform a PKCS#1 Hash Sign with a RSA key.
I am currently trying to do this:
Dim store As Microsoft.Web.Services2.Security.X509.X509Certific ateStore =
Microsoft.Web.Services2.Security.X509.X509Certific ateStore.CurrentUserStore(Microsoft.Web.Services2. Security.X509.X509CertificateStore.MyStore)
store.Open()
Dim cert As Microsoft.Web.Services2.Security.X509.X509Certific ate =
store.Certificates(0)
Dim RSA As System.Security.Cryptography.RSA = cert.Key
Dim Crypt As New
System.Security.Cryptography.RSAPKCS1SignatureForm atter(RSA)
Dim hash As New System.Security.Cryptography.MD5CryptoServiceProvi der()
Dim hashed As Byte()
Dim Cypher As Byte()
Dim enc As System.Text.Encoding
hashed = hash.ComputeHash(enc.ASCII.GetBytes("Hi"))
Crypt.SetHashAlgorithm("MD5")
Cypher = Crypt.CreateSignature(hashed)
Everything goes fine until the last line, when it throws an 'DecryptValue'
not supported exception.
I think I am very close to do my task, but I can't solve that error.
Any clues? Thank you.
|