add securechip_model to securechip HAL
What changed, and why it matters
This commit is a small internal code cleanup. It moves the way the firmware asks for the secure chip model from a direct function call into the hardware abstraction layer (HAL), so the same code can be tested more easily. There is no change to user-facing behavior, no bug fix, and no security improvement or weakening visible in the diff.
No security action required. Review as normal refactoring if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds a model() method to the SecureChip trait in the Rust HAL and implements it for both the real BitBox02SecureChip and the test mock. The device_info API handler is updated to call hal.securechip().model()? instead of securechip::model()?. The returned model enum and string mapping are unchanged. This is purely an architectural refactor to improve testability and abstraction consistency.
Changed components
src/rust/bitbox02-rust/src/hal.rssrc/rust/bitbox02-rust/src/hww/api/device_info.rsInspect captured patch +10 / −1
diff --git a/src/rust/bitbox02-rust/src/hal.rs b/src/rust/bitbox02-rust/src/hal.rs
index 4cd3550..5da76bc 100644
--- a/src/rust/bitbox02-rust/src/hal.rs
+++ b/src/rust/bitbox02-rust/src/hal.rs
@@ -54,6 +54,7 @@ pub trait SecureChip {
signature: &mut [u8; 64],
) -> Result<(), ()>;
fn monotonic_increments_remaining(&mut self) -> Result<u32, ()>;
+ fn model(&mut self) -> Result<bitbox02::securechip::Model, ()>;
}
/// Hardware abstraction layer for BitBox devices.
@@ -148,6 +149,10 @@ impl SecureChip for BitBox02SecureChip {
fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
bitbox02::securechip::monotonic_increments_remaining()
}
+
+ fn model(&mut self) -> Result<bitbox02::securechip::Model, ()> {
+ bitbox02::securechip::model()
+ }
}
pub struct BitBox02Hal {
@@ -362,6 +367,10 @@ pub mod testing {
fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
Ok(1)
}
+
+ fn model(&mut self) -> Result<bitbox02::securechip::Model, ()> {
+ Ok(bitbox02::securechip::Model::ATECC_ATECC608B)
+ }
}
pub struct TestingHal<'a> {
diff --git a/src/rust/bitbox02-rust/src/hww/api/device_info.rs b/src/rust/bitbox02-rust/src/hww/api/device_info.rs
index b7f5308..7cd03fa 100644
--- a/src/rust/bitbox02-rust/src/hww/api/device_info.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/device_info.rs
@@ -39,7 +39,7 @@ pub fn process(hal: &mut impl crate::hal::Hal) -> Result<Response, Error> {
version: crate::version::FIRMWARE_VERSION_SHORT.into(),
mnemonic_passphrase_enabled: memory::is_mnemonic_passphrase_enabled(),
monotonic_increments_remaining: hal.securechip().monotonic_increments_remaining()?,
- securechip_model: match securechip::model()? {
+ securechip_model: match hal.securechip().model()? {
securechip::Model::ATECC_ATECC608A => "ATECC608A".into(),
securechip::Model::ATECC_ATECC608B => "ATECC608B".into(),
securechip::Model::OPTIGA_TRUST_M_V3 => "OPTIGA_TRUST_M_V3".into(),
Why this scored 15/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.