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.

destination
Span<Byte>

要接收 RSA 簽章的緩衝區。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.

bytesWritten
Int32

當這個方法傳回時,寫入 destination 的位元組總數。When this method returns, the total number of bytes written into destination. 這個參數會被視為未初始化。This parameter is treated as uninitialized.

傳回

Boolean

如果 destination 的長度足以接收 RSA 簽章,則為 true;否則為 falsetrue if destination is long enough to receive the RSA signature; otherwise, false.

例外狀況

paddingnullpadding is null.

hashAlgorithm.NamehashAlgorithm.Name nullEmptyis null or Empty.

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) 並將結果複製到 destinationThe 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 所需位元組數目的輸出 KeySizeThe RSA signature algorithm will always produce an output equal to the number of bytes required for KeySize bits.

適用於

另請參閱