Skip to main content

Crate hpke_dispatch

Crate hpke_dispatch 

Source
Expand description

§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 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 described in the HPKE specification, and within base mode, only stateless single-shot message encryption/decryption, as defined in Section 6, “Single-Shot APIs”.

The algorithms supported in this crate and their codepoints are as described in the HPKE specification and draft-ietf-hpke-pq.

§Available cargo features:

hpke-dispatch’s cargo features are designed to align directly with those of hpke. See that crate’s documentation for discussion of how to selectively enable algorithms.

hpke-dispatch defines the following additional features:

  • algo-all: enables all aead, kdf, and kem algorithms. Enabled by default.

  • aead-all: Enables aes and chacha algorithm features. Enabled by default.

  • kdf-all: Enables hkdfsha2 and shake algorithm features. Enabled by default.

  • kem-all: Enables x25519, nistp and mlkem algorithm features. Enabled by default.

  • serde: Enables derived serde serialization and deserialization for all public structs and enums. Disabled by default.

§Example feature usage:

To depend on this crate with all algorithms, use default features.

To depend on this crate with only AES, NIST curves, SHA-2 and Serde enabled, use default-features = false, features = ["aes", "hkdfsha2", "nistp", "serde"].

Structs§

Config
Configuration for crate interfaces.
EncappedKeyAndCiphertext
Encapsulated key and ciphertext.
IdLookupError
A simple error type for failed id lookups
Keypair
An encoded keypair

Enums§

Aead
An authenticated encryption with additional data encryption function, as per RFC9180§7.3.
HpkeError
Describes things that can go wrong in the HPKE protocol
Kdf
A key derivation function used in HPKE.
Kem
An asymmetric key encapsulation mechanism.

Constants§

AEAD_ALL
An iterable slice of Aead variants
KDF_ALL
An iterable slice of Kdf variants
KEM_ALL
An iterable slice of Kem variants

Functions§

base_mode_open
Single-shot HPKE ciphertext opening.
base_mode_seal
Single-shot HPKE ciphertext sealing.
gen_keypair
generate a Keypair for the provided asymmetric key encapsulation mechanism (Kem)