Expand description
§RustCrypto: Diffie-Hellman-Based KEM
Pure Rust implementation of the Diffie-Hellman-Based Key-Encapsulation Mechanism as described in the RFC9180 § 4.1.
§About
Key Encapsulation Mechanisms (KEMs) provide a common API for establishing a symmetric key using public-key cryptography.
This crate implements a KEM-based API for elliptic curve Diffie-Hellman as specified for Hybrid Public Key Encryption (HPKE) which is described in RFC9180.
§⚠️ Security Warning
The implementation contained in this crate has never been independently audited!
USE AT YOUR OWN RISK!
§Minimum Supported Rust Version (MSRV) Policy
MSRV increases are not considered breaking changes and can happen in patch releases.
The crate MSRV accounts for all supported targets and crate feature combinations, excluding explicitly unstable features.
§License
Licensed under either of:
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
§Diffie-Hellman (DH) based Key Encapsulation Mechanisms (KEM)
This crate provides a KEM interface for DH protocols as specified in RFC9180 without the shared secret extraction process.
In particular, Encaps(pk) in the RFC returns the encapsulated key and an extracted shared
secret, while our implementation leaves the extraction process up to the user.
This type of KEM construction is currently being used in HPKE, as per the RFC, and in the current draft of the TLS KEM combiner.
§Supported elliptic curves
Support for specific elliptic curves is gated behind the following features:
k256: secp256k1p256: NIST P-256p384: NIST P-384p521: NIST P-521
Re-exports§
pub use kem;
Structs§
- Decapsulation
Key - Newtype for a piece of data that may be decapsulated
- EcdhKem
ecdh - Generic Elliptic Curve Diffie-Hellman KEM adapter compatible with curves implemented using
traits from the
elliptic-curvecrate. - Encapsulation
Key - Newtype for a piece of data that may be encapsulated
- X25519
Kem x25519 - X22519 Diffie-Hellman KEM adapter.
Traits§
- Decapsulator
- Trait for decapsulators, which is a supertrait bound of both
DecapsulateandTryDecapsulate. - DhKem
- This is a trait that all KEM models should implement, and should probably be promoted to the kem crate itself. It specifies the types of encapsulating and decapsulating keys created by key generation, the shared secret type, and the encapsulated key type
- Encapsulate
- Encapsulator for shared secrets.
- Generate
- Secure random generation.
- KemParams
- Key encapsulation mechanism parameters: sizes of the ciphertext and decrypted plaintext.
- TryDecapsulate
- Decapsulator for encapsulated keys with failure handling, with an associated
Encapsulatorbounded by theEncapsulatetrait.
Type Aliases§
- Ecdh
Decapsulation Key ecdh - Elliptic Curve Diffie-Hellman Decapsulation Key (i.e. secret decryption key)
- Ecdh
Encapsulation Key ecdh - Elliptic Curve Diffie-Hellman Encapsulation Key (i.e. public encryption key)
- Nist
P256 Decapsulation Key p256 - NIST P-256 ECDH Decapsulation Key.
- Nist
P256 Encapsulation Key p256 - NIST P-256 ECDH Encapsulation Key.
- Nist
P384 Decapsulation Key p384 - NIST P-384 ECDH Decapsulation Key.
- Nist
P384 Encapsulation Key p384 - NIST P-384 ECDH Encapsulation Key.
- Nist
P521 Decapsulation Key p521 - NIST P-521 ECDH Decapsulation Key.
- Nist
P521 Encapsulation Key p521 - NIST P-521 ECDH Encapsulation Key.
- Secp256k1
Decapsulation Key k256 - secp256k1 ECDH Decapsulation Key.
- Secp256k1
Encapsulation Key k256 - secp256k1 ECDH Encapsulation Key.
- X25519
Decapsulation Key x25519 - Elliptic Curve Diffie-Hellman Decapsulation Key (i.e. secret decryption key)
- X25519
Encapsulation Key x25519 - Elliptic Curve Diffie-Hellman Encapsulation Key (i.e. public encryption key)