Module auth

Module auth 

Source
Expand description

Password hashing, authentication credentials, and user security models.

Structs§

KekParams
KEK derivation parameters to be stored in the SQLite table users_key_encryption_key_params in users.db. For now this is a stub structure that you can later wire to Argon2id properly.

Functions§

derive_kek
Derive a Key Encryption Key (KEK) from a password using Argon2id. Returns the derived KEK and the salt used in the derivation. The KEK is suitable for AES-256 encryption. It’s not clear if this is all correct. See: https://docs.rs/argon2/latest/argon2/#key-derivation https://rustcrypto.org/key-derivation/index.html https://cheatsheetseries.owasp.org/cheatsheets/Key_Management_Cheat_Sheet.html#key-encryption-keys (last two are basically blank.)
derive_kek_with_params
Derive a Key Encryption Key (KEK) from a password using specific KekParams.
generate_dek
Generate a cryptographically secure 32-byte Database Encryption Key (DEK) using the OS random number generator.
open_bytes
Open sealed bytes (decrypt and verify authentication) using AES-256-GCM. Expects the 12-byte nonce prepended to the ciphertext.
seal_bytes
Seal bytes (encrypt and authenticate) using AES-256-GCM. Returns the nonce (12 bytes) prepended to the ciphertext.
unwrap_key
Unwrap the DEK using the KEK (Key Encryption Key) and AES-256-GCM. Expects the 12-byte nonce prepended to the ciphertext.
wrap_key
Wrap the DEK under a KEK (Key Encryption Key) using AES-256-GCM. Additional Authenticated Data (AAD) is used to prevent key substitution. Returns the nonce (12 bytes) prepended to the ciphertext.