Leggere in inglese

Condividi tramite


AsymmetricAlgorithm Classe

Definizione

Rappresenta la classe base astratta dalla quale devono ereditare tutte le implementazioni di algoritmi asimmetrici.

C#
public abstract class AsymmetricAlgorithm : IDisposable
C#
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class AsymmetricAlgorithm : IDisposable
Ereditarietà
AsymmetricAlgorithm
Derivato
Attributi
Implementazioni

Esempio

Nell'esempio AsymmetricAlgorithm di codice seguente viene illustrato come implementare un algoritmo asimmetrico personalizzato ereditato dalla classe. Viene fornita una classe aggiuntiva per illustrare come usare la classe personalizzata.

C#
using System;
using System.Xml;
using System.Text;
using System.Security.Cryptography;
using System.Reflection;

[assembly: AssemblyKeyFile("CustomCrypto.snk")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: CLSCompliant(true)]
namespace Contoso
{
    // Define a CustomCrypto class that inherits from the AsymmetricAlgorithm
    // class.
    public class CustomCrypto : 
        System.Security.Cryptography.AsymmetricAlgorithm
    {
        // Declare local member variables.
        private CspParameters cspParameters;
        private readonly KeySizes[] keySizes = {new KeySizes(8, 64, 8)};

        // Initialize a CustomCrypto with the default key size of 8.
        public CustomCrypto()
        {
            this.KeySize = 8;
        }

        // Initialize a CustomCrypto with the specified key size.
        public CustomCrypto(int keySize)
        {
            this.KeySize = keySize;
        }

        // Accessor function for keySizes member variable.
        public override KeySizes[] LegalKeySizes 
        { 
            get { return (KeySizes[])keySizes.Clone(); }
        }

        // Modify the KeySizeValue property inherited from the Asymmetric
        // class. Prior to setting the value, ensure it falls within the
        // range identified in the local keySizes member variable.
        public override int KeySize 
        {
            get { return KeySizeValue; }
            set
            {
                for (int i=0; i < keySizes.Length; i++)
                {
                    if (keySizes[i].SkipSize == 0) 
                    {
                        if (keySizes[i].MinSize == value)
                        {
                            KeySizeValue = value;
                            return;
                        }
                    }
                    else
                    {
                        for (int j = keySizes[i].MinSize;
                            j <= keySizes[i].MaxSize;
                            j += keySizes[i].SkipSize)
                        {
                            if (j == value)
                            {
                                KeySizeValue = value;
                                return;
                            }
                        }
                    }
                }

                // If the key does not fall within the range identified 
                // in the keySizes member variable, throw an exception.
                throw new CryptographicException("Invalid key size.");
            }
        }

        // Initialize the parameters with default values.
        public void InitializeParameters()
        {
            cspParameters = new CspParameters();
            cspParameters.ProviderName = "Contoso";
            cspParameters.KeyContainerName = "SecurityBin1";
            cspParameters.KeyNumber = 1;
            cspParameters.ProviderType = 2;
        }

        // Parse specified xmlString for values to populate the CspParams
        // Expected XML schema:
        //      <ProviderName></ProviderName>
        //      <KeyContainerName></KeyContainerName>
        //      <KeyNumber></KeyNumber>
        //      <ProviderType></ProviderType>
        public override void FromXmlString(string xmlString)
        {
            if (xmlString != null)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xmlString);
                XmlNode firstNode = doc.FirstChild;
                XmlNodeList nodeList;

                // Assemble parameters from values in each XML element.
                cspParameters = new CspParameters();

                // KeyContainerName is optional.
                nodeList = doc.GetElementsByTagName("KeyContainerName");
                string keyName = nodeList.Item(0).InnerText;
                if (keyName != null) 
                {
                    cspParameters.KeyContainerName = keyName;
                }

                // KeyNumber is optional.
                nodeList = doc.GetElementsByTagName("KeyNumber");
                string keyNumber = nodeList.Item(0).InnerText;
                if (keyNumber != null) 
                {
                    cspParameters.KeyNumber = Int32.Parse(keyNumber);
                }

                // ProviderName is optional.
                nodeList = doc.GetElementsByTagName("ProviderName");
                string providerName = nodeList.Item(0).InnerText;
                if (providerName != null) 
                {
                    cspParameters.ProviderName = providerName;
                }

                // ProviderType is optional.
                nodeList = doc.GetElementsByTagName("ProviderType");
                string providerType = nodeList.Item(0).InnerText;
                if (providerType != null) 
                {
                    cspParameters.ProviderType = Int32.Parse(providerType);
                }
            }
            else
            {
                throw new ArgumentNullException("xmlString");
            }
        }

        // Create an XML string representation of the parameters in the
        // current customCrypto object.
        public override string ToXmlString(bool includePrivateParameters)
        {
            string keyContainerName = "";
            string keyNumber = "";
            string providerName = "";
            string providerType = "";

            if (cspParameters != null)
            {
                keyContainerName = cspParameters.KeyContainerName;
                keyNumber = cspParameters.KeyNumber.ToString();
                providerName = cspParameters.ProviderName;
                providerType = cspParameters.ProviderType.ToString();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append("<CustomCryptoKeyValue>");

            sb.Append("<KeyContainerName>");
            sb.Append(keyContainerName);
            sb.Append("</KeyContainerName>");

            sb.Append("<KeyNumber>");
            sb.Append(keyNumber);
            sb.Append("</KeyNumber>");

            sb.Append("<ProviderName>");
            sb.Append(providerName);
            sb.Append("</ProviderName>");

            sb.Append("<ProviderType>");
            sb.Append(providerType);
            sb.Append("</ProviderType>");

            sb.Append("</CustomCryptoKeyValue>");
            return(sb.ToString());
        }

        // Return the name for the key exchange algorithm.
        public override string KeyExchangeAlgorithm
        {
            get {return "RSA-PKCS1-KeyEx";}
        }

        // Retrieves the name of the signature alogrithm.
        // This example uses the SHA1 algorithm.
        // Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
        public override string SignatureAlgorithm 
        {
            get {return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";}
        }

        // Required member for implementing the AsymmetricAlgorithm class.
        protected override void Dispose(bool disposing) {}

        // Call the Create method using the CustomCrypto assembly name.
        // The create function attempts to create a CustomCrypto object using
        // the assembly name. This functionality requires modification of the
        // machine.config file. Add the following section to the configuration
        // element and modify the values of the cryptoClass to reflect what is
        // installed in your machines GAC.
        //        <cryptoClass CustomCrypto="Contoso.CustomCrypto, 
        //          CustomCrypto, 
        //          Culture=neutral, 
        //          PublicKeyToken=fdb9f9c4851028bf, 
        //          Version=1.0.1448.27640" />
        //      <nameEntry name="Contoso.CustomCrypto" class="CustomCrypto" />
        //      <nameEntry name="CustomCrypto" class="CustomCrypto" />
        new static public CustomCrypto Create() 
        {
            return Create("CustomCrypto");
        }

        // Create a CustomCrypto object by calling CrytoConfig's
        // CreateFromName method and casting the type to CustomCrypto.
        // The create function attempts to create a CustomCrypto object using
        // the assembly name. This functionality requires modification of the
        // machine.config file. Add the following section to the configuration
        // element and modify the values of the cryptoClass to reflect what is
        // installed in your machines GAC.
        //       <cryptoClass CustomCrypto="Contoso.CustomCrypto, 
        //         CustomCrypto, 
        //         Culture=neutral, 
        //         PublicKeyToken=fdb9f9c4851028bf, 
        //         Version=1.0.1448.27640" />
        //     <nameEntry name="Contoso.CustomCrypto" class="CustomCrypto" />
        //     <nameEntry name="CustomCrypto" class="CustomCrypto" />
        new static public CustomCrypto Create(String algorithmName) 
        {
            return (CustomCrypto) CryptoConfig.CreateFromName(algorithmName);
        }
    }
    class CustomCryptoImpl
    {
        [STAThread]
        static void Main(string[] args)
        {
            // Construct a CustomCrypto object and initialize its
            // CspParameters.
            CustomCrypto customCrypto = new CustomCrypto();
            customCrypto.InitializeParameters();

            // Display properties of the current customCrypto object.
            Console.WriteLine("*** CustomCrypto created with default " + 
                "parameters:");
            DisplayProperties(customCrypto);

            // Release all the resources used by this instance of 
            // CustomCrytpo.
            customCrypto.Clear();

            customCrypto = new CustomCrypto(64);
            // Create new parameters and set them by using the FromXmlString
            // method.
            string parameterXml = "<CustomCryptoKeyValue>";
            parameterXml += "<ProviderName>Contoso</ProviderName>";
            parameterXml += "<KeyContainerName>SecurityBin2";
            parameterXml += "</KeyContainerName>";
            parameterXml += "<KeyNumber>1</KeyNumber>";
            parameterXml += "<ProviderType>2</ProviderType>";
            parameterXml += "</CustomCryptoKeyValue>";
            customCrypto.FromXmlString(parameterXml);

            // Display the properties of a customCrypto object created with
            // custom parameters.
            Console.WriteLine("\n*** " + 
                "CustomCrypto created with custom parameters:");
            DisplayProperties(customCrypto);

            // Create an object by using the assembly name.
            try
            {
                CustomCrypto myCryptoA = CustomCrypto.Create("CustomCrypto");
                if (myCryptoA != null)
                {
                    Console.Write("\n*** " + 
                        "Successfully created CustomCrytpo from");
                    Console.WriteLine(" the Create method.");

                    DisplayProperties(myCryptoA);
                }
                else
                {
                    Console.Write("Unable to create CustomCrytpo from ");
                    Console.WriteLine(" the Create method.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            
            Console.WriteLine("This sample completed successfully; " +
                "press Enter to exit.");
            Console.ReadLine();
        }
        // Display the properties of the specified CustomCrypto object to the
        // console.
        public static void DisplayProperties(CustomCrypto customCrypto)
        {
            try
            {
                // Retrieve the class description for the customCrypto object.
                string classDescription = customCrypto.ToString();

                Console.WriteLine(classDescription);
                Console.Write("KeyExchangeAlgorithm: ");
                Console.WriteLine(customCrypto.KeyExchangeAlgorithm);
                Console.Write("SignatureAlgorithm: ");
                Console.WriteLine(customCrypto.SignatureAlgorithm);
                Console.WriteLine("KeySize: " + customCrypto.KeySize);
                Console.WriteLine("Parameters described in Xml format:");
                Console.WriteLine(customCrypto.ToXmlString(true));

                // Display the MinSize, MaxSize, and SkipSize properties of 
                // each KeySize item in the local keySizes member variable.
                KeySizes[] legalKeySizes = customCrypto.LegalKeySizes;
                if (legalKeySizes.Length > 0)
                {
                    for (int i=0; i < legalKeySizes.Length; i++)
                    {
                        Console.Write("Keysize" + i + " min, max, step: ");
                        Console.Write(legalKeySizes[i].MinSize + ", ");
                        Console.Write(legalKeySizes[i].MaxSize + ", ");
                        Console.WriteLine(legalKeySizes[i].SkipSize + ", ");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught unexpected exception: " + 
                    ex.ToString());
            }
        }
    }
}
//
// This sample produces the following output:
//
// *** CustomCrypto created with default parameters:
// Contoso.vbCustomCrypto
// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
// KeySize: 8
// Parameters described in Xml format:
// <CustomCryptoKeyValue><KeyContainerName>SecurityBin1</KeyContainerName>
// <KeyNumber>1</KeyNumber><ProviderName>Contoso</ProviderName>
// <ProviderType>2</ProviderType></CustomCryptoKeyValue>
// Keysize0 min, max, step: 8, 64, 8, 
// 
// *** CustomCrypto created with custom parameters:
// Contoso.vbCustomCrypto
// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
// KeySize: 64
// Parameters described in Xml format:
// <CustomCryptoKeyValue><KeyContainerName>SecurityBin2</KeyContainerName>
// <KeyNumber>1</KeyNumber><ProviderName>Contoso</ProviderName>
// <ProviderType>2</ProviderType></CustomCryptoKeyValue>
// Keysize0 min, max, step: 8, 64, 8, 
// Unable to create CustomCrytpo from  the Create method
// This sample completed successfully; press Exit to continue.

Ecco una classe aggiuntiva che illustra come usare la classe personalizzata.

C#
    class CustomCryptoImpl
    {
        [STAThread]
        static void Main(string[] args)
        {
            // Construct a CustomCrypto object and initialize its
            // CspParameters.
            CustomCrypto customCrypto = new CustomCrypto();
            customCrypto.InitializeParameters();

            // Display properties of the current customCrypto object.
            Console.WriteLine("*** CustomCrypto created with default " + 
                "parameters:");
            DisplayProperties(customCrypto);

            // Release all the resources used by this instance of 
            // CustomCrytpo.
            customCrypto.Clear();

            customCrypto = new CustomCrypto(64);
            // Create new parameters and set them by using the FromXmlString
            // method.
            string parameterXml = "<CustomCryptoKeyValue>";
            parameterXml += "<ProviderName>Contoso</ProviderName>";
            parameterXml += "<KeyContainerName>SecurityBin2";
            parameterXml += "</KeyContainerName>";
            parameterXml += "<KeyNumber>1</KeyNumber>";
            parameterXml += "<ProviderType>2</ProviderType>";
            parameterXml += "</CustomCryptoKeyValue>";
            customCrypto.FromXmlString(parameterXml);

            // Display the properties of a customCrypto object created with
            // custom parameters.
            Console.WriteLine("\n*** " + 
                "CustomCrypto created with custom parameters:");
            DisplayProperties(customCrypto);

            // Create an object by using the assembly name.
            try
            {
                CustomCrypto myCryptoA = CustomCrypto.Create("CustomCrypto");
                if (myCryptoA != null)
                {
                    Console.Write("\n*** " + 
                        "Successfully created CustomCrytpo from");
                    Console.WriteLine(" the Create method.");

                    DisplayProperties(myCryptoA);
                }
                else
                {
                    Console.Write("Unable to create CustomCrytpo from ");
                    Console.WriteLine(" the Create method.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            
            Console.WriteLine("This sample completed successfully; " +
                "press Enter to exit.");
            Console.ReadLine();
        }
        // Display the properties of the specified CustomCrypto object to the
        // console.
        public static void DisplayProperties(CustomCrypto customCrypto)
        {
            try
            {
                // Retrieve the class description for the customCrypto object.
                string classDescription = customCrypto.ToString();

                Console.WriteLine(classDescription);
                Console.Write("KeyExchangeAlgorithm: ");
                Console.WriteLine(customCrypto.KeyExchangeAlgorithm);
                Console.Write("SignatureAlgorithm: ");
                Console.WriteLine(customCrypto.SignatureAlgorithm);
                Console.WriteLine("KeySize: " + customCrypto.KeySize);
                Console.WriteLine("Parameters described in Xml format:");
                Console.WriteLine(customCrypto.ToXmlString(true));

                // Display the MinSize, MaxSize, and SkipSize properties of 
                // each KeySize item in the local keySizes member variable.
                KeySizes[] legalKeySizes = customCrypto.LegalKeySizes;
                if (legalKeySizes.Length > 0)
                {
                    for (int i=0; i < legalKeySizes.Length; i++)
                    {
                        Console.Write("Keysize" + i + " min, max, step: ");
                        Console.Write(legalKeySizes[i].MinSize + ", ");
                        Console.Write(legalKeySizes[i].MaxSize + ", ");
                        Console.WriteLine(legalKeySizes[i].SkipSize + ", ");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught unexpected exception: " + 
                    ex.ToString());
            }
        }
    }
}
//
// This sample produces the following output:
//
// *** CustomCrypto created with default parameters:
// Contoso.vbCustomCrypto
// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
// KeySize: 8
// Parameters described in Xml format:
// <CustomCryptoKeyValue><KeyContainerName>SecurityBin1</KeyContainerName>
// <KeyNumber>1</KeyNumber><ProviderName>Contoso</ProviderName>
// <ProviderType>2</ProviderType></CustomCryptoKeyValue>
// Keysize0 min, max, step: 8, 64, 8, 
// 
// *** CustomCrypto created with custom parameters:
// Contoso.vbCustomCrypto
// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
// KeySize: 64
// Parameters described in Xml format:
// <CustomCryptoKeyValue><KeyContainerName>SecurityBin2</KeyContainerName>
// <KeyNumber>1</KeyNumber><ProviderName>Contoso</ProviderName>
// <ProviderType>2</ProviderType></CustomCryptoKeyValue>
// Keysize0 min, max, step: 8, 64, 8, 
// Unable to create CustomCrytpo from  the Create method
// This sample completed successfully; press Exit to continue.

Commenti

Gli algoritmi crittografici asimmetrici, noti anche come algoritmi di chiave pubblica, richiedono che sia il mittente che il ricevitore mantengano una coppia di chiavi correlate: una chiave privata e una chiave pubblica. Entrambe le chiavi sono univoche per l'entità. La chiave pubblica può essere resa disponibile a chiunque; questa chiave viene usata per la codifica dei dati inviati a un ricevitore. La chiave privata deve essere mantenuta privata dal ricevitore; questa chiave viene usata per decodificare i messaggi codificati usando la chiave pubblica del ricevitore. La RSACryptoServiceProvider classe è un'implementazione di un algoritmo a chiave pubblica. Per una discussione approfondita sulla crittografia e sugli algoritmi di chiave pubblica, vedere la sezione "Crittografia chiave pubblica" in Servizi di crittografia. Per informazioni su come usare lo strumento Nome sicuro (Sn.exe) per creare coppie chiave, vedere Procedura: Creare una coppia di chiavi Public-Private.

È possibile usare sistemi a chiave pubblica per formare firme digitali. Le firme digitali vengono usate per proteggere l'integrità dei dati. Ad esempio, per usare un sistema a chiave pubblica per firmare digitalmente un messaggio, il mittente applica prima una funzione hash al messaggio per creare un digest di messaggi. Il mittente crittografa quindi il digest del messaggio con la chiave privata del mittente per creare la firma personale del mittente. Dopo aver ricevuto il messaggio e la firma, il ricevitore decrittografa la firma usando la chiave pubblica del mittente per recuperare il digest del messaggio e esegue l'hash usando lo stesso algoritmo hash usato dal mittente. Se il digest del messaggio calcolato dal ricevitore corrisponde al digest del messaggio ricevuto dal mittente, il destinatario può presumere che il messaggio non sia stato modificato durante il transito. Si noti che chiunque può verificare una firma, perché la chiave pubblica del mittente è conoscenza comune. Questa tecnica non mantiene la segretezza del messaggio; affinché il messaggio sia segreto, deve essere crittografato anche.

.NET Framework fornisce le classi seguenti che implementano algoritmi di firma digitale: DSACryptoServiceProvider, , ECDsaRSACryptoServiceProvider(classe base) e ECDsaCng.

Lo System.Security.Cryptography spazio dei nomi fornisce classi concrete solo per RSA e DSA solo.

Per informazioni su come usare l'algoritmo RSA per crittografare e decrittografare i dati XML e creare e verificare le firme digitali XML, vedere questi articoli:

Costruttori

AsymmetricAlgorithm()

Inizializza una nuova istanza della classe AsymmetricAlgorithm.

Campi

KeySizeValue

Rappresenta la dimensione in bit del modulo della chiave usato dall'algoritmo asimmetrico.

LegalKeySizesValue

Specifica le dimensioni delle chiavi supportate dall'algoritmo asimmetrico.

Proprietà

KeyExchangeAlgorithm

Quando ne viene eseguito l'override in una classe derivata, ottiene il nome dell'algoritmo di scambio delle chiavi; in caso contrario, genera NotImplementedException.

KeySize

Ottiene o imposta la dimensione in bit del modulo della chiave usato dall'algoritmo asimmetrico.

LegalKeySizes

Ottiene le dimensioni delle chiavi supportate dall'algoritmo asimmetrico.

SignatureAlgorithm

Quando ne viene eseguito l'override in una classe derivata, ottiene il nome dell'algoritmo di scambio delle chiavi; in caso contrario, genera sempre NotImplementedException.

Metodi

Clear()

Rilascia tutte le risorse usate dalla classe AsymmetricAlgorithm.

Create()
Obsoleti.
Obsoleti.

Crea un oggetto predefinito di crittografia usato per eseguire l'algoritmo asimmetrico.

Create(String)
Obsoleti.

Crea un'istanza dell'implementazione specificata di un algoritmo asimmetrico.

Dispose()

Rilascia tutte le risorse usate dall'istanza corrente della classe AsymmetricAlgorithm.

Dispose(Boolean)

Rilascia le risorse non gestite usate dalla classe AsymmetricAlgorithm e facoltativamente le risorse gestite.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

Esporta la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su byte.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

Esporta la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su caratteri.

ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters)

Esporta la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su byte, con codifica PEM.

ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters)

Esporta la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su caratteri, con codifica PEM.

ExportPkcs8PrivateKey()

Esporta la chiave corrente nel formato PKCS#8 PrivateKeyInfo.

ExportPkcs8PrivateKeyPem()

Esporta la chiave corrente nel formato PKCS#8 PrivateKeyInfo, con codifica PEM.

ExportSubjectPublicKeyInfo()

Esporta la parte della chiave pubblica della chiave corrente nel formato X.509 SubjectPublicKeyInfo.

ExportSubjectPublicKeyInfoPem()

Esporta la parte pubblica della chiave pubblica della chiave corrente nel formato X.509 SubjectPublicKeyInfo, codificato con PEM.

FromXmlString(String)

Quando ne viene eseguito l'override in una classe derivata, ricostruisce un oggetto AsymmetricAlgorithm da una stringa XML; in caso contrario, genera NotImplementedException.

GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

Quando sottoposto a override in una classe derivata, importa la coppia di chiavi pubblica/privata da una struttura PKCS#8 EncryptedPrivateKeyInfo dopo la decrittografia con una password basata su byte, sostituendo le chiavi per questo oggetto.

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

Quando sottoposto a override in una classe derivata, importa la coppia di chiavi pubblica/privata da una struttura PKCS#8 EncryptedPrivateKeyInfo dopo la decrittografia con una password basata su caratteri, sostituendo le chiavi per questo oggetto.

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

Quando sottoposto a override in una classe derivata, importa una chiave con codifica PEM RFC 7468 crittografata, sostituendo le chiavi per questo oggetto.

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Quando sottoposto a override in una classe derivata, importa una chiave con codifica PEM RFC 7468 crittografata, sostituendo le chiavi per questo oggetto.

ImportFromPem(ReadOnlySpan<Char>)

Quando sottoposto a override in una classe derivata, importa una chiave codificata in modo testuale RFC 7468, sostituendo le chiavi per questo oggetto.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

Quando sottoposto a override in una classe derivata, importa la coppia di chiavi pubblica/privata da una struttura PKCS#8 PrivateKeyInfo dopo la decrittografia, sostituendo le chiavi per questo oggetto.

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

Quando sottoposto a override in una classe derivata, importa la chiave pubblica da una struttura X.509 SubjectPublicKeyInfo dopo la decrittografia, sostituendo le chiavi per questo oggetto.

MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)
ToXmlString(Boolean)

Quando ne viene eseguito l'override in una classe derivata, crea e restituisce una rappresentazione di stringa XML dell'oggetto AsymmetricAlgorithm corrente; in caso contrario, genera NotImplementedException.

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

Quando sottoposto a override in una classe derivata, tenta di esportare la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo in un buffer specificato, usando una password basata su byte.

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

Quando sottoposto a override in una classe derivata, tenta di esportare la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo in un buffer specificato, usando una password basata su caratteri.

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

Tenta di esportare la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su byte, con codifica PEM.

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

Esporta la chiave corrente nel formato PKCS#8 EncryptedPrivateKeyInfo con una password basata su caratteri, con codifica PEM.

TryExportPkcs8PrivateKey(Span<Byte>, Int32)

Quando sottoposto a override in una classe derivata, tenta di esportare la chiave corrente nel formato PKCS#8 PrivateKeyInfo in un buffer specificato.

TryExportPkcs8PrivateKeyPem(Span<Char>, Int32)

Tenta di esportare la chiave corrente nel formato PKCS#8 PrivateKeyInfo con codifica PEM in un buffer fornito.

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

Quando sottoposto a override in una classe derivata, tenta di esportare la chiave corrente nel formato X.509 SubjectPublicKeyInfo in un buffer specificato.

TryExportSubjectPublicKeyInfoPem(Span<Char>, Int32)

Tenta di esportare la chiave corrente nel formato X.509 SoggettoPublicKeyInfo con codifica PEM in un buffer fornito.

Implementazioni dell'interfaccia esplicita

IDisposable.Dispose()

Questa API supporta l'infrastruttura del prodotto e non è previsto che venga usata direttamente dal codice.

Per una descrizione di questo membro, vedere Dispose().

Si applica a

Prodotto Versioni
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

Vedi anche