DSA.VerifyData 方法

定义

验证数字签名有效。Verifies that a digital signature is valid.

重载

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(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[], 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(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.

public:
 bool VerifyData(cli::array <System::Byte> ^ data, cli::array <System::Byte> ^ signature, System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public bool VerifyData (byte[] data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
member this.VerifyData : byte[] * byte[] * System.Security.Cryptography.HashAlgorithmName -> bool
Public Function VerifyData (data As Byte(), signature As Byte(), hashAlgorithm As HashAlgorithmName) As Boolean

参数

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.

返回

如果数字签名有效,则为 true;否则为 falsetrue if the digital signature is valid; otherwise, false.

异常

datanulldata is null.

-or- signaturenullsignature is null.

实现类型仅支持旧版 DSA (FIPS 186-2),哈希算法不是 SHA-1。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.NamehashAlgorithm.Name nullEmptyis null or Empty.

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.

public:
 virtual bool VerifyData(System::IO::Stream ^ data, cli::array <System::Byte> ^ signature, System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public virtual bool VerifyData (System.IO.Stream data, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
abstract member VerifyData : System.IO.Stream * byte[] * System.Security.Cryptography.HashAlgorithmName -> bool
override this.VerifyData : System.IO.Stream * byte[] * System.Security.Cryptography.HashAlgorithmName -> bool
Public Overridable Function VerifyData (data As Stream, signature As Byte(), hashAlgorithm As HashAlgorithmName) As Boolean

参数

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.

返回

如果数字签名有效,则为 true;否则为 falsetrue if the digital signature is valid; otherwise, false.

异常

datanulldata is null.

-or- signaturenullsignature is null.

hashAlgorithm.NamehashAlgorithm.Name nullEmptyis null or Empty.

实现类型仅支持旧版 DSA (FIPS 186-2),哈希算法不是 SHA-1。The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

验证签名失败。Verifying the signature otherwise failed.

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.

public:
 virtual bool VerifyData(ReadOnlySpan<System::Byte> data, ReadOnlySpan<System::Byte> signature, System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public virtual bool VerifyData (ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
abstract member VerifyData : ReadOnlySpan<byte> * ReadOnlySpan<byte> * System.Security.Cryptography.HashAlgorithmName -> bool
override this.VerifyData : ReadOnlySpan<byte> * ReadOnlySpan<byte> * System.Security.Cryptography.HashAlgorithmName -> bool
Public Overridable Function VerifyData (data As ReadOnlySpan(Of Byte), signature As ReadOnlySpan(Of Byte), hashAlgorithm As HashAlgorithmName) As Boolean

参数

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.

返回

如果数字签名有效,则为 true;否则为 falsetrue if the digital signature is valid; otherwise, false.

异常

hashAlgorithm.NamehashAlgorithm.Name nullEmptyis null or Empty.

实现类型仅支持旧版 DSA (FIPS 186-2),哈希算法不是 SHA-1。The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

- 或 --or-

验证签名失败。Verifying the signature otherwise failed.

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.

public:
 virtual bool VerifyData(cli::array <System::Byte> ^ data, int offset, int count, cli::array <System::Byte> ^ signature, System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public virtual bool VerifyData (byte[] data, int offset, int count, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
abstract member VerifyData : byte[] * int * int * byte[] * System.Security.Cryptography.HashAlgorithmName -> bool
override this.VerifyData : byte[] * int * int * byte[] * System.Security.Cryptography.HashAlgorithmName -> bool
Public Overridable Function VerifyData (data As Byte(), offset As Integer, count As Integer, signature As Byte(), hashAlgorithm As HashAlgorithmName) As Boolean

参数

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.

返回

如果数字签名有效,则为 true;否则为 falsetrue if the digital signature is valid; otherwise, false.

异常

datanulldata is null.

-or- signaturenullsignature is null.

hashAlgorithm.NamehashAlgorithm.Name nullEmptyis null or Empty.

offset 小于零。offset is less than zero.

-or- count 小于零。count is less than zero.

-or- offset + count - 1 会导致超出 data 上限的索引。offset + count - 1 results in an index that is beyond the upper bound of data.

实现类型仅支持旧版 DSA (FIPS 186-2),哈希算法不是 SHA-1。The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.

-or-

验证签名失败。Verifying the signature otherwise failed.

适用于