ECDiffieHellmanCng 類別

定義

提供 Elliptic Curve Diffie-Hellman (ECDH) 演算法的 Cryptography Next Generation (CNG) 實作。Provides a Cryptography Next Generation (CNG) implementation of the Elliptic Curve Diffie-Hellman (ECDH) algorithm. 這個類別是用來執行密碼編譯作業。This class is used to perform cryptographic operations.

public ref class ECDiffieHellmanCng sealed : System::Security::Cryptography::ECDiffieHellman
public sealed class ECDiffieHellmanCng : System.Security.Cryptography.ECDiffieHellman
type ECDiffieHellmanCng = class
    inherit ECDiffieHellman
Public NotInheritable Class ECDiffieHellmanCng
Inherits ECDiffieHellman
繼承

範例

下列範例示範如何使用 ECDiffieHellmanCng 類別來建立金鑰交換,以及如何使用該金鑰來加密可透過公用通道傳送並由接收者解密的訊息。The following example shows how to use the ECDiffieHellmanCng class to establish a key exchange and how to use that key to encrypt a message that can be sent over a public channel and decrypted by the receiver.

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

class Alice
{
    public static byte[] alicePublicKey;

    public static void Main(string[] args)
    {
        using (ECDiffieHellmanCng alice = new ECDiffieHellmanCng())
        {

            alice.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
            alice.HashAlgorithm = CngAlgorithm.Sha256;
            alicePublicKey = alice.PublicKey.ToByteArray();
            Bob bob = new Bob();
            CngKey k = CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob);
            byte[] aliceKey = alice.DeriveKeyMaterial(CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob));
            byte[] encryptedMessage = null;
            byte[] iv = null;
            Send(aliceKey, "Secret message", out encryptedMessage, out iv);
            bob.Receive(encryptedMessage, iv);
        }
    }

    private static void Send(byte[] key, string secretMessage, out byte[] encryptedMessage, out byte[] iv)
    {
        using (Aes aes = new AesCryptoServiceProvider())
        {
            aes.Key = key;
            iv = aes.IV;

            // Encrypt the message
            using (MemoryStream ciphertext = new MemoryStream())
            using (CryptoStream cs = new CryptoStream(ciphertext, aes.CreateEncryptor(), CryptoStreamMode.Write))
            {
                byte[] plaintextMessage = Encoding.UTF8.GetBytes(secretMessage);
                cs.Write(plaintextMessage, 0, plaintextMessage.Length);
                cs.Close();
                encryptedMessage = ciphertext.ToArray();
            }
        }
    }
}
public class Bob
{
    public byte[] bobPublicKey;
    private byte[] bobKey;
    public Bob()
    {
        using (ECDiffieHellmanCng bob = new ECDiffieHellmanCng())
        {

            bob.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
            bob.HashAlgorithm = CngAlgorithm.Sha256;
            bobPublicKey = bob.PublicKey.ToByteArray();
            bobKey = bob.DeriveKeyMaterial(CngKey.Import(Alice.alicePublicKey, CngKeyBlobFormat.EccPublicBlob));
        }
    }

    public void Receive(byte[] encryptedMessage, byte[] iv)
    {

        using (Aes aes = new AesCryptoServiceProvider())
        {
            aes.Key = bobKey;
            aes.IV = iv;
            // Decrypt the message
            using (MemoryStream plaintext = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(plaintext, aes.CreateDecryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(encryptedMessage, 0, encryptedMessage.Length);
                    cs.Close();
                    string message = Encoding.UTF8.GetString(plaintext.ToArray());
                    Console.WriteLine(message);
                }
            }
        }
    }
}
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text




Class Alice
    Public Shared alicePublicKey() As Byte


    Public Shared Sub Main(ByVal args() As String)
        Using alice As New ECDiffieHellmanCng()
            alice.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash
            alice.HashAlgorithm = CngAlgorithm.Sha256
            alicePublicKey = alice.PublicKey.ToByteArray()
            Dim bob As New Bob()
            Dim k As CngKey = CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob)
            Dim aliceKey As Byte() = alice.DeriveKeyMaterial(CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob))
            Dim encryptedMessage As Byte() = Nothing
            Dim iv As Byte() = Nothing
            Send(aliceKey, "Secret message", encryptedMessage, iv)
            bob.Receive(encryptedMessage, iv)
        End Using
    End Sub


    Private Shared Sub Send(ByVal key() As Byte, ByVal secretMessage As String, ByRef encryptedMessage() As Byte, ByRef iv() As Byte)
        Using aes As New AesCryptoServiceProvider()
            aes.Key = key
            iv = aes.IV

            ' Encrypt the message
            Using ciphertext As New MemoryStream()
                Using cs As New CryptoStream(ciphertext, aes.CreateEncryptor(), CryptoStreamMode.Write)
                    Dim plaintextMessage As Byte() = Encoding.UTF8.GetBytes(secretMessage)
                    cs.Write(plaintextMessage, 0, plaintextMessage.Length)
                    cs.Close()
                    encryptedMessage = ciphertext.ToArray()
                End Using
            End Using
        End Using

    End Sub
