Hybrid public key encryption with algorithms dispatched at runtime

This crate provides a generic-free interface to the hpke crate, a rust implementation of the draft RFC9180 hybrid public key encryption scheme. If you know the specific (aead, kdf, kem) triple at compile time, you should use the hpke crate directly.

Currently, this crate only exposes interfaces for the Base mode (0) described in the hpke draft, and within base mode, only stateless single-shot message encryption/decryption, as defined in RFC9180ยง6

Web-assembly ready

This crate is also published to npm as hpke as a typescript/javascript package, and can also be custom built for specific wasm use cases (omitting unused algorithms) with wasm-pack

Nightly-only feature to work around a wasm-bindgen bug: cfg_eval

In order to opt out of algo-all for a wasm build, you must use nightly and enable the cfg_eval cargo feature. This is due to wasm-bindgen#2058. This is not necessary for use from rust, even when opting out of algo-all.

Available cargo features:

Example feature usage:

To depend on this crate from rust with all algorithms, base-mode-open, and base-mode-seal, use default features.

To depend on this crate from rust with all algorithms and serde enabled, but without base-mode-seal: default-features = false, features = ["algo-all", "base-mode-open", "serde"]

To build for wasm without kem-x25519-hkdf-sha256 or base-mode-open: wasm-pack build --no-default-features --features aead-all,kdf-all,kem-dh-p256-hkdf-sha256,base-mode-seal,cfg_eval

To build for wasm with all algorithms but without base-mode-open: wasm-pack build --no-default-features --features algo-all,base-mode-seal