Επεξεργασία

Κοινή χρήση μέσω


X509AsymmetricSecurityKey.GetAsymmetricAlgorithm(String, Boolean) Method

Definition

Gets the specified asymmetric cryptographic algorithm.

public:
 override System::Security::Cryptography::AsymmetricAlgorithm ^ GetAsymmetricAlgorithm(System::String ^ algorithm, bool privateKey);
public override System.Security.Cryptography.AsymmetricAlgorithm GetAsymmetricAlgorithm (string algorithm, bool privateKey);
override this.GetAsymmetricAlgorithm : string * bool -> System.Security.Cryptography.AsymmetricAlgorithm
Public Overrides Function GetAsymmetricAlgorithm (algorithm As String, privateKey As Boolean) As AsymmetricAlgorithm

Parameters

algorithm
String

The asymmetric algorithm to create.

privateKey
Boolean

true when a private key is required to create the algorithm; otherwise, false.

Returns

An AsymmetricAlgorithm that represents the specified asymmetric cryptographic algorithm.

Exceptions

privateKey is true and the X.509 certificate specified in the constructor does not have a private key.

-or-

algorithm is XmlDsigDSAUrl and the public or private key for the X.509 certificate specified in the constructor is not of type DSA.

-or-

algorithm is XmlEncRSA15Url, XmlEncRSAOAEPUrl, XmlDsigRSASHA1Url or RsaSha256Signature and the public or private key for the X.509 certificate specified in the constructor is not of type RSA.

-or-

algorithm is not supported. The supported algorithms are XmlDsigDSAUrl, XmlEncRSA15Url, XmlEncRSAOAEPUrl, XmlDsigRSASHA1Url, and RsaSha256Signature.

Remarks

Use the XmlDsigDSAUrl, XmlEncRSA15Url, XmlEncRSAOAEPUrl, XmlDsigRSASHA1Url or RsaSha256Signature fields to specify the algorithm parameter.

Due to collision problems with SHA1, Microsoft recommends a security model based on SHA256 or better.

Applies to