Muokkaa

Jaa


ECDiffieHellman.DeriveKeyFromHmac Method

Definition

Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm.

Overloads

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

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[])

Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm.

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

Source:
ECDiffieHellman.cs
Source:
ECDiffieHellman.cs
Source:
ECDiffieHellman.cs

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()

Parameters

otherPartyPublicKey
ECDiffieHellmanPublicKey

The other party's public key.

hashAlgorithm
HashAlgorithmName

The hash algorithm to use to derive the key material.

hmacKey
Byte[]

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.

Returns

Byte[]

The HMAC of the shared secret after prepending or appending data as requested.

Exceptions

A derived class must override this method.

The curve used by otherPartyPublicKey has a different size than the curve from this key.

-or-

The hashAlgorithm parameter does not specify a hash.

otherPartyPublicKey is null.

The curve used by otherPartyPublicKey is different than the curve from this key.

-or-

This instance represents only a public key.

Remarks

This method internally performs the Elliptic Curve Diffie-Hellman key agreement to produce the shared secret (z).

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. Otherwise, the return value from this method is the result of HMAC-HASH(hmacKey, secretPrepend || z || secretAppend).

If the value of secretPrepend or secretAppend is null, they are treated as empty arrays.

Applies to

DeriveKeyFromHmac(ECDiffieHellmanPublicKey, HashAlgorithmName, Byte[])

Source:
ECDiffieHellman.cs
Source:
ECDiffieHellman.cs
Source:
ECDiffieHellman.cs

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()

Parameters

otherPartyPublicKey
ECDiffieHellmanPublicKey

The other party's public key.

hashAlgorithm
HashAlgorithmName

The hash algorithm to use to derive the key material.

hmacKey
Byte[]

The key for the HMAC.

Returns

Byte[]

The HMAC of the shared secret.

Exceptions

The curve used by otherPartyPublicKey has a different size than the curve from this key.

-or-

The hashAlgorithm parameter does not specify a hash.

otherPartyPublicKey is null.

The curve used by otherPartyPublicKey is different than the curve from this key.

-or-

This instance represents only a public key.

Remarks

This overload calls the DeriveKeyFromHmac method passing null as the prepend and append values.

Applies to