ECDiffieHellman.DeriveKeyFromHmac 方法

定義

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

多載

DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[])

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

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.

DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[])

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

public:
 cli::array <System::Byte> ^ DeriveKeyFromHmac(System::Security::Cryptography::ECDiffieHellmanPublicKey ^ otherPartyPublicKey, System::Security::Cryptography::HashAlgorithmName hashAlgorithm, cli::array <System::Byte> ^ hmacKey);
public byte[] DeriveKeyFromHmac (System.Security.Cryptography.ECDiffieHellmanPublicKey otherPartyPublicKey, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[]? hmacKey);
public byte[] DeriveKeyFromHmac (System.Security.Cryptography.ECDiffieHellmanPublicKey otherPartyPublicKey, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] hmacKey);
member this.DeriveKeyFromHmac : System.Security.Cryptography.ECDiffieHellmanPublicKey * System.Security.Cryptography.HashAlgorithmName * byte[] -> byte[]
Public Function DeriveKeyFromHmac (otherPartyPublicKey As ECDiffieHellmanPublicKey, hashAlgorithm As HashAlgorithmName, hmacKey As Byte()) As Byte()

參數

otherPartyPublicKey
ECDiffieHellmanPublicKey

另一方的公開金鑰。The other party's public key.

hashAlgorithm
HashAlgorithmName

要用來衍生金鑰內容的雜湊演算法。The hash algorithm to use to derive the key material.

hmacKey
Byte[]

HMAC 的金鑰。The key for the HMAC.

傳回

Byte[]

所共用密碼的 HMAC。The HMAC of the shared secret.

例外狀況

otherPartyPublicKey 所使用曲線與此金鑰的曲線大小不同。The curve used by otherPartyPublicKey has a different size than the curve from this key.

-或--or-

hashAlgorithm 參數未指定雜湊。The hashAlgorithm parameter does not specify a hash.

otherPartyPublicKeynullotherPartyPublicKey is null.

otherPartyPublicKey 所使用曲線與此金鑰的曲線不同。The curve used by otherPartyPublicKey is different than the curve from this key.

-或--or-

這個執行個體只表示公開金鑰。This instance represents only a public key.

備註

這個多載會呼叫 DeriveKeyFromHmac 傳遞 null 做為前置和附加值的方法。This overload calls the DeriveKeyFromHmac method passing null as the prepend and append values.

適用於

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.

public:
 virtual cli::array <System::Byte> ^ DeriveKeyFromHmac(System::Security::Cryptography::ECDiffieHellmanPublicKey ^ otherPartyPublicKey, System::Security::Cryptography::HashAlgorithmName hashAlgorithm, cli::array <System::Byte> ^ hmacKey, cli::array <System::Byte> ^ secretPrepend, cli::array <System::Byte> ^ secretAppend);
public virtual byte[]? DeriveKeyFromHmac (System.Security.Cryptography.ECDiffieHellmanPublicKey? otherPartyPublicKey, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] hmacKey, byte[] secretPrepend, byte[] secretAppend);
public virtual byte[] DeriveKeyFromHmac (System.Security.Cryptography.ECDiffieHellmanPublicKey otherPartyPublicKey, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] hmacKey, byte[] secretPrepend, byte[] secretAppend);
abstract member DeriveKeyFromHmac : System.Security.Cryptography.ECDiffieHellmanPublicKey * System.Security.Cryptography.HashAlgorithmName * byte[] * byte[] * byte[] -> byte[]
override this.DeriveKeyFromHmac : System.Security.Cryptography.ECDiffieHellmanPublicKey * System.Security.Cryptography.HashAlgorithmName * byte[] * byte[] * byte[] -> byte[]
Public Overridable Function DeriveKeyFromHmac (otherPartyPublicKey As ECDiffieHellmanPublicKey, hashAlgorithm As HashAlgorithmName, hmacKey As Byte(), secretPrepend As Byte(), secretAppend As Byte()) As Byte()

參數

otherPartyPublicKey
ECDiffieHellmanPublicKey

另一方的公開金鑰。The other party's public key.

hashAlgorithm
HashAlgorithmName

要用來衍生金鑰內容的雜湊演算法。The hash algorithm to use to derive the key material.

hmacKey
Byte[]

HMAC 的金鑰。The key for the HMAC.

secretPrepend
Byte[]

雜湊之前要加在衍生密碼前面的值。A value to prepend to the derived secret before hashing.

secretAppend
Byte[]

雜湊之前要附加至衍生密碼的值。A value to append to the derived secret before hashing.

傳回

Byte[]

依要求前置或附加資料後的共用密碼 HMAC。The HMAC of the shared secret after prepending or appending data as requested.

例外狀況

衍生的類別必須覆寫這個方法。A derived class must override this method.

otherPartyPublicKey 所使用曲線與此金鑰的曲線大小不同。The curve used by otherPartyPublicKey has a different size than the curve from this key.

-或--or-

hashAlgorithm 參數未指定雜湊。The hashAlgorithm parameter does not specify a hash.

otherPartyPublicKeynullotherPartyPublicKey is null.

otherPartyPublicKey 所使用曲線與此金鑰的曲線不同。The curve used by otherPartyPublicKey is different than the curve from this key.

-或--or-

這個執行個體只表示公開金鑰。This instance represents only a public key.

備註

這個方法會在內部執行橢圓曲線 Diffie-hellman 金鑰協定,以產生共用密碼 (z) 。This method internally performs the Elliptic Curve Diffie-Hellman key agreement to produce the shared secret (z).

hmacKey 為時 null ,這個方法的傳回值會是 HMAC-HASH(z, secretPrepend || z || secretAppend) 使用指定之 HMAC 演算法的結果,其中 || 表示串連。When hmacKey is null, the return value from this method is the result of HMAC-HASH(z, secretPrepend || z || secretAppend) using the specified HMAC algorithm, where || signifies concatenation. 否則,此方法的傳回值即為的結果 HMAC-HASH(hmacKey, secretPrepend || z || secretAppend)Otherwise, the return value from this method is the result of HMAC-HASH(hmacKey, secretPrepend || z || secretAppend).

如果或的值 secretPrepend secretAppendnull ,則會將它們視為空的陣列。If the value of secretPrepend or secretAppend is null, they are treated as empty arrays.

適用於