HPKE-X25519-SHA-256-Aes128gcm
Hybrid Public Key Encryption: a KEM, a KDF and an AEAD combined per RFC 9180
Source found and wired, correctness not fully proven. Root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About HPKE-X25519-SHA-256-Aes128gcm
HPKE-X25519-SHA-256-Aes128gcm is one of 3 HPKE variants in the NextSSL registry, a public-key encryption scheme. It uses a 0–65,536-byte output, a 32-byte public key, a 32-byte secret key, a 48–65,584-byte ciphertext and a 0–1,024-byte context string. Its registry entry cites RFC 9180. NextSSL lists it in the unverified tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
Overview
HPKE is a standard framework for encrypting messages to a recipient's public key by combining a key encapsulation mechanism, a key derivation function and an authenticated cipher. It replaces ad hoc ECIES variants and underpins TLS Encrypted Client Hello, MLS and Oblivious HTTP.
The sender runs the KEM against the recipient's public key to obtain a shared secret and an encapsulation. A key schedule built on HKDF derives an AEAD key, a base nonce and an exporter secret from that shared secret plus application-supplied info. The sender can then encrypt one or more messages in sequence, and the recipient decapsulates and derives the same context to decrypt.
RFC 9180 defines four modes: base, PSK (adds a pre-shared key), Auth (authenticates the sender with its own KEM key) and AuthPSK. Each ciphersuite is a triple of KEM, KDF and AEAD identifiers, and the design has a published security analysis. Post-quantum and hybrid KEMs such as ML-KEM can be slotted in as further suites. Three ciphersuites are present: DHKEM(P-256, HKDF-SHA256) with HKDF-SHA256 and AES-128-GCM; DHKEM(X25519, HKDF-SHA256) with HKDF-SHA256 and AES-128-GCM; and the same X25519 suite with ChaCha20-Poly1305.
History
2022–2022Specified in RFC 9180
How it works
- Encap: the sender runs the KEM with the recipient's public key to get a shared secret and encapsulated key enc.
- KeySchedule: HKDF combines the shared secret, mode, info and optional PSK into an AEAD key, base nonce and exporter secret.
- Seal: messages are encrypted with the AEAD using a nonce derived from a sequence counter.
- Open: the recipient decapsulates enc, runs the same key schedule and decrypts.
Security notes
The DHKEM suites present are not post-quantum. HPKE contexts must not be reused across too many messages, and in base mode the sender is not authenticated. NextSSL has not yet verified these suites against the RFC 9180 test vectors.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| out | 0 – 65,536 | Output |
| pk | 32 | Public key |
| sk | 32 | Secret key |
| ct | 48 – 65,584 | Ciphertext |
| ctx | 0 – 1,024 | Context string |
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'unverified' is reachable from the root API only
pk, sk = root.call("pke_keygen", "hpke-x25519-sha256-aes128gcm", None, outs=2)
ct = root.call("pke_encrypt", "hpke-x25519-sha256-aes128gcm", None, pk, b"secret", b"")[0]
nextssl_root_pke_encrypt("hpke-x25519-sha256-aes128gcm", NULL, pk, pt, label, out);
// pke is a root-only kind: use the C ABI (nextssl_root_*)
// or the Pke trait in nextssl-core/src/traits.rs
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other HPKE variants
2More public-key encryption
All 32Frequently asked questions
What is HPKE-X25519-SHA-256-Aes128gcm?
HPKE-X25519-SHA-256-Aes128gcm is a PKE in the HPKE family. HPKE is a standard framework for encrypting messages to a recipient's public key by combining a key encapsulation mechanism, a key derivation function and an authenticated cipher.
What are the HPKE-X25519-SHA-256-Aes128gcm sizes?
In NextSSL, HPKE-X25519-SHA-256-Aes128gcm uses: public key 32 bytes, ciphertext 48 to 65,584 bytes, output 0 to 65,536 bytes.
Who designed HPKE-X25519-SHA-256-Aes128gcm and when?
HPKE-X25519-SHA-256-Aes128gcm belongs to the HPKE family, first published in 2022 by Richard Barnes, Karthikeyan Bhargavan, Benjamin Lipp, Christopher A. Wood. Its origin: IETF RFC 9180 (CFRG).
Which standards define HPKE-X25519-SHA-256-Aes128gcm?
HPKE-X25519-SHA-256-Aes128gcm is referenced by RFC 9180.
Is HPKE-X25519-SHA-256-Aes128gcm safe to use?
HPKE-X25519-SHA-256-Aes128gcm is in the unverified tier. Source found and wired, correctness not fully proven. Root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).
What other HPKE variants are there?
NextSSL also registers hpke-p256-sha256-aes128gcm, hpke-x25519-sha256-chacha20poly1305 in the HPKE family.
Related families
Counter-mode AES with a GHASH polynomial MAC; the default AEAD of TLS and IPsec
ChaCha20-Poly1305ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
HKDFHMAC-based extract-and-expand key derivation function (RFC 5869)
ML-KEMNIST's primary post-quantum key encapsulation mechanism, standardised in FIPS 203
ECDH (including X25519 and X448)Elliptic-curve Diffie-Hellman key agreement on NIST curves, Curve25519 and Curve448
ChaChaBernstein's ARX stream cipher; ChaCha20 secures much of today's TLS, SSH and VPN traffic