Leer en inglés

Compartir a través de


AsymmetricAlgorithm Clase

Definición

Representa la clase base abstracta de la que deben heredarse todas las implementaciones de algoritmos asimétricos.

C#
public abstract class AsymmetricAlgorithm : IDisposable
C#
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class AsymmetricAlgorithm : IDisposable
Herencia
AsymmetricAlgorithm
Derivado
Atributos
Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestra cómo implementar un algoritmo asimétrico personalizado heredado de la AsymmetricAlgorithm clase . Se proporciona una clase adicional para mostrar cómo usar la clase personalizada.

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.

Esta es una clase adicional que muestra cómo usar la clase personalizada.

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.

Comentarios

Los algoritmos criptográficos asimétricos, también conocidos como algoritmos de clave pública, requieren que tanto el remitente como el receptor mantengan un par de claves relacionadas: una clave privada y una clave pública. Ambas claves son únicas para la entidad. La clave pública se puede poner a disposición de cualquier persona; esta clave se usa para codificar los datos que se envían a un receptor. El receptor debe mantener la clave privada; esta clave se usa para descodificar mensajes codificados mediante la clave pública del receptor. La RSACryptoServiceProvider clase es una implementación de un algoritmo de clave pública. Para obtener una explicación detallada del cifrado y los algoritmos de clave pública, consulte la sección "Cifrado de clave pública" en Servicios criptográficos. Para obtener información sobre cómo usar la herramienta de nombre seguro (Sn.exe) para crear pares de claves, vea How to: Create a Public-Private Key Pair.

Puede usar sistemas de clave pública para formar firmas digitales. Las firmas digitales se usan para ayudar a proteger la integridad de los datos. Por ejemplo, para usar un sistema de clave pública para firmar digitalmente un mensaje, el remitente aplica primero una función hash al mensaje para crear un resumen de mensaje. A continuación, el remitente cifra el resumen del mensaje con la clave privada del remitente para crear la firma personal del remitente. Tras recibir el mensaje y la firma, el receptor descifra la firma mediante la clave pública del remitente para recuperar el resumen del mensaje y aplica un algoritmo hash al mensaje con el mismo algoritmo hash que usó el remitente. Si el resumen del mensaje que el receptor calcula coincide con el resumen del mensaje recibido del remitente, el receptor puede suponer que el mensaje no se modificó durante el tránsito. Tenga en cuenta que cualquier persona puede comprobar una firma, ya que la clave pública del remitente es un conocimiento común. Esta técnica no conserva el secreto del mensaje; para que el mensaje sea secreto, también debe cifrarse.

.NET Framework proporciona las siguientes clases que implementan algoritmos de firma digital: DSACryptoServiceProvider, , ECDsaRSACryptoServiceProvider(clase base) y ECDsaCng.

El System.Security.Cryptography espacio de nombres proporciona clases concretas solo para RSA y DSA .

Para obtener información sobre cómo usar el algoritmo RSA para cifrar y descifrar datos XML, y crear y comprobar firmas digitales XML, consulte estos artículos:

Constructores

AsymmetricAlgorithm()

Inicializa una nueva instancia de la clase AsymmetricAlgorithm.

Campos

KeySizeValue

Representa el tamaño, en bits, del módulo de claves que usa el algoritmo asimétrico.

LegalKeySizesValue

Especifica los tamaños de clave admitidos por el algoritmo asimétrico.

Propiedades

KeyExchangeAlgorithm

Cuando se invalida en una clase derivada, obtiene el nombre del algoritmo de intercambio de claves. En caso contrario, produce una excepción NotImplementedException.

KeySize

Obtiene o establece el tamaño, en bits, del módulo de claves que usa el algoritmo asimétrico.

LegalKeySizes

Obtiene los tamaños de clave que admite el algoritmo asimétrico.

SignatureAlgorithm

Cuando se implementa en una clase derivada, obtiene el nombre del algoritmo de signatura. En caso contrario, produce siempre una NotImplementedException.

Métodos

Clear()

Libera todos los recursos que utiliza la clase AsymmetricAlgorithm.

Create()
Obsoletos.
Obsoletos.

Crea un objeto criptográfico predeterminado que se usa para realizar el algoritmo asimétrico.

Create(String)
Obsoletos.

Crea una instancia de la implementación especificada de un algoritmo asimétrico.

Dispose()

