Ecc.dh_shared_secret) using the elliptic curve groups
Cipher.encrypt_aead) using the algorithms
HPKE_LabeledExtract and HPKE_LabeledExpand
are provided here to carry out the functions
LabeledExpand() defined in HKPE.
The function HPKE_DerivePrivateKey (
is provided to derive an EC private key using the deterministic method described in HKPE.
The corresponding public key can be derived using ECC_PublicKeyFromPrivate
Together these provide the HKPE function
Note that these functions are intended to be used in an object-oriented language like C# or Python, not in raw ANSI C or VB6.
See the Python code
In this implementation, the KDF algorithm is chosen automatically to match the KEM ECDH group curve as follows (from Table 2 in [RFC9180]).
Furthermore, the ciphersuite's KDF is assumed to be always equal to the DHKEM's associated KDF from the above table.
Because these are all standalone functions with no context, the ECDH curve group used in the scheme must be specified. This automatically defines the KDF and associated HMAC algorithm to be used as per the above table.
LabeledExpand() functions facilitate domain separation of KDF calls by incorporating a
suite_id which has a value derived from identifiers for the EC curve group, the KDF algorithm and, sometimes, the AEAD algorithm.
Note that the
suite_id value is different depending on where the KDF is used.
In this implementation, specifying the curve name will automatically select the corresponding KDF algorithm, and the absence or presence of an option flag for
an AEAD algorithm dictates whether the KDF is being used inside a KEM algorithm (zero flag) or in the remainder of HPKE (specific AEAD algorithm flag).
The string literal "HPKE-v1" is currently hardcoded into the
Future implementations may offer an alternative if the specification is changed.
This is a "proof-of-concept" program to show that cryptosyspki.py v22.0 has all the features necessary to carry out the required computations for RFC9180 "Hybrid Public Key Encryption". It reads a cut-down version of the test-vectors.json file [TestVectors] and computes and verifies the values. Currently the code only supports mode 0.
|hpke_test.py||Test source code|
|test-vectors-1.json||Cut-down sample of test-vectors.json|
|hpke_test.zip||Download all as zip|
To contact us or comment on this page, please send us a message.
[Go to top]
This page last updated 26 October 2023