Skip to main content

Module crypto

Module crypto 

Source

Re-exports§

pub use aes_gcm::aes256_gcm_decrypt;
pub use aes_gcm::aes256_gcm_encrypt;
pub use const_time::constant_time_eq;
pub use hmac::hmac_sha256;
pub use page_encryption::key_from_env;
pub use sha256::sha256;
pub use sha256::Sha256;
pub use uuid::Uuid;

Modules§

aes_gcm
AES-256-GCM wrapper used by storage.
const_time
Constant-time byte-slice comparison.
hmac
HMAC helpers used by RedDB storage encryption.
os_random
OS-backed CSPRNG helpers.
page_encryption
Encryption-at-rest: server-side facade over the canonical reddb-io-crypto envelope (#1053, ADR 0054).
sha256
uuid

Enums§

PageEnvelopeError
Errors returned by the page-envelope surface. The caller (the pager) maps these to its own typed error.

Constants§

PAGE_ENVELOPE_OVERHEAD
Fixed envelope overhead per page: nonce (12) + tag (16) = 28. Plaintext expands by exactly this many bytes. This is the value the page-0 key_check slot (reddb_file) is sized against: PAGED_ENCRYPTION_KEY_CHECK_BLOB_SIZE = 32 (plaintext) + 28.

Functions§

decrypt_page
Decrypt an envelope produced by encrypt_page. page_id MUST match the value passed at encrypt time — a mismatch surfaces as PageEnvelopeError::KeyMismatch (the GCM tag check failing), which is the correct signal: an attacker swapping pages is functionally indistinguishable from a wrong key.
encrypt_page
Encrypt plaintext for storage as page page_id. page_id is bound as AAD (u32 LE), so swapping two pages on disk fails the tag check on decrypt.
parse_encryption_key
Parse a 32-byte AES key from a string — accepts hex (64 chars) or unpadded/padded standard base64 (43 or 44 chars). Tolerates leading/trailing whitespace including newlines.