RSA.TrySignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32) 方法
定义
尝试使用当前密钥对哈希进行签名,从而将签名写入到提供的缓冲区中。Attempts to sign the hash with the current key, writing the signature into a provided buffer.
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>
待签名数据的哈希值。The hash value of the data to be signed.
- hashAlgorithm
- HashAlgorithmName
要用于创建数据哈希值的哈希算法。The hash algorithm used to create the hash value of the data.
- padding
- RSASignaturePadding
填充。The padding.
- bytesWritten
- Int32
此方法返回时,为写入 destination 的字节总数。When this method returns, the total number of bytes written into destination. 该参数未经初始化即被处理。This parameter is treated as uninitialized.
返回
如果 destination 的长度不足以接收 RSA 签名,则为 true;否则为 false。true if destination is long enough to receive the RSA signature; otherwise, false.
例外
padding 为 null。padding is null.
padding 未知或不受此实现支持。padding is unknown, or not supported by this implementation.
- 或 --or-
此实例仅表示一个公钥。This instance represents only a public key.
- 或 --or-
创建签名时出错。An error occurred creating the signature.
注解
此方法的默认实现调用 SignHash(Byte[], HashAlgorithmName, RSASignaturePadding) ,并将结果复制到 destination 。The default implementation of this method calls SignHash(Byte[], HashAlgorithmName, RSASignaturePadding) and copies the result to destination.
派生类型应重写此方法,以避免中间数组创建。Derived types should override this method to avoid the intermediate array creation.
RSA 签名算法将始终生成与 bits 所需的字节数相等的输出 KeySize 。The RSA signature algorithm will always produce an output equal to the number of bytes required for KeySize bits.