Libera todos los recursos usados por la instancia actual de la clase AsymmetricAlgorithm.

Dispose(Boolean)

Libera los recursos no administrados utilizados por la clase AsymmetricAlgorithm y, de forma opcional, libera los recursos administrados.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

Exporta la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en bytes.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

Exporta la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en caracteres.

ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters)

Exporta la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en bytes, codificada en PEM.

ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters)

Exporta la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en caracteres, codificada en PEM.

ExportPkcs8PrivateKey()

Exporta la clave actual en el formato PrivateKeyInfo de PKCS#8.

ExportPkcs8PrivateKeyPem()

Exporta la clave actual en el formato PrivateKeyInfo PKCS#8, codificado en PEM.

ExportSubjectPublicKeyInfo()

Exporta la parte de la clave pública de la clave actual en el formato SubjectPublicKeyInfo de X.509.

ExportSubjectPublicKeyInfoPem()

Exporta la parte de clave pública de la clave actual en el formato SubjectPublicKeyInfo X.509, codificado en PEM.

FromXmlString(String)

Cuando se invalida en una clase derivada, reconstruye un objeto AsymmetricAlgorithm a partir de una cadena XML. En caso contrario, produce una excepción NotImplementedException.

GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

Cuando se reemplaza en una clase derivada, importa el par de claves pública/privada desde una estructura EncryptedPrivateKeyInfo de PKCS#8 después de descifrar con una contraseña basada en bytes, reemplazando las claves de este objeto.

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

Cuando se reemplaza en una clase derivada, importa el par de claves pública/privada desde una estructura EncryptedPrivateKeyInfo de PKCS#8 después de descifrar con una contraseña basada en caracteres, reemplazando las claves de este objeto.

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

Cuando se invalida en una clase derivada, importa una clave con codificación PEM de RFC 7468 cifrada, reemplazando las claves para este objeto.

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

Cuando se invalida en una clase derivada, importa una clave con codificación PEM de RFC 7468 cifrada, reemplazando las claves para este objeto.

ImportFromPem(ReadOnlySpan<Char>)

Cuando se reemplaza en una clase derivada, importa una clave codificada textualmente de RFC 7468, reemplazando las claves para este objeto.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

Cuando se reemplaza en una clase derivada, importa el par de claves pública/privada desde una estructura PrivateKeyInfo de PKCS#8 después del descifrado, reemplazando las claves de este objeto.

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

Cuando se reemplaza en una clase derivada, importa la clave pública desde una estructura SubjectPublicKeyInfo de X.509 después del descifrado, reemplazando las claves de este objeto.

MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)
ToXmlString(Boolean)

Cuando se invalida en una clase derivada, crea y devuelve una representación en forma de cadena XML del objeto AsymmetricAlgorithm actual. En caso contrario, produce una excepción NotImplementedException.

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

Cuando se reemplaza en una clase derivada, intenta exportar la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 a un búfer proporcionado, utilizando una contraseña basada en bytes.

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

Cuando se reemplaza en una clase derivada, intenta exportar la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 a un búfer proporcionado, utilizando una contraseña basada en caracteres.

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

Intenta exportar la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en bytes, codificada en PEM.

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

Exporta la clave actual en el formato EncryptedPrivateKeyInfo de PKCS#8 con una contraseña basada en caracteres, codificada en PEM.

TryExportPkcs8PrivateKey(Span<Byte>, Int32)

Cuando se reemplaza en una clase derivada, intenta exportar la clave actual en el formato PrivateKeyInfo de PKCS#8 a un búfer proporcionado.

TryExportPkcs8PrivateKeyPem(Span<Char>, Int32)

Intenta exportar la clave actual en el formato PKCS#8 PrivateKeyInfo codificado en PEM en un búfer proporcionado.

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

Cuando se reemplaza en una clase derivada, intenta exportar la clave actual en el formato SubjectPublicKeyInfo de X.509 a un búfer proporcionado.

TryExportSubjectPublicKeyInfoPem(Span<Char>, Int32)

Intenta exportar la clave actual en el formato X.509 SubjectPublicKeyInfo codificado en PEM en un búfer proporcionado.

Implementaciones de interfaz explícitas

IDisposable.Dispose()

Esta API admite la infraestructura de producto y no está pensada para usarse directamente en el código.

Para obtener una descripción de este miembro, vea Dispose().

Se aplica a

Producto Versiones
.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

Consulte también