EnvelopedCms.Decrypt Method

Definition

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message.

Overloads

Decrypt(RecipientInfo, X509Certificate2Collection)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info by searching certificate stores and a provided collection for a matching certificate and key.

Decrypt(RecipientInfo, AsymmetricAlgorithm)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info with a specified private key.

Decrypt()

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via any available recipient by searching certificate stores for a matching certificate and key.

Decrypt(RecipientInfo)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info by searching certificate stores for a matching certificate and key.

Decrypt(X509Certificate2Collection)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via any available recipient info by searching certificate stores and a provided collection for a matching certificate and key.

Decrypt(RecipientInfo, X509Certificate2Collection)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info by searching certificate stores and a provided collection for a matching certificate and key.

public:
 void Decrypt(System::Security::Cryptography::Pkcs::RecipientInfo ^ recipientInfo, System::Security::Cryptography::X509Certificates::X509Certificate2Collection ^ extraStore);
public void Decrypt (System.Security.Cryptography.Pkcs.RecipientInfo recipientInfo, System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore);
member this.Decrypt : System.Security.Cryptography.Pkcs.RecipientInfo * System.Security.Cryptography.X509Certificates.X509Certificate2Collection -> unit
Public Sub Decrypt (recipientInfo As RecipientInfo, extraStore As X509Certificate2Collection)

Parameters

recipientInfo
RecipientInfo

The recipient info to use for decryption.

extraStore
X509Certificate2Collection

A collection of certificates to use in addition to the certificate stores for finding a recipient certificate and private key.

Exceptions

The recipientInfo or extraStore parameter is null.

A cryptographic operation could not be completed.

A method call was invalid for the object's current state.

Remarks

.NET Framework Security

The following permissions are required to access the decryption key:

Applies to

Decrypt(RecipientInfo, AsymmetricAlgorithm)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info with a specified private key.

public:
 void Decrypt(System::Security::Cryptography::Pkcs::RecipientInfo ^ recipientInfo, System::Security::Cryptography::AsymmetricAlgorithm ^ privateKey);
public void Decrypt (System.Security.Cryptography.Pkcs.RecipientInfo recipientInfo, System.Security.Cryptography.AsymmetricAlgorithm privateKey);
public void Decrypt (System.Security.Cryptography.Pkcs.RecipientInfo recipientInfo, System.Security.Cryptography.AsymmetricAlgorithm? privateKey);
member this.Decrypt : System.Security.Cryptography.Pkcs.RecipientInfo * System.Security.Cryptography.AsymmetricAlgorithm -> unit
Public Sub Decrypt (recipientInfo As RecipientInfo, privateKey As AsymmetricAlgorithm)

Parameters

recipientInfo
RecipientInfo

The recipient info to use for decryption.

privateKey
AsymmetricAlgorithm

The private key to use to decrypt the recipient-specific information.

Exceptions

The recipientInfo or privateKey parameter is null.

A cryptographic operation could not be completed.

A method call was invalid for the object's current state.

Remarks

Unlike the other overloads of Decrypt, this overload does not search certificate stores. The MatchesCertificate(X509Certificate2) method can be used to manually match an expected certificate to the RecipientInfo.RecipientIdentifier value to evaluate the applicability of the private key to the recipient info value.

See also

Applies to

Decrypt()

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via any available recipient by searching certificate stores for a matching certificate and key.

public:
 void Decrypt();
public void Decrypt ();
member this.Decrypt : unit -> unit
Public Sub Decrypt ()

Exceptions

A cryptographic operation could not be completed.

A method call was invalid for the object's current state.

Remarks

EnvelopedCms.Decode should be called before EnvelopedCms.Decrypt() or any other Decrypt method.

The Decrypt() method does not search the computer My store if it is inaccessible.

.NET Framework Security

The following permissions are required to access the decryption key:

Applies to

Decrypt(RecipientInfo)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via a specified recipient info by searching certificate stores for a matching certificate and key.

public:
 void Decrypt(System::Security::Cryptography::Pkcs::RecipientInfo ^ recipientInfo);
public void Decrypt (System.Security.Cryptography.Pkcs.RecipientInfo recipientInfo);
member this.Decrypt : System.Security.Cryptography.Pkcs.RecipientInfo -> unit
Public Sub Decrypt (recipientInfo As RecipientInfo)

Parameters

recipientInfo
RecipientInfo

The recipient info to use for decryption.

Exceptions

The recipientInfo parameter is null.

A cryptographic operation could not be completed.

A method call was invalid for the object's current state.

Remarks

.NET Framework Security

The following permissions are required to access the decryption key:

Applies to

Decrypt(X509Certificate2Collection)

Decrypts the contents of the decoded enveloped CMS/PKCS#7 message via any available recipient info by searching certificate stores and a provided collection for a matching certificate and key.

public:
 void Decrypt(System::Security::Cryptography::X509Certificates::X509Certificate2Collection ^ extraStore);
public void Decrypt (System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore);
member this.Decrypt : System.Security.Cryptography.X509Certificates.X509Certificate2Collection -> unit
Public Sub Decrypt (extraStore As X509Certificate2Collection)

Parameters

extraStore
X509Certificate2Collection

A collection of certificates to use in addition to the certificate stores for finding a recipient certificate and private key.

Exceptions

The extraStore parameter was null.

A cryptographic operation could not be completed.

A method call was invalid for the object's current state.

Remarks

.NET Framework Security

The following permissions are required to access the decryption key:

Applies to