/// <summary> /// Verifies that the base64 encoded signature is valid by comparing the hashed data with the decrypted signature. /// </summary> /// <param name="hashedData">Hashed data to be verified</param> /// <param name="signedHash">Signed hash as byte array</param> /// <param name="publicKey">Public key that is the RSA pair of the private key that signed the message</param> /// <param name="hashAlgorithm">The algorithm used for signing</param> /// <param name="padding">The padding that was used in the signature</param> /// <returns>Return true if data is Verified</returns> /// <exception cref="ArgumentException">There is null in the parameters or one of the parameters empty</exception> /// <exception cref="CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The parameters parameter has missing fields.</exception> public static bool VerifyHash(byte[] data, byte[] signedHash, X509Certificate2 publicKey, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) { return(CertificateCrypto.VerifyHash(data, signedHash, publicKey, hashAlgorithm, padding)); }
/// <summary> /// Verifies that the base64 encoded signature is valid by comparing the hashed data with the decrypted signature. /// </summary> /// <param name="hashedData">Hashed data to be verified</param> /// <param name="encodedsiged">The encoded hashed and signed data</param> /// <param name="publicKey">Public key that is the RSA pair of the private key that signed the message</param> /// <param name="hashAlgorithm">The algorithm used for signing</param> /// <param name="padding">The padding that was used in the signature</param> /// <returns>Return true if data is Verified</returns> /// <exception cref="ArgumentException">There is null in the parameters or one of the parameters empty</exception> /// <exception cref="CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The parameters parameter has missing fields.</exception> public static bool VerifyHash(byte[] data, string encodedSigned, X509Certificate2 publicKey, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) { byte[] signedHash = Convert.FromBase64String(encodedSigned); return(CertificateCrypto.VerifyHash(data, signedHash, publicKey, hashAlgorithm, padding)); }