Rediger

Del via


RSA.TrySignData Method

Definition

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

Parameters

data
ReadOnlySpan<Byte>

The input data to hash and sign.

destination
Span<Byte>

The buffer to receive the RSA signature.

hashAlgorithm
HashAlgorithmName

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

padding
RSASignaturePadding

The padding mode.

bytesWritten
Int32

When this method returns, the total number of bytes written into destination. This parameter is treated as uninitialized.

Returns

true if destination is long enough to receive the RSA signature; otherwise, false.

Exceptions

padding is null.

hashAlgorithm.Name is null or Empty.

This instance represents only a public key.

-or-

An error occurred creating the signature.

Remarks

The RSA signature algorithm will always produce an output equal to the number of bytes required for KeySize bits.

Applies to

See also