DSA.VerifyData Method

Definition

Verifies that a digital signature is valid.

Overloads

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and comparing it to the provided signature.

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

VerifyData(Stream, Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

VerifyData(Stream, Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and comparing it to the provided signature.

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the data in a byte span using the specified hash algorithm and comparing it to the provided signature.

VerifyData(Byte[], Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and comparing it to the provided signature.

VerifyData(Byte[], Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, DSASignatureFormat)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid for the provided data.

C#
public bool VerifyData(byte[] data, int offset, int count, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.DSASignatureFormat signatureFormat);

Parameters

data
Byte[]

An array that contains the signed data.

offset
Int32

The starting index of the signed portion of data.

count
Int32

The number of bytes in data that were signed.

signature
Byte[]

The signature to verify.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to hash the data for the verification process.

signatureFormat
DSASignatureFormat

The encoding format for signature.

Returns

true if the digital signature is valid for the provided data; otherwise, false.

Exceptions

data or signature is null.

signatureFormat is not a known format.

-or- offset is less than zero.

-or- count is less than zero.

-or- offset + count - 1 results in an index that is beyond the upper bound of data.

hashAlgorithm has a null or empty Name.

An error occurred in the hashing or verification operation.

Applies to

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

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and comparing it to the provided signature.

C#
public virtual bool VerifyData(byte[] data, int offset, int count, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);

Parameters

data
Byte[]

The signed data.

offset
Int32

The starting index at which to compute the hash.

count
Int32

The number of bytes to hash.

signature
Byte[]

The signature data to be verified.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value of the data.

Returns

true if the digital signature is valid; otherwise, false.

Exceptions

data is null.

-or-

signature is null.

hashAlgorithm.Name is null or Empty.

offset is less than zero.

-or-

count is less than zero.

-or-

offset + count - 1 results in an index that is beyond the upper bound of data.

The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

Verifying the signature otherwise failed.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid for the provided data.

C#
public bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.DSASignatureFormat signatureFormat);

Parameters

data
ReadOnlySpan<Byte>

The signed data.

signature
ReadOnlySpan<Byte>

The signature to verify.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to hash the data for the verification process.

signatureFormat
DSASignatureFormat

The encoding format for signature.

Returns

true if the digital signature is valid for the provided data; otherwise, false.

Exceptions

signatureFormat is not a known format.

An error occurred in the hashing or verification operation.

Applies to

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

VerifyData(Stream, Byte[], HashAlgorithmName, DSASignatureFormat)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid for the provided data.

C#
public bool VerifyData(System.IO.Stream data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.DSASignatureFormat signatureFormat);

Parameters

data
Stream

The signed data.

signature
Byte[]

The signature to verify.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to hash the data for the verification process.

signatureFormat
DSASignatureFormat

The encoding format for signature.

Returns

true if the digital signature is valid for the provided data; otherwise, false.

Exceptions

data or signature is null.

signatureFormat is not a known format.

hashAlgorithm has a null or empty Name.

An error occurred in the hashing or verification operation.

Applies to

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

VerifyData(Stream, Byte[], HashAlgorithmName)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and comparing it to the provided signature.

C#
public virtual bool VerifyData(System.IO.Stream data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);

Parameters

data
Stream

The signed data.

signature
Byte[]

The signature data to be verified.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value of the data.

Returns

true if the digital signature is valid; otherwise, false.

Exceptions

data is null.

-or-

signature is null.

hashAlgorithm.Name is null or Empty.

The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

Verifying the signature otherwise failed.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid by calculating the hash value of the data in a byte span using the specified hash algorithm and comparing it to the provided signature.

C#
public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);

Parameters

data
ReadOnlySpan<Byte>

The signed data.

signature
ReadOnlySpan<Byte>

The signature to be verified.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value of the data.

Returns

true if the digital signature is valid; otherwise, false.

Exceptions

hashAlgorithm.Name is null or Empty.

The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

Verifying the signature otherwise failed.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

VerifyData(Byte[], Byte[], HashAlgorithmName)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and comparing it to the provided signature.

C#
public bool VerifyData(byte[] data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);

Parameters

data
Byte[]

The signed data.

signature
Byte[]

The signature data to be verified.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value of the data.

Returns

true if the digital signature is valid; otherwise, false.

Exceptions

data is null.

-or-

signature is null.

The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

Verifying the signature otherwise failed.

hashAlgorithm.Name is null or Empty.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

VerifyData(Byte[], Byte[], HashAlgorithmName, DSASignatureFormat)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Verifies that a digital signature is valid for the provided data.

C#
public bool VerifyData(byte[] data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.DSASignatureFormat signatureFormat);

Parameters

data
Byte[]

The signed data.

signature
Byte[]

The signature to verify.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to hash the data for the verification process.

signatureFormat
DSASignatureFormat

The encoding format for signature.

Returns

true if the digital signature is valid for the provided data; otherwise, false.

Exceptions

data or signature is null.

signatureFormat is not a known format.

hashAlgorithm has a null or empty Name.

An error occurred in the hashing or verification operation.

Applies to

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