...
To verify PKCS1 signature
Code Block |
---|
private bool validatePKCS1Signature(string signatureFromAudkenni, string hashStringFromAuthenticationRequest, string certFromAudkenni)
{
byte[] orgHash = null;
byte[] signedHash = null;
byte[] certBytes = null;
X509Certificate2 certificate = null;
try
{
orgHash = Convert.FromBase64String(hashStringFromAuthenticationRequest);
signedHash = Convert.FromBase64String(signatureFromAudkenni);
certBytes = Convert.FromBase64String(certFromAudkenni);
certificate = new X509Certificate2(certBytes);
RSA key = (RSA)certificate.PublicKey.Key;
RSAPKCS1SignatureDeformatter formatter = new RSAPKCS1SignatureDeformatter(key);
formatter.SetHashAlgorithm("SHA512");
var result = formatter.VerifySignature(orgHash, signedHash);
return result;
}
catch (CryptographicException e)
{
return false;
}
} |