4
Is returning error from Invalid algorithm Specified, when it will be signed, how to proceed?
Dim data = Encoding.UTF8.GetBytes(Me.txtCNPJEmpresa.Text + Me.txtCNPJSoftwareHouse.Text)
Dim csp As RSACryptoServiceProvider = DirectCast(Certificado.PrivateKey, RSACryptoServiceProvider)
Dim sha As SHA256 = SHA256Managed.Create()
Dim hash As Byte() = New Byte() {}
hash = sha.ComputeHash(data)
Dim encrypted As Byte() = csp.SignHash(hash, "SHA256")
Which line returned error? Which Exception returned (not just the message)? Which version of . Net used?
– Vinícius Gobbo A. de Oliveira
On the signature line, when will you add the key in the Encrypted variable, VS12
– Felipe S
Are you sure this is how you sign? SHA-256 is a hash algorithm, not a digital signature, but it is used on other signature algorithms, such as the HMAC-SHA256 (although you wouldn’t believe it to be your case). You wouldn’t be looking for the
RSAPKCS1SignatureFormatter
? Behold that example. It’s very common - when you want to sign an arbitrary data - first hash this data and then sign the hash, this is used in several protocols, I just don’t know if it applies to your case.– mgibsonbr
So when I use the SHA1 standard, changing only the classes, sure, but when I use SHA256 of this error, because all the researches I did the guys uses this model that I mentioned above, not to mention that besides I have to generate in SHA256 I have to sign using my digital certificate.
– Felipe S
@Felipewalleg The about the digital certificate, would be the new version of certificates? There are certificates chain v2 and v3. If I’m not mistaken, this month or last month have changed the chain of digital certificates. Check if the certificate is G2,G5... G7, because the version G7(V3) are having some problems giving error in the validation of it. I don’t know if it involves the same problem with your signature, but it follows one of the problems I’ve had around here about signatures and have been solved, If that is, I put as answer the resolution of the problem.
– Daniel Nicodemos