Rediger

Del via


CoseSign1Message.VerifyDetachedAsync Method

Definition

Asynchronously verifies that the signature is valid for the content using the specified key.

public System.Threading.Tasks.Task<bool> VerifyDetachedAsync (System.Security.Cryptography.AsymmetricAlgorithm key, System.IO.Stream detachedContent, ReadOnlyMemory<byte> associatedData = default, System.Threading.CancellationToken cancellationToken = default);
member this.VerifyDetachedAsync : System.Security.Cryptography.AsymmetricAlgorithm * System.IO.Stream * ReadOnlyMemory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Function VerifyDetachedAsync (key As AsymmetricAlgorithm, detachedContent As Stream, Optional associatedData As ReadOnlyMemory(Of Byte) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)

Parameters

key
AsymmetricAlgorithm

The public key that is associated with the private key that was used to sign the content.

detachedContent
Stream

The content that was previously signed.

associatedData
ReadOnlyMemory<Byte>

The extra data associated with the signature, which must match the value provided during signing.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task whose Task<TResult> property is true if the signature is valid; otherwise, false.

Exceptions

key or detachedContent is null.

key is of an unsupported type.

-or-

detachedContent does not support reading or seeking.

The content is embedded on this message, use an overload that uses embedded content.

ProtectedHeaders does not have a value for the Algorithm header.

-or-

The algorithm protected header was incorrectly formatted.

-or-

The algorithm protected header was not one of the values supported by this implementation.

-or-

The algorithm protected header doesn't match with the algorithms supported by the specified key.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to