End Class

Public Class Bob
    Public bobPublicKey() As Byte
    Private bobKey() As Byte

    Public Sub New()
        Using bob As New ECDiffieHellmanCng()

            bob.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash
            bob.HashAlgorithm = CngAlgorithm.Sha256
            bobPublicKey = bob.PublicKey.ToByteArray()
            bobKey = bob.DeriveKeyMaterial(CngKey.Import(Alice.alicePublicKey, CngKeyBlobFormat.EccPublicBlob))
        End Using

    End Sub


    Public Sub Receive(ByVal encryptedMessage() As Byte, ByVal iv() As Byte)

        Using aes As New AesCryptoServiceProvider()
                aes.Key = bobKey
                aes.IV = iv
                ' Decrypt the message
            Using plaintext As New MemoryStream()
                Using cs As New CryptoStream(plaintext, aes.CreateDecryptor(), CryptoStreamMode.Write)
                    cs.Write(encryptedMessage, 0, encryptedMessage.Length)
                    cs.Close()
                    Dim message As String = Encoding.UTF8.GetString(plaintext.ToArray())
                    Console.WriteLine(message)
                End Using
            End Using
        End Using
    End Sub
End Class

備註

ECDiffieHellmanCng類別可讓雙方交換私密金鑰內容,即使它們是透過公用通道進行通訊也一樣。The ECDiffieHellmanCng class enables two parties to exchange private key material even if they are communicating through a public channel. 雙方都可以計算相同的秘密值,這在受控 Diffie-hellman 類別中稱為「 秘密協定 」。Both parties can calculate the same secret value, which is referred to as the secret agreement in the managed Diffie-Hellman classes. 密碼合約隨後可用於各種用途,包括做為對稱金鑰。The secret agreement can then be used for a variety of purposes, including as a symmetric key. 不過,類別不會直接公開秘密協定,而是 ECDiffieHellmanCng 會在提供值之前,先對協定執行一些後置處理。However, instead of exposing the secret agreement directly, the ECDiffieHellmanCng class does some post-processing on the agreement before providing the value. 這種 post 處理稱為 * (KDF) 的金鑰衍生函數 *;您可以選取您想要使用的 KDF,並透過 Diffie-hellman 物件實例上的一組屬性來設定其參數。This post processing is referred to as the key derivation function (KDF); you can select which KDF you want to use and set its parameters through a set of properties on the instance of the Diffie-Hellman object.

金鑰衍生函式Key derivation function 屬性Properties
Hash HashAlgorithm -用來處理密碼協定的雜湊演算法。HashAlgorithm - The hash algorithm that is used to process the secret agreement.

SecretPrepend -在雜湊之前,要在秘密合約前面加上的選擇性位元組陣列。SecretPrepend - An optional byte array to prepend to the secret agreement before hashing it.

SecretAppend -在雜湊之前要附加到秘密協定的選擇性位元組陣列。SecretAppend - An optional byte array to append to the secret agreement before hashing it.
Hmac HashAlgorithm -用來處理密碼協定的雜湊演算法。HashAlgorithm - The hash algorithm that is used to process the secret agreement.

SecretPrepend-在雜湊之前,要在秘密合約前面加上的選擇性位元組陣列。SecretPrepend- An optional byte array to prepend to the secret agreement before hashing it.

SecretAppend -在雜湊之前要附加到秘密協定的選擇性位元組陣列。SecretAppend - An optional byte array to append to the secret agreement before hashing it.
Tls Label -金鑰衍生的標籤。Label - The label for key derivation.

Seed -金鑰衍生的種子。Seed - The seed for key derivation.

