Click or drag to resize
MimeKit

OpenPgpContextDecryptTo Method

Decrypt an encrypted stream and extract the digital signers if the content was also signed.

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public DigitalSignatureCollection DecryptTo(
	Stream encryptedData,
	Stream decryptedData,
	CancellationToken cancellationToken = default
)

Parameters

encryptedData  Stream
The encrypted data.
decryptedData  Stream
The stream to write the decrypted data to.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

DigitalSignatureCollection
The list of digital signatures if the data was both signed and encrypted; otherwise, null.
Exceptions
ExceptionCondition
ArgumentNullException

encryptedData is null.

-or-

decryptedData is null.

PrivateKeyNotFoundException The private key could not be found to decrypt the stream.
OperationCanceledException

The user chose to cancel the password prompt.

-or-

The operation was canceled via the cancellation token.

UnauthorizedAccessException 3 bad attempts were made to unlock the secret key.
PgpException An OpenPGP error occurred.
Remarks

Decrypts an encrypted stream and extracts the digital signers if the content was also signed.

If any of the signatures were made with an unrecognized key and AutoKeyRetrieve is enabled, an attempt will be made to retrieve said key(s). The cancellationToken can be used to cancel key retrieval.

See Also