Skip to main content

Module crypto

Module crypto 

Source
Expand description

Low-level cryptography primitives for tsafe.

Key derivation: Argon2id with tunable cost parameters. Encryption: XChaCha20-Poly1305 by default, with optional AES-256-GCM support behind the fips feature flag. All secret material is handled via Zeroizing wrappers so keys are wiped from heap memory on drop.

Structs§

VaultKey
A 256-bit key that is zeroed from memory on drop.

Enums§

CipherKind
Cipher selection for vault/team ciphertext on disk.
KeyPurpose
Purpose labels for HKDF expansion. Adding new purposes must use a distinct label so old ciphertext domains remain isolated.
KeySchedule
The on-disk vault format historically used the root key directly. Newer vaults keep the same file format but scope encryption through HKDF-derived purpose keys so challenge/data material do not share a key.

Constants§

KEY_LEN
NONCE_LEN
SALT_LEN
VAULT_KDF_M_COST
VAULT_KDF_P_COST
VAULT_KDF_T_COST
XCHACHA20POLY1305_NONCE_LEN

Functions§

decode_b64
decrypt
Decrypt with XChaCha20-Poly1305. Authentication failure returns DecryptionFailed.
decrypt_for_cipher
decrypt_with_key_schedule
default_vault_cipher
derive_key
Derive a 256-bit key from a password + salt using Argon2id.
derive_labeled_subkey
Derive a 256-bit subkey from a root key using an explicit HKDF label.
derive_subkey
Derive a purpose-scoped 256-bit subkey from a root key using HKDF-SHA256.
detect_key_schedule
Detect which key schedule was used for a known-plaintext record.
encode_b64
encrypt
Encrypt plaintext with XChaCha20-Poly1305. Returns (nonce, ciphertext).
encrypt_for_cipher
encrypt_with_key_schedule
parse_cipher_kind
random_nonce
random_salt
snap_decrypt
Decrypt a snap blob received from the snap server.
snap_encrypt
Encrypt a plaintext string for one-time snap sharing.