Click or drag to resize

HpkeLabeledExtract Method

Compute the output of the LabeledExtract function as defined in RFC9180.

Namespace: CryptoSysPKI
Assembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.30549 (23.1.0.0)
Syntax
public static byte[] LabeledExtract(
	byte[] salt,
	string label,
	byte[] ikm,
	HpkeCurveName curveName,
	HpkeAeadAlg aeadAlg = HpkeAeadAlg.None
)

Parameters

salt  Byte
Byte string salt
label  String
Label string
ikm  Byte
Input keying material (ikm)
curveName  HpkeCurveName
ECDH curve used in scheme
aeadAlg  HpkeAeadAlg  (Optional)
AEAD encryption algorithm used in the scheme or 0 (default) to indicate KDF is being used inside a KEM algorithm.

Return Value

Byte
A pseudorandom key of fixed length Nh bytes.
Remarks
The LabeledExtract function is defined in section 4 of [RFC9180]. It uses the "extract" stage of the HKDF function [RFC5869] and outputs a fixed value of bytes equal to the length (Nh) of the underlying HMAC function used by the KDF algorithm. The ECDH curve group used in the scheme must be specified, which automatically fixes the KDF and associated HMAC algorithm to be used.
Example
C#
// Used inside KEM
string ikmhex = "7268600d403fce431561aef583ee1613527cff655c1343f29812e66706df3234";
Console.WriteLine(Cnv.ToHex(Hpke.LabeledExtract(null, "dkp_prk", Cnv.FromHex(ikmhex), Hpke.CurveName.X25519)));
// 7B8BFE1D6F3D0CB45C585E133299C64AC998BF46CAF2DC13BA874F23413EC23A
// Used outside KEM
Console.WriteLine(Cnv.ToHex(Hpke.LabeledExtract(null, "psk_id_hash", null, Hpke.CurveName.X25519, Hpke.AeadAlg.Aes_128_Gcm)));
// 725611C9D98C07C03F60095CD32D400D8347D45ED67097BBAD50FC56DA742D07
See Also