Crates.io | hpke-dispatch |
lib.rs | hpke-dispatch |
version | 0.7.0 |
source | src |
created_at | 2022-04-19 19:26:53.81689 |
updated_at | 2024-07-11 22:46:06.104885 |
description | runtime algorithmic selection for hybrid public key encryption |
homepage | |
repository | https://github.com/divviup/hpke-dispatch |
max_upload_size | |
id | 570607 |
size | 6,206,895 |
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
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
. For an example of using the library from
node, see examples/example.ts
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
.
cfg_eval
: allows this crate to be built on nightly rust for wasm
without algo-all
. Note that algo-all
(all
algorithms) will build for wasm on any channel without this feature.
disabled by default. Attempting to build for wasm with a subset.
base-mode-open: Enables hpke base-mode one-shot open behavior (receiver functionality). Enabled by default.
base-mode-seal: Enables hpke base-mode one-shot seal behavior (sender functionality). Enabled by default.
algo-all: enables all aead, kdf, and kem algorithms. enabled by default.
aead-all: Enables aead-aes-gcm-128
, aead-aes-gcm-256
, and
aead-chacha-20-poly-1305
algorithm features. Enabled by default.
kdf-all: Enables kdf-sha256
, kdf-sha384
, kdf-sha512
algorithm features. Enabled by default.
kem-all: Enables kem-dh-p256-hkdf-sha256
,
kem-dh-p384-hkdf-sha384
, kem-dh-p521-hkdf-sha512
, and
kem-x25519-hkdf-sha256
algorithm features. Enabled by default.
serde: enables derived serde serialization and deserialization for all public structs and enums. Disabled by default.
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