0.18 round 2 (decrypt dedup): adopt DecryptingSectorSource at the two
existing call sites — sweep producer and DiscStream demux Round 1 shipped the DecryptingSectorSource decorator (libfreemkv/src/sector/decrypting.rs) but the existing decrypt sites kept calling crate::decrypt::decrypt_sectors inline. This commit migrates both: - Disc::sweep (disc/mod.rs): producer wraps the input reader in DecryptingSectorSource::new(reader, keys) before the read loop. The inline decrypt_sectors call goes away — read_sectors yields plaintext directly. - DiscStream (mux/disc.rs): constructor wraps the underlying Box<dyn SectorReader> in DecryptingSectorSource so the internal fill_extents / read path sees plaintext bytes. The DecryptKeys field stays on DiscStream for metadata-side use; it just no longer drives decryption. Disc::patch carried the same inline decrypt step at three call sites (main read, backtrack read, non-NOT_READY retry read). All three migrated onto the same wrapping for a single audit surface. Two small support changes carry the migration without touching the round-1 decorator shape: - sector/mod.rs gains specific SectorSource impls for &mut dyn SectorReader and Box<dyn SectorReader>, mirroring std's Read forwarding pattern. Generic blankets would conflict with the existing SectorReader → SectorSource blanket under the orphan rule (downstream could impl SectorReader for &mut U), so the impls are scoped to the dyn-trait shape we actually consume. - sector/decrypting.rs gains DecryptingSectorSource::set_keys so DiscStream::set_raw() can flip the wrapped reader to a DecryptKeys::None pass-through without rebuilding the decorator (which would require moving the inner Box out from behind &mut self). After this commit, grep `decrypt_sectors` in src/ shows the function definition, its single use inside DecryptingSectorSource, plus comments only. One audit surface for AACS / CSS / passthrough correctness. Behaviour-preserving: same plaintext bytes flow through; the only difference is which type owns the decrypt step. See (internal)/memory/0_18_redesign.md. Single contributor: MattJackson.
This commit is contained in:
@@ -53,6 +53,16 @@ impl<S: SectorSource> DecryptingSectorSource<S> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Replace the configured keys without unwrapping the decorator.
|
||||
/// Used by `DiscStream::set_raw()` to flip from encrypted-disc
|
||||
/// decryption to a pass-through after the inner reader is already
|
||||
/// owned by the wrapper. For new construction prefer [`new`].
|
||||
///
|
||||
/// [`new`]: Self::new
|
||||
pub fn set_keys(&mut self, keys: DecryptKeys) {
|
||||
self.keys = keys;
|
||||
}
|
||||
|
||||
/// Borrow the inner source. Useful for tests and for adapters
|
||||
/// that want to introspect the underlying drive / file without
|
||||
/// unwrapping the decorator.
|
||||
|
||||
Reference in New Issue
Block a user