透過金鑰衍生函式傳遞密碼協定的結果是可以用來作為應用程式金鑰材質的位元組陣列。The result of passing the secret agreement through the key derivation function is a byte array that may be used as key material for your application. 所產生之金鑰材料的位元組數目取決於金鑰衍生函式;例如,SHA-256 會產生256位的金鑰內容,而 SHA-512 會產生512位的金鑰資料。The number of bytes of key material generated is dependent on the key derivation function; for example, SHA-256 will generate 256 bits of key material, whereas SHA-512 will generate 512 bits of key material. ECDH 金鑰交換的基本流程如下所示:The basic flow of an ECDH key exchange is as follows:

  1. Alice 和 Bob 建立金鑰組以用於 Diffie-hellman 金鑰交換操作Alice and Bob create a key pair to use for the Diffie-Hellman key exchange operation

  2. Alice 和 Bob 使用「同意」的參數來設定 KDF。Alice and Bob configure the KDF using parameters the agree on.

  3. Alice 傳送他的公開金鑰給 Bob。Alice sends Bob her public key.

  4. Bob 將他的公開金鑰傳送給 Alice。Bob sends Alice his public key.

  5. Alice 和 Bob 會使用彼此的公開金鑰來產生秘密合約,並將 KDF 套用到秘密合約以產生金鑰內容。Alice and Bob use each other's public keys to generate the secret agreement, and apply the KDF to the secret agreement to generate key material.

建構函式

ECDiffieHellmanCng()

使用隨機金鑰組,初始化 ECDiffieHellmanCng 類別的新執行個體。Initializes a new instance of the ECDiffieHellmanCng class with a random key pair.

ECDiffieHellmanCng(CngKey)

使用指定的 CngKey 物件,初始化 ECDiffieHellmanCng 類別的新執行個體。Initializes a new instance of the ECDiffieHellmanCng class by using the specified CngKey object.

ECDiffieHellmanCng(ECCurve)

建立 ECDiffieHellmanCng 類別的新執行個體,其公開/私密金鑰組是在指定的曲線上所產生。Creates a new instance of the ECDiffieHellmanCng class whose public/private key pair is generated over the specified curve.

ECDiffieHellmanCng(Int32)

使用指定金鑰大小的隨機金鑰組,初始化 ECDiffieHellmanCng 類別的新執行個體。Initializes a new instance of the ECDiffieHellmanCng class with a random key pair, using the specified key size.

欄位

KeySizeValue

表示非對稱演算法使用的金鑰模數大小,以位元為單位。Represents the size, in bits, of the key modulus used by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
LegalKeySizesValue

指定非對稱演算法所支援的金鑰大小。Specifies the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)

屬性

HashAlgorithm

取得或設定產生金鑰內容時使用的雜湊演算法。Gets or sets the hash algorithm to use when generating key material.

HmacKey

取得或設定「雜湊式訊息驗證碼」(Hash-based Message Authentication Code,HMAC) 金鑰,以便在衍生金鑰內容時使用。Gets or sets the Hash-based Message Authentication Code (HMAC) key to use when deriving key material.

Key

指定 CngKey,由目前物件用於密碼編譯作業。Specifies the CngKey that is used by the current object for cryptographic operations.

KeyDerivationFunction

取得或設定 ECDiffieHellmanCng 類別的金鑰衍生函數。Gets or sets the key derivation function for the ECDiffieHellmanCng class.

KeyExchangeAlgorithm

取得金鑰交換演算法的名稱。Gets the name of the key exchange algorithm.

(繼承來源 ECDiffieHellman)
KeySize

取得或設定非對稱演算法使用的金鑰模數大小,以位元為單位。Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.

KeySize

取得或設定非對稱演算法使用的金鑰模數大小,以位元為單位。Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
Label

取得或設定標籤值,用於金鑰衍生。Gets or sets the label value that is used for key derivation.

LegalKeySizes

取得非對稱演算法所支援的金鑰大小。Gets the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
PublicKey

取得公開金鑰,可讓其他 ECDiffieHellmanCng 物件用來產生共用的密碼協議。Gets the public key that can be used by another ECDiffieHellmanCng object to generate a shared secret agreement.

SecretAppend

取得或設定值,該值將在產生金鑰內容時附加到密碼協議。Gets or sets a value that will be appended to the secret agreement when generating key material.

SecretPrepend

取得或設定值,該值將在衍生金鑰內容時加入至密碼協議的開頭。Gets or sets a value that will be added to the beginning of the secret agreement when deriving key material.

Seed

取得或設定值,該值將在衍生金鑰內容時使用。Gets or sets the seed value that will be used when deriving key material.

SignatureAlgorithm

取得簽章演算法的名稱。Gets the name of the signature algorithm.

(繼承來源 ECDiffieHellman)
UseSecretAgreementAsHmacKey

