RSA.TrySignHash 方法

定义

尝试使用当前密钥对哈希进行签名,从而将签名写入到提供的缓冲区中。

public:
 virtual bool TrySignHash(ReadOnlySpan<System::Byte> hash, Span<System::Byte> destination, System::Security::Cryptography::HashAlgorithmName hashAlgorithm, System::Security::Cryptography::RSASignaturePadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TrySignHash (ReadOnlySpan<byte> hash, Span<byte> destination, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding, out int bytesWritten);
abstract member TrySignHash : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
override this.TrySignHash : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
Public Overridable Function TrySignHash (hash As ReadOnlySpan(Of Byte), destination As Span(Of Byte), hashAlgorithm As HashAlgorithmName, padding As RSASignaturePadding, ByRef bytesWritten As Integer) As Boolean

参数

hash
ReadOnlySpan<Byte>

待签名数据的哈希值。

destination
Span<Byte>

要接收 RSA 签名的缓冲区。

hashAlgorithm
HashAlgorithmName

要用于创建数据哈希值的哈希算法。

padding
RSASignaturePadding

填充。

bytesWritten
Int32

此方法返回时,为写入 destination 的字节总数。 该参数未经初始化即被处理。

返回

如果 destination 的长度不足以接收 RSA 签名,则为 true;否则为 false

例外

padding 上声明的默认值为 null

hashAlgorithm.NamenullEmpty

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

注解

此方法的默认实现调用 SignHash(Byte[], HashAlgorithmName, RSASignaturePadding) 并将结果复制到 destination。 派生类型应重写此方法,以避免创建中间数组。

RSA 签名算法将始终生成等于位所需的 KeySize 字节数的输出。

适用于

另请参阅