RSA.TrySignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32) Method

Definition

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

Parameters

hash
ReadOnlySpan<Byte>

The hash value of the data to be signed.

destination
Span<Byte>
hashAlgorithm
HashAlgorithmName

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

padding
RSASignaturePadding

The padding.

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.

padding is unknown, or not supported by this implementation.

-or-

This instance represents only a public key.

-or-

An error occurred creating the signature.

Remarks

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.

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

Applies to

See also