Skip to main content

Module crypto

Module crypto 

Source
Expand description

Key management + AEAD encryption (pure Rust — RustCrypto, no C deps, so wasm32 and mobile cross-builds stay clean; same algorithms as @combs/zerotrust’s WebCrypto stack).

Layout of an encrypted payload: nonce (12 bytes, random) || ciphertext || tag — the nonce travels with the message, keys never leave the KeyRing (master key held in Zeroizing).

A process-wide keyring lives behind OnceLock<RwLock<…>> with init/shutdown/global so the FFI crate (combsmesh_init / combsmesh_shutdown) is a thin shim over this module.

Structs§

KeyRing
Holds the master key and derives purpose-specific subkeys via HKDF-SHA256. Key material is zeroized on drop.

Constants§

DEFAULT_HKDF_INFO
Default HKDF info string for emoji-at-rest encryption subkeys.
NONCE_LEN
Nonce size in bytes (96-bit, the standard AEAD nonce).

Functions§

global
Returns a clone of the process-wide keyring, or MeshError::NotInitialized when init was never called.
init
Initializes the process-wide keyring (combsmesh_init semantics). None generates a random master key. Replaces any existing keyring.
shutdown
Drops the process-wide keyring, zeroizing the master key (combsmesh_shutdown semantics).