Public-key encryption

HPKE-X25519-SHA-256-Aes128gcm

Hybrid Public Key Encryption: a KEM, a KDF and an AEAD combined per RFC 9180

unverified Root API only
Unverified tier.

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–2022
  1. Specified in RFC 9180

How it works

  1. Encap: the sender runs the KEM with the recipient's public key to get a shared secret and encapsulated key enc.
  2. KeySchedule: HKDF combines the shared secret, mode, info and optional PSK into an AEAD key, base nonce and exporter secret.
  3. Seal: messages are encrypted with the AEAD using a nonce derived from a sequence counter.
  4. 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

TLS Encrypted Client Hello (ECH)Messaging Layer Security (MLS)Oblivious HTTP and Oblivious DNSEncrypting data to a recipient's public key

Sizes

FieldBytesMeaning
out0 – 65,536Output
pk32Public key
sk32Secret key
ct48 – 65,584Ciphertext
ctx0 – 1,024Context 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]

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Frequently 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.