ECDiffieHellmanCng.DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[], Byte[], Byte[]) 方法

定义

使用基于哈希的消息验证代码 (HMAC) 派生可用作密钥的字节。Derives bytes that can be used as a key using a Hash-based Message Authentication Code (HMAC).

public:
 override 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 override byte[] DeriveKeyFromHmac (System.Security.Cryptography.ECDiffieHellmanPublicKey otherPartyPublicKey, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] hmacKey, byte[] secretPrepend, byte[] secretAppend);
override this.DeriveKeyFromHmac : System.Security.Cryptography.ECDiffieHellmanPublicKey * System.Security.Cryptography.HashAlgorithmName * byte[] * byte[] * byte[] -> byte[]
Public Overrides 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[]

来自与另一方的公钥进行密钥交换的密钥材料。The key material from the key exchange with the other party's public key.

异常

otherPartyPublicKeynullotherPartyPublicKey is null.

otherPartyPublicKey 不是 ECDH 密钥,或者大小不正确。otherPartyPublicKey is not an ECDH key, or it is not the correct size.

-or- hashAlgorithm.NamehashAlgorithm.Name nullEmptyis null or Empty.

所有其他错误。All other errors.

注解

如果secretPrepend nullsecretAppend的值为, 则将它们视为空数组。If the value of secretPrepend or secretAppend is null, they are treated as empty arrays. 如果的hmacKey值为null, 则椭圆曲线 diffie-hellman (ECDH) 算法的结果将用作 HMAC 密钥。If the value of hmacKey is null, the result of the Elliptic Curve Diffie-Hellman (ECDH) algorithm will be used as the HMAC key.

适用于