Expand description
hpke-ng — RFC 9180 HPKE implementation.
§Example
use hpke_ng::*;
use rand_core::{OsRng, TryRngCore as _};
type Suite = Hpke<DhKemX25519HkdfSha256, HkdfSha256, ChaCha20Poly1305>;
let mut os = OsRng;
let mut rng = os.unwrap_mut();
let (sk_r, pk_r) = DhKemX25519HkdfSha256::generate(&mut rng).unwrap();
let (enc, ct) =
Suite::seal_base(&mut rng, &pk_r, b"info", b"aad", b"hello").unwrap();
let pt = Suite::open_base(&enc, &sk_r, b"info", b"aad", &ct).unwrap();
assert_eq!(pt, b"hello");See the Readme for design notes and the constant-time disclosure table.
Re-exports§
pub use kem::AuthKem;pub use kem::Kem;pub use kem::dh::DhKemK256HkdfSha256;pub use kem::dh::DhKemP256HkdfSha256;pub use kem::dh::DhKemP384HkdfSha384;pub use kem::dh::DhKemP521HkdfSha512;pub use kem::dh::DhKemX448HkdfSha512;pub use kem::dh::DhKemX25519HkdfSha256;
Modules§
- kem
- HPKE Key Encapsulation Mechanisms (RFC 9180 §4 + §7.1).
Structs§
- Aes128
Gcm - AES-128-GCM (RFC 9180 §7.3, ID
0x0001). - Aes256
Gcm - AES-256-GCM (RFC 9180 §7.3, ID
0x0002). - ChaCha20
Poly1305 - ChaCha20-Poly1305 (RFC 9180 §7.3, ID
0x0003). - Context
- HPKE encryption/decryption context.
- Export
Only - Export-only “AEAD” marker (RFC 9180 §7.3, ID
0xFFFF). - Hkdf
Sha256 - HKDF-SHA-256 (RFC 9180 §7.2, ID
0x0001). - Hkdf
Sha384 - HKDF-SHA-384 (RFC 9180 §7.2, ID
0x0002). - Hkdf
Sha512 - HKDF-SHA-512 (RFC 9180 §7.2, ID
0x0003). - Hpke
- HPKE configuration parameterized over a KEM, KDF, and AEAD.
Enums§
- Hpke
Error - All error conditions raised by
hpke-ng.
Traits§
- Aead
- Sealed trait for HPKE-supported AEAD ciphersuite components.
- Kdf
- Sealed trait for HPKE-supported KDFs.
- Sealing
Aead - Marker subtrait for AEADs that actually encrypt (i.e. not export-only).