pub struct IvStash { /* private fields */ }Expand description
Remembers the IV used for each (plaintext, aad) pair so re-encrypting an
unchanged value reproduces its exact previous ciphertext.
This is not an optimisation. sops edit decrypts, hands the tree to an
editor, and re-encrypts everything; without the stash every line of the
file changes on every edit, which destroys the property the whole format
exists for — a readable, reviewable diff. Upstream calls it stash and keys
it on exactly the same pair.
The security shape is worth stating rather than inheriting silently: two identical values at the same path reuse a nonce under one data key. Since the plaintexts are identical, GCM’s nonce-reuse failure reveals nothing an attacker did not already have (equal ciphertext for equal plaintext, which deterministic encryption concedes by construction). It is a knowing trade, not an oversight, and it is confined to unchanged values.
Implementations§
Source§impl IvStash
impl IvStash
pub fn new() -> Self
Sourcepub fn remember(&mut self, plaintext: &Plaintext, aad: &Aad, iv: &[u8])
pub fn remember(&mut self, plaintext: &Plaintext, aad: &Aad, iv: &[u8])
Record the IV a leaf was decrypted with, so an unchanged value keeps it.
Sourcepub fn recall(&self, plaintext: &Plaintext, aad: &Aad) -> Option<Iv>
pub fn recall(&self, plaintext: &Plaintext, aad: &Aad) -> Option<Iv>
The remembered IV for this pair, if any.