取得值,表示密碼協議是否做為「雜湊式訊息驗證碼」(Hash-based Message Authentication Code,HMAC) 金鑰用來衍生金鑰內容。Gets a value that indicates whether the secret agreement is used as a Hash-based Message Authentication Code (HMAC) key to derive key material.

方法

Clear()

釋放 AsymmetricAlgorithm 類別所使用的所有資源。Releases all resources used by the AsymmetricAlgorithm class.

(繼承來源 AsymmetricAlgorithm)
DeriveKeyFromHash(ECDiffieHellmanPublicKey, HashAlgorithmName)

使用所指定雜湊演算法來執行金鑰衍生。Performs key derivation using a specified hash algorithm.

(繼承來源 ECDiffieHellman)
DeriveKeyFromHash(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[], Byte[])

使用指定的雜湊演算法搭配選擇性的前置或附加資料,執行金鑰衍生。Performs key derivation using a specified hash algorithm with optional prepended or appended data.

DeriveKeyFromHash(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[], Byte[])

在衍生類別中實作時,使用指定的雜湊演算法搭配選擇性前置或附加資料來執行金鑰衍生。When implemented in a derived class, performs key derivation using a specified hash algorithm with optional prepended or appended data.

(繼承來源 ECDiffieHellman)
DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[])

使用指定的 HMAC (雜湊式訊息驗證碼) 演算法來執行金鑰衍生。Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm.

(繼承來源 ECDiffieHellman)
DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[], Byte[], Byte[])

使用指定的 HMAC (雜湊式訊息驗證碼) 演算法搭配選擇性的前置或附加資料來執行金鑰衍生。Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm with optional prepended or appended data.

DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[], Byte[], Byte[])

在衍生類別中實作時,使用指定的 HMAC (雜湊式訊息驗證碼) 演算法搭配選擇性的前置或附加資料來執行金鑰衍生。When implemented in a derived class, performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm with optional prepended or appended data.

(繼承來源 ECDiffieHellman)
DeriveKeyMaterial(CngKey)

衍生金鑰內容,該內容產生自雙方的密碼協議 (如果 CngKey 物件包含另一方的公開金鑰)。Derives the key material that is generated from the secret agreement between two parties, given a CngKey object that contains the second party's public key.

DeriveKeyMaterial(ECDiffieHellmanPublicKey)

衍生金鑰內容,該內容產生自雙方的密碼協議 (如果 ECDiffieHellmanPublicKey 物件包含另一方的公開金鑰)。Derives the key material that is generated from the secret agreement between two parties, given an ECDiffieHellmanPublicKey object that contains the second party's public key.

DeriveKeyTls(ECDiffieHellmanPublicKey, Byte[], Byte[])

使用 TLS (傳輸層安全性) 1.1 PRF (虛擬隨機函式) 來執行金鑰衍生。Performs key derivation using the TLS (Transport Layer Security) 1.1 PRF (Pseudo-Random Function).

DeriveKeyTls(ECDiffieHellmanPublicKey, Byte[], Byte[])

當在衍生類別中實作時,使用 TLS (傳輸層安全性) 1.1 PRF (虛擬隨機函式) 來執行金鑰衍生。When implemented in a derived class, performs key derivation using the TLS (Transport Layer Security) 1.1 PRF (Pseudo-Random Function).

(繼承來源 ECDiffieHellman)
DeriveSecretAgreementHandle(CngKey)

取得雙方所產生密碼協議的控制代碼 (如果 CngKey 物件包含另一方的公開金鑰)。Gets a handle to the secret agreement generated between two parties, given a CngKey object that contains the second party's public key.

DeriveSecretAgreementHandle(ECDiffieHellmanPublicKey)

取得雙方所產生密碼協議的控制代碼 (如果 ECDiffieHellmanPublicKey 物件包含另一方的公開金鑰)。Gets a handle to the secret agreement generated between two parties, given an ECDiffieHellmanPublicKey object that contains the second party's public key.

Dispose()

釋放 AsymmetricAlgorithm 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the AsymmetricAlgorithm class.

(繼承來源 AsymmetricAlgorithm)
Dispose(Boolean)

釋放 AsymmetricAlgorithm 類別所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the AsymmetricAlgorithm class and optionally releases the managed resources.

(繼承來源 AsymmetricAlgorithm)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
ExportECPrivateKey()

以 ECPrivateKey 格式匯出目前的金鑰。Exports the current key in the ECPrivateKey format.

(繼承來源 ECDiffieHellman)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用位元組型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

