From fbdfccdd8343d213bfd74771c9f6f7fd5fe327d4 Mon Sep 17 00:00:00 2001 From: MattJackson <1085847+MattJackson@users.noreply.github.com> Date: Tue, 14 Apr 2026 23:42:14 +0000 Subject: [PATCH] =?UTF-8?q?Add=20keys()=20to=20IOStream=20trait=20?= =?UTF-8?q?=E2=80=94=20streams=20know=20their=20own=20decrypt=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - IOStream::keys() default returns DecryptKeys::None - IsoStream and DiscStream override with real AACS/CSS keys - Pipeline calls input.keys() instead of separate scan_keys() - Streams are self-contained: read bytes + provide keys --- src/mux/disc.rs | 10 +++++++++- src/mux/iso.rs | 4 +++- src/mux/mod.rs | 10 ++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/mux/disc.rs b/src/mux/disc.rs index ccb1028..0d73606 100644 --- a/src/mux/disc.rs +++ b/src/mux/disc.rs @@ -23,6 +23,7 @@ use std::path::Path; pub struct DiscStream { drive: Drive, title: DiscTitle, + decrypt_keys: crate::decrypt::DecryptKeys, // What to read mode: ReadMode, @@ -120,7 +121,9 @@ impl DiscStream { } let title = disc.titles[title_index].clone(); - let stream = Self::title(drive, title); + let keys = disc.decrypt_keys(); + let mut stream = Self::title(drive, title); + stream.decrypt_keys = keys; Ok(DiscOpenResult { stream, disc }) } @@ -155,6 +158,7 @@ impl DiscStream { Self { drive, title, + decrypt_keys: crate::decrypt::DecryptKeys::None, mode, current_lba: 0, current_extent: 0, @@ -293,6 +297,10 @@ impl IOStream for DiscStream { ReadMode::Sequential { capacity } => Some(*capacity as u64 * 2048), } } + + fn keys(&self) -> crate::decrypt::DecryptKeys { + self.decrypt_keys.clone() + } } impl Read for DiscStream { diff --git a/src/mux/iso.rs b/src/mux/iso.rs index e68abe7..421afc1 100644 --- a/src/mux/iso.rs +++ b/src/mux/iso.rs @@ -231,13 +231,15 @@ impl IOStream for IsoStream { Ok(()) } fn total_bytes(&self) -> Option { - // Read mode: size is known from disc scan if self.reader.is_some() { Some(self.disc_title.size_bytes) } else { None } } + fn keys(&self) -> DecryptKeys { + self.decrypt_keys.clone() + } } impl Read for IsoStream { diff --git a/src/mux/mod.rs b/src/mux/mod.rs index 8ea8a15..4911621 100644 --- a/src/mux/mod.rs +++ b/src/mux/mod.rs @@ -36,8 +36,8 @@ pub mod resolve; pub mod stdio; pub mod ts; -pub use disc::{DiscOptions, DiscStream}; -pub use iso::IsoStream; +pub use disc::{DiscOpenResult, DiscStream}; +pub use iso::{IsoSectorReader, IsoStream}; pub use m2ts::M2tsStream; pub use mkvstream::MkvStream; pub use network::NetworkStream; @@ -63,6 +63,12 @@ pub trait IOStream: Read + Write { fn total_bytes(&self) -> Option { None } + + /// Decryption keys for this stream. Default: no encryption. + /// Overridden by DiscStream and IsoStream for AACS/CSS. + fn keys(&self) -> crate::decrypt::DecryptKeys { + crate::decrypt::DecryptKeys::None + } } // Combined traits for internal trait objects.