hal/securechip: mark monotonic_increments_remaining async
What changed, and why it matters
This commit is a routine internal refactoring: it changes one function in the secure-chip hardware abstraction layer from synchronous to asynchronous. It does not fix a bug, change any security behavior, or alter how data is validated. It only adjusts how the firmware waits for the secure chip's answer when reporting how many times a one-way counter can still be incremented.
No security action needed; treat as normal code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch marks monotonic_increments_remaining as async across the SecureChip trait and all implementations (host fake, BitBox02, BitBox03). The caller in device_info::process is updated to .await the call, and process_api already awaited the device-info handler. No logic, return values, error handling, or access-control checks are changed. The change is purely an async/await plumbing refactor.
Changed components
src/rust/bitbox-hal/src/securechip.rssrc/rust/bitbox-platform-host/src/securechip.rssrc/rust/bitbox02-rust/src/hww/api.rssrc/rust/bitbox02-rust/src/hww/api/device_info.rssrc/rust/bitbox02/src/hal/securechip.rssrc/rust/bitbox03/src/securechip.rsInspect captured patch +8 / −7
diff --git a/src/rust/bitbox-hal/src/securechip.rs b/src/rust/bitbox-hal/src/securechip.rs
index 82f1414..13fdb4d 100644
--- a/src/rust/bitbox-hal/src/securechip.rs
+++ b/src/rust/bitbox-hal/src/securechip.rs
@@ -47,6 +47,7 @@ pub enum SecureChipError {
OptigaUnexpectedLen = -206,
}
+#[allow(async_fn_in_trait)]
pub trait SecureChip {
/// Returns 32 bytes of randomness generated by the secure chip.
fn random(&mut self) -> Result<Box<zeroize::Zeroizing<[u8; 32]>>, Error>;
@@ -88,7 +89,7 @@ pub trait SecureChip {
) -> Result<(), ()>;
/// Returns the remaining number of secure-chip monotonic counter increments.
- fn monotonic_increments_remaining(&mut self) -> Result<u32, ()>;
+ async fn monotonic_increments_remaining(&mut self) -> Result<u32, ()>;
/// Returns the detected secure-chip model.
fn model(&mut self) -> Result<Model, ()>;
diff --git a/src/rust/bitbox-platform-host/src/securechip.rs b/src/rust/bitbox-platform-host/src/securechip.rs
index 0cd53d4..8d6dfe9 100644
--- a/src/rust/bitbox-platform-host/src/securechip.rs
+++ b/src/rust/bitbox-platform-host/src/securechip.rs
@@ -144,7 +144,7 @@ impl bitbox_hal::SecureChip for FakeSecureChip {
Ok(())
}
- fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
+ async fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
Ok(1)
}
diff --git a/src/rust/bitbox02-rust/src/hww/api.rs b/src/rust/bitbox02-rust/src/hww/api.rs
index 624ec21..df1ce58 100644
--- a/src/rust/bitbox02-rust/src/hww/api.rs
+++ b/src/rust/bitbox02-rust/src/hww/api.rs
@@ -156,7 +156,7 @@ fn can_call(hal: &mut impl crate::hal::Hal, request: &Request) -> bool {
async fn process_api(hal: &mut impl crate::hal::Hal, request: &Request) -> Result<Response, Error> {
match request {
Request::Reboot(request) => system::reboot_to_bootloader(hal, request).await,
- Request::DeviceInfo(_) => device_info::process(hal),
+ Request::DeviceInfo(_) => device_info::process(hal).await,
Request::DeviceName(request) => set_device_name::process(hal, request).await,
Request::SetPassword(request) => set_password::process(hal, request).await,
Request::ChangePassword(_) => change_password::process(hal).await,
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 c3402b5..7252821 100644
--- a/src/rust/bitbox02-rust/src/hww/api/device_info.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/device_info.rs
@@ -6,7 +6,7 @@ use crate::pb;
use pb::response::Response;
-pub fn process(hal: &mut impl crate::hal::Hal) -> Result<Response, Error> {
+pub async fn process(hal: &mut impl crate::hal::Hal) -> Result<Response, Error> {
let bluetooth = match hal.memory().get_platform().map_err(|_| Error::Memory)? {
hal_memory::Platform::BitBox02Plus | hal_memory::Platform::BitBox03 => {
let ble_metadata = hal.memory().ble_get_metadata();
@@ -37,7 +37,7 @@ pub fn process(hal: &mut impl crate::hal::Hal) -> Result<Response, Error> {
initialized: hal.memory().is_initialized(),
version: crate::version::FIRMWARE_VERSION_SHORT.into(),
mnemonic_passphrase_enabled: hal.memory().is_mnemonic_passphrase_enabled(),
- monotonic_increments_remaining: hal.securechip().monotonic_increments_remaining()?,
+ monotonic_increments_remaining: hal.securechip().monotonic_increments_remaining().await?,
securechip_model: match hal.securechip().model()? {
securechip::Model::Atecc608A => "ATECC608A".into(),
securechip::Model::Atecc608B => "ATECC608B".into(),
diff --git a/src/rust/bitbox02/src/hal/securechip.rs b/src/rust/bitbox02/src/hal/securechip.rs
index 267d653..35e773e 100644
--- a/src/rust/bitbox02/src/hal/securechip.rs
+++ b/src/rust/bitbox02/src/hal/securechip.rs
@@ -117,7 +117,7 @@ impl SecureChip for BitBox02SecureChip {
crate::securechip::attestation_sign(challenge, signature)
}
- fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
+ async fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
crate::securechip::monotonic_increments_remaining()
}
diff --git a/src/rust/bitbox03/src/securechip.rs b/src/rust/bitbox03/src/securechip.rs
index c7bbca4..9ccf5ae 100644
--- a/src/rust/bitbox03/src/securechip.rs
+++ b/src/rust/bitbox03/src/securechip.rs
@@ -41,7 +41,7 @@ impl hal::securechip::SecureChip for BitBox03SecureChip {
todo!()
}
- fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
+ async fn monotonic_increments_remaining(&mut self) -> Result<u32, ()> {
todo!()
}
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.