RSACng.VerifyHash Method

Definition

Overloads

VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

Verifies data that was signed and already hashed with the specified algorithm and padding mode.

VerifyHash(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

Verifies data that was signed and already hashed with the specified algorithm and padding mode.

C#
public override bool VerifyHash(byte[] hash, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

Parameters

hash
Byte[]

The hash to verify.

signature
Byte[]

The signature of the data.

hashAlgorithm
HashAlgorithmName

The hash algorithm name.

padding
RSASignaturePadding

The padding mode.

Returns

true if the signature verifies for the hash; otherwise, false.

Exceptions

hash is null.

-or-

signature is null.

-or-

padding is null.

The value of the Name property of hashAlgorithm is null or Empty.

padding does not equal Pkcs1 or Pss.

-or-

The signature is badly formatted. (In the .NET Framework 4.6 and 4.6.1 only; starting with the .NET Framework 4.6.2, the method returns false if a signature is badly formatted.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, 6, 7, 8, 9, 10
.NET Framework 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
Windows Desktop 3.0, 3.1, 5

VerifyHash(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

C#
public override bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

Parameters

hash
ReadOnlySpan<Byte>

The hash value of the signed data.

signature
ReadOnlySpan<Byte>

The signature data to be verified.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value.

padding
RSASignaturePadding

The padding mode.

Returns

true if the signature is valid; otherwise, false.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10