(繼承來源 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

(繼承來源 AsymmetricAlgorithm)
ExportExplicitParameters(Boolean)

ECCurve 物件所使用的金鑰和明確的曲線參數匯出至 ECParameters 物件。Exports the key and explicit curve parameters used by the ECCurve object into an ECParameters object.

ExportExplicitParameters(Boolean)

在衍生類別中覆寫時,會使用明確的曲線形式,將公開或公開和私密金鑰資訊從運作中的 ECDiffieHellman 金鑰匯出至 ECParameters 結構,讓您可將它傳遞至 ImportParameters(ECParameters) 方法。When overridden in a derived class, exports either the public or the public and private key information using the explicit curve form from a working ECDiffieHellman key to an ECParameters structure so that it can be passed to the ImportParameters(ECParameters) method.

(繼承來源 ECDiffieHellman)
ExportParameters(Boolean)

ECCurve 物件所使用的金鑰匯出到 ECParameters 物件中。Exports the key used by the ECCurve object into an ECParameters object.

ExportParameters(Boolean)

在衍生類別中覆寫時,會將公開或公開和私密金鑰資訊從運作中的 ECDiffieHellman 金鑰匯出至 ECParameters 結構,讓您可將它傳遞至 ImportParameters(ECParameters) 方法。When overridden in a derived class, exports either the public or the public and private key information from a working ECDiffieHellman key to an ECParameters structure so that it can be passed to the ImportParameters(ECParameters) method.

(繼承來源 ECDiffieHellman)
ExportPkcs8PrivateKey()

以 PKCS#8 PrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 PrivateKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式匯出目前金鑰的公開金鑰部分。Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
FromXmlString(String)

這個方法尚未實作。This method is not implemented.

FromXmlString(String)

這個方法在所有情況下都會擲回。This method throws in all cases.

(繼承來源 ECDiffieHellman)
FromXmlString(String, ECKeyXmlFormat)

使用指定的格式從 XML 字串還原金鑰資訊的序列化。Deserializes the key information from an XML string by using the specified format.

GenerateKey(ECCurve)

針對指定的曲線產生新的暫時性公開/私密金鑰組。Generates a new ephemeral public/private key pair for the specified curve.

GenerateKey(ECCurve)

在衍生類別中覆寫時,會針對指定的曲線產生新的暫時性公開/私密金鑰組。When overridden in a derived class, generates a new ephemeral public/private key pair for the specified curve.

(繼承來源 ECDiffieHellman)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
ImportECPrivateKey(ReadOnlySpan<Byte>, Int32)

從 ECPrivateKey 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from an ECPrivateKey structure, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportFromPem(ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的金鑰,並取代這個物件的金鑰。Imports an RFC 7468 PEM-encoded key, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportParameters(ECParameters)

ECCurve 物件的指定參數當做金鑰匯入至目前的執行個體。Imports the specified parameters for an ECCurve object as a key into the current instance.

ImportParameters(ECParameters)

在衍生類別中覆寫時,會將 ECCurve 的指定參數做為暫時性金鑰匯入目前的 ECDiffieHellman 物件。When overridden in a derived class, imports the specified parameters for an ECCurve as an ephemeral key into the current ECDiffieHellman object.

(繼承來源 ECDiffieHellman)
ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密後,從 PKCS#8 PrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

解密後,從 X.509 SubjectPublicKeyInfo 結構匯入公開金鑰,以取代這個物件的金鑰。Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

(繼承來源 ECDiffieHellman)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
ToXmlString(Boolean)

這個方法尚未實作。This method is not implemented.

ToXmlString(Boolean)

這個方法在所有情況下都會擲回。This method throws in all cases.

(繼承來源 ECDiffieHellman)
ToXmlString(ECKeyXmlFormat)

使用指定的格式將金鑰資訊序列化成 XML 字串。Serializes the key information to an XML string by using the specified format.

TryExportECPrivateKey(Span<Byte>, Int32)

嘗試以 ECPrivateKey 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the ECPrivateKey format into a provided buffer.

(繼承來源 ECDiffieHellman)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

使用位元組型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

(繼承來源 ECDiffieHellman)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

使用 Char 型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

(繼承來源 ECDiffieHellman)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

嘗試以 PKCS#8 PrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 PrivateKeyInfo format into a provided buffer.

(繼承來源 ECDiffieHellman)
TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

嘗試以 X.509 SubjectPublicKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

(繼承來源 ECDiffieHellman)

明確介面實作

IDisposable.Dispose()

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(繼承來源 AsymmetricAlgorithm)

適用於