Issues with RSA.Verify(.Net Core)

  • Thread starter Thread starter Ken Nipper
  • Start date Start date
K

Ken Nipper

Guest
This might not be the right place for this, as I'm targeting .Net Core 3.0 but here goes. I'm working with a 3rd party who sends me a certificate via a byte array. They send me 3 strings in an XML document that include, x509Data, SignatureValue, and DigestValue(for debugging).

They want me to validate that the SignatureValue is valid using the certificate public key contained in the x509Data cert. I'm populating the cert fine but when I try to Verify, it always returns false.

Here is my code:

byte[] SignatureValueBytes = Convert.FromBase64String(Signature.SignatureValue);
byte[] x509DataBytes = Convert.FromBase64String(Signature.x509Data);
byte[] DigestValueBytes = Convert.FromBase64String(Signature.DigestValue);
X509Certificate2 cert = new X509Certificate2(x509DataBytes);
using (RSA RSA = (RSA)cert.PublicKey.Key)
{
bool a = RSA.VerifyData(x509DataBytes, SignatureValueBytes, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}

Signature.* is the string coming from the XML file. Can some kind soul point out where I'm going wrong here?

Continue reading...
 
Back
Top