refactor(rust/trezor-thp): add Mux::reset()
What changed, and why it matters
This commit adds a new 'reset' method to two internal Rust channel objects in the Trezor firmware's THP (Trezor Host Protocol) code. The method simply restores the channel to its freshly-created state, discarding any pending messages or connection bookkeeping. There is no indication in the commit that this fixes a security bug; it reads as a routine code cleanup or preparation for future use.
No security action required based on this commit alone. Treat as normal refactoring. If reviewing a larger change set, verify that any new caller of `Mux::reset()` handles in-flight messages safely and does not introduce state-desynchronization between device and host.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces Mux::reset() on both device-side and host-side Mux structs in rust/trezor-thp/src/channel/device.rs and rust/trezor-thp/src/channel/host.rs. The implementation is *self = Self::new(), which reinitializes the mux to its default state. Comments state it discards outgoing messages/keep-alive and channel allocation. No call sites are added, no existing behavior is changed, and no security relevance is claimed by the vendor.
Changed components
rust/trezor-thp/src/channel/device.rsrust/trezor-thp/src/channel/host.rsInspect captured patch +10 / −0
diff --git a/rust/trezor-thp/src/channel/device.rs b/rust/trezor-thp/src/channel/device.rs
index 0ba02e2e..6a59b091 100644
--- a/rust/trezor-thp/src/channel/device.rs
+++ b/rust/trezor-thp/src/channel/device.rs
@@ -73,6 +73,11 @@ where
}
}
+ /// Reset everything to initial state - discard outgoing messages and channel allocation.
+ pub fn reset(&mut self) {
+ *self = Self::new()
+ }
+
/// Create new [`ChannelOpen`] when channel allocation request is pending.
pub fn channel_alloc<C>(
&mut self,
diff --git a/rust/trezor-thp/src/channel/host.rs b/rust/trezor-thp/src/channel/host.rs
index 0f5ed45c..90807bab 100644
--- a/rust/trezor-thp/src/channel/host.rs
+++ b/rust/trezor-thp/src/channel/host.rs
@@ -80,6 +80,11 @@ where
}
}
+ /// Reset everything to initial state - discard keep-alive and channel allocation.
+ pub fn reset(&mut self) {
+ *self = Self::new()
+ }
+
/// Enqueue a keep-alive message.
pub fn ping(&mut self) {
if !matches!(self.ping, PingState::None) {
Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.