capsule_core/crypto/encryption/mod.rs
1//! Asset and metadata encryption — the only place AES-256-GCM is invoked for user data.
2//!
3//! Three constructions (SSoT: [Cryptography — Encryption]):
4//! - `stream` — AES-256-GCM STREAM for asset bytes (originals + derivatives), supporting
5//! streaming, ranged reads, and per-chunk authentication.
6//! - `blob` — standalone AES-256-GCM with a fixed wire format for small metadata blobs.
7//! - `keywrap` — `asset-keywrap/v1` seal/unseal for an externally-chosen file key carried
8//! under `key_mode = wrapped` (an adopted web-upload drop).
9//! - `rekey` — the re-keying writers that fold a fresh nonce into the key salt and refuse
10//! to reuse the nonce they supersede (a same-epoch `replace` / `metadata-update`).
11//!
12//! [Cryptography — Encryption]: https://docs/design/cryptography/encryption/
13
14mod blob;
15mod keywrap;
16mod rekey;
17mod stream;
18
19// Every public item of the four modules, because this barrel is their only public path
20// (#480). The chunk geometry and the `_vec` helpers were reachable only through the long
21// path and are not incidental: `capsule-wasm` and `xtask`'s share KAT both re-derive an
22// asset's nonce prefix, which is what makes a browser-opened share link decrypt to the same
23// bytes the importer sealed.
24pub use blob::{
25 MIN_BLOB_LEN, NONCE_LEN, blob_ciphertext_hash, blob_nonce, blob_suite_id, open_blob, seal_blob,
26 seal_blob_with_nonce,
27};
28pub use keywrap::{
29 WRAP_NONCE_LEN, WRAPPED_FILE_KEY_LEN, recover_file_key, recover_file_key_parts, seal_file_key,
30 unseal_file_key,
31};
32pub use rekey::{
33 RekeyStreamError, encrypt_asset_rekey, encrypt_asset_rekey_stream,
34 encrypt_asset_rekey_stream_with_prefix, encrypt_asset_rekey_with_prefix, seal_metadata_blob,
35 seal_metadata_blob_with_nonce,
36};
37pub use stream::{
38 AssetEncryption, CIPHERTEXT_CHUNK, CiphertextReader, NONCE_PREFIX_LEN, PLAINTEXT_CHUNK,
39 StreamDecryptor, StreamError, TAG_LEN, chunk_count, ciphertext_len, decrypt_asset,
40 decrypt_asset_vec, decrypt_chunk, encrypt_asset, encrypt_asset_vec, encrypt_asset_vec_full,
41 encrypt_asset_vec_with_prefix, encrypt_asset_with_prefix, encrypt_chunk,
42};