package granary
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/granary.storage/Granary_storage/Crypto/index.html
Module Granary_storage.CryptoSource
Per-page AES-256-GCM codec for at-rest encryption (#84).
Pure: no I/O. The application supplies a 32-byte raw key; nonces are freshly generated per call via Mirage_crypto_rng (the application must seed the RNG at boot — lib/ never seeds, to stay Mirage-clean).
On-disk encrypted page layout (length n = page_size):
[ ciphertext : n - overhead ] [ nonce : nonce_len ] [ tag : tag_len ] The encrypted region is the logical page minus the reserved tail; the B+-tree already keeps its data within that region.
Pretty-printer for t (redacts key material).
16
16
32 — reserved bytes an encrypted page must carve off its tail
Build a cipher from raw key material. Error `Bad_key_length unless the key is exactly 32 bytes (AES-256).
Encrypt the page in place: encrypts bytes 0 .. len-overhead), then writes the freshly-generated nonce and the auth tag into the reserved tail. AAD is the [page_id], binding the ciphertext to its slot. [buf] length must be > [overhead].
Total WAL-frame decrypt invocations since process start. Observability hook used by tests to assert the #246 decrypted-frame cache serves repeated reads with zero extra decrypts and that authentication still runs on every fresh WAL fill. Monotonic; never reset.
Decrypt the page in place: verifies the tag over 0 .. len-overhead) using the tail nonce and [page_id] AAD, writes plaintext back, and zeroes the reserved tail (so the page's pre-seal CRC over a zeroed tail still verifies). [Error `Tag_mismatch] on a wrong key or tampering.
Encrypt a WAL frame payload. Returns a fresh buffer of length Cstruct.length plaintext + overhead: ciphertext nonce tag .
Decrypt a WAL frame payload produced by encrypt_frame. payload length must be plaintext_len + overhead; returns the plaintext_len plaintext or Error `Tag_mismatch.
Fixed associated data for the key-check canary.
make_canary t ~nonce returns the tag_len-byte GCM tag over an empty message with canary_adata, under t's key and nonce.