HpkeLabeledExtract Method |
Compute the output of the LabeledExtract function as defined in RFC9180.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.30549 (23.1.0.0)
Syntaxpublic static byte[] LabeledExtract(
byte[] salt,
string label,
byte[] ikm,
HpkeCurveName curveName,
HpkeAeadAlg aeadAlg = HpkeAeadAlg.None
)
Public Shared Function LabeledExtract (
salt As Byte(),
label As String,
ikm As Byte(),
curveName As HpkeCurveName,
Optional aeadAlg As HpkeAeadAlg = HpkeAeadAlg.None
) As Byte()
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
ByteA pseudorandom key of fixed length Nh bytes.
RemarksThe 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
string ikmhex = "7268600d403fce431561aef583ee1613527cff655c1343f29812e66706df3234";
Console.WriteLine(Cnv.ToHex(Hpke.LabeledExtract(null, "dkp_prk", Cnv.FromHex(ikmhex), Hpke.CurveName.X25519)));
Console.WriteLine(Cnv.ToHex(Hpke.LabeledExtract(null, "psk_id_hash", null, Hpke.CurveName.X25519, Hpke.AeadAlg.Aes_128_Gcm)));
See Also