RSA.TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32) 方法
定义
尝试使用指定的算法对提供的数据进行哈希处理,并使用当前密钥对哈希进行签名,从而将签名写入所提供的缓冲区中。Attempts to hash the provided data with the specified algorithm and sign the hash with the current key, writing the signature into a provided buffer.
public:
virtual bool TrySignData(ReadOnlySpan<System::Byte> data, Span<System::Byte> destination, System::Security::Cryptography::HashAlgorithmName hashAlgorithm, System::Security::Cryptography::RSASignaturePadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TrySignData (ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding, out int bytesWritten);
abstract member TrySignData : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
override this.TrySignData : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
Public Overridable Function TrySignData (data As ReadOnlySpan(Of Byte), destination As Span(Of Byte), hashAlgorithm As HashAlgorithmName, padding As RSASignaturePadding, ByRef bytesWritten As Integer) As Boolean
参数
- data
- ReadOnlySpan<Byte>
要进行哈希处理和签名的输入数据。The input data to hash and sign.
- hashAlgorithm
- HashAlgorithmName
要用于创建数据哈希值的哈希算法。The hash algorithm used to create the hash value of the data.
- padding
- RSASignaturePadding
填充模式。The padding mode.
- 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.
此实例仅表示一个公钥。This instance represents only a public key.
- 或 --or-
创建签名时出错。An error occurred creating the signature.
注解
RSA 签名算法将始终生成与 bits 所需的字节数相等的输出 KeySize 。The RSA signature algorithm will always produce an output equal to the number of bytes required for KeySize bits.