1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Sensitive material wrapped with `secure-gate`.
//!
//! Internal only: the public [`crate::decrypt`] and [`crate::encrypt`] APIs
//! still take `password: &str` and return a plain `Vec<u8>`. Everything that
//! used to be zeroized by hand via `zeroize::Zeroizing` is wrapped here
//! instead — `secure-gate` is this crate's only zeroizing primitive now, not
//! an addition alongside `zeroize` — and so is every package plaintext
//! between a cipher and a zip, in either direction.
//!
//! The encrypt arc (`docs/plans/odf-encryption-encrypt-2026-09-03.md`) landed
//! without needing an alias of its own: key derivation is shared with decrypt
//! (`crate::kdf`), so the writer side reuses [`PasswordDigest`] and
//! [`DerivedKey`] verbatim, and its deflated-then-sealed buffer is the same
//! material as [`DeflatedPlaintext`] travelling the other way. Its salt and
//! IV are *not* wrapped: both are written to the manifest in the clear, so
//! they are public by construction, exactly like the KDF parameters they sit
//! beside. The plaintext the caller hands `encrypt()` stays plain for the
//! same reason `password: &str` does — the caller already owns it.
//! # These five are names, not types
//!
//! All five are `Dynamic<Vec<u8>>`, so they are the *same* nominal type and are
//! freely substitutable: passing a [`PasswordDigest`] where a [`DerivedKey`] is
//! expected compiles. What they buy is a greppable name and zeroize-on-drop, not
//! type safety.
//!
//! `secure-gate` deleted its `dynamic_alias!` macro in 0.9.0-rc.9 over exactly
//! this reading — a macro from a crate whose pitch is "accidents must not
//! compile" looked like it guaranteed a type when it only ever emitted a `type`
//! line. The replacement is [`dynamic_newtype!`], which emits a `struct` and
//! would make the five distinct. Adopting it is deliberately deferred: it is a
//! separate design change, and rc.11 is still actively moving that macro's
//! `derive:` surface. Stated here rather than left to be rediscovered.
//!
//! [`dynamic_newtype!`]: https://docs.rs/secure-gate/latest/secure_gate/macro.dynamic_newtype.html
use Dynamic;
/// SHA-1 or SHA-256 digest of the user's password (`start_key`'s output),
/// before KDF stretching. Length depends on the digest algorithm (20 or 32
/// bytes), so this wraps `Vec<u8>`, not a fixed-size array.
pub type PasswordDigest = ;
/// The password itself, re-encoded or padded for hashing: the MS-1252 bytes
/// of `crate::ms1252::encode`, and the final padded block(s) of
/// `crate::kdf`'s StarOffice SHA-1. Only the legacy start-key ladder makes
/// either; the correct digests hash `password.as_bytes()` in place.
///
/// A fifth alias rather than a reuse of [`PasswordDigest`], because these
/// bytes are not a digest and a reader grepping for where the password
/// itself is copied should find them.
pub type PasswordBytes = ;
/// PBKDF2/Argon2id-derived cipher key. On the read side its length (16/24/32
/// bytes) follows `EntryEncryption::derived_key_len`, so this wraps `Vec<u8>`,
/// not a fixed-size array; `encrypt` reuses it at its own fixed 32, since both
/// directions fill it through the same `crate::kdf` helpers.
pub type DerivedKey = ;