What changed, and why it matters
This commit removes a small internal wrapper type called Bytes that was used to pass around byte buffers. The code now returns the underlying byte buffer directly instead of wrapping it first. There is no visible security fix or behavior change beyond simplifying the code.
No security action required. Treat as a routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes the Bytes struct in util.rs and changes HasherExt::finalize() and wire_receive() to return the raw BoxedSlice<u8> instead of wrapping it in Bytes. The wrapper only implemented AsRef<[u8]>, so removing it does not alter the public API contract (both still return impl AsRef<[u8]>). No bounds checks, ownership, or lifetime rules are changed.
Changed components
sdk/crates/trezor-app-sdk/src/app_runtime/crypto.rssdk/crates/trezor-app-sdk/src/app_runtime/util.rssdk/crates/trezor-app-sdk/src/app_runtime/wire.rsInspect captured patch +3 / −15
### sdk/crates/trezor-app-sdk/src/app_runtime/crypto.rs
@@ -25,7 +25,6 @@ pub use crate::traits::crypto::{
BoxedHasher, CanonicalSig, Curve, EcdsaCurve, HashingAlgorithm, HmacAlgorithm, XPUB_RAW_LEN,
};
use crate::traits::crypto::{CryptoV1Dyn as _, HasherDynMut};
-use crate::util::Bytes;
use crate::{IntoAppResult, Result, ResultExt};
/// A local (non-IPC) streaming hasher for `algorithm` — see the module docs.
@@ -61,7 +60,7 @@ impl HasherExt for BoxedHasher {
}
fn finalize(mut self) -> impl AsRef<[u8]> {
- Bytes(HasherDynMut::finalize(&mut self))
+ HasherDynMut::finalize(&mut self)
}
}
### sdk/crates/trezor-app-sdk/src/app_runtime/util.rs
@@ -1,4 +1,3 @@
-use stabby::boxed::BoxedSlice;
use ufmt::derive::uDebug;
use crate::app_runtime;
@@ -102,16 +101,6 @@ impl<'a> AsRef<str> for SliceWriter<'a> {
}
}
-/// Bytes handed over by Core, exposed as `impl AsRef<[u8]>` without copying
-/// them out of the [`BoxedSlice`].
-pub(crate) struct Bytes(pub(crate) BoxedSlice<u8>);
-
-impl AsRef<[u8]> for Bytes {
- fn as_ref(&self) -> &[u8] {
- &self.0
- }
-}
-
#[cfg(test)]
mod tests {
use super::*;
### sdk/crates/trezor-app-sdk/src/app_runtime/wire.rs
@@ -3,7 +3,7 @@
use crate::app_runtime::get_wire_or_die;
use crate::traits::wire::{FailureKind, WireV1Dyn as _};
-use crate::util::{Bytes, Timeout};
+use crate::util::Timeout;
use crate::{IntoAppResult, Result, ResultExt, debug};
/// Waits for the next message from the host and returns its id and raw bytes.
@@ -15,7 +15,7 @@ pub fn wire_receive() -> Result<(u16, impl AsRef<[u8]>)> {
.c()?;
debug!("Received wire message: id={}", message.id);
- Ok((message.id, Bytes(message.data)))
+ Ok((message.id, message.data))
}
/// Sends a message to the host. On its own this is how a flow ends; mid-flowWhy this scored 12/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.