simulator-graphical-bb03: implement Random
What changed, and why it matters
This commit implements a placeholder random-number generator inside a graphical simulator for the BitBox03 hardware wallet. It replaces 'todo!' stubs with code that fills 32-byte buffers using the standard Rust 'rand' crate. The change only affects test/simulator code, not the real firmware or any production device, so it does not create a security vulnerability in shipped products. The only concern is that simulator developers must remember this is a non-cryptographic/test RNG and must not copy it into real hardware code.
No security action required for this commit. Ensure project documentation and code comments clearly state that simulator RNG is for testing only and must not be reused in the real BitBox02/BitBox03 firmware HAL. If cryptographic tests in the simulator require predictable or reproducible output, consider seeding the RNG explicitly rather than using the default.
Security signals we found
Use of a software PRNG in a hardware-wallet simulator context
Replacement of unimplemented stubs with a deterministic-ish host RNG
Clear scope limitation to test/simulator-graphical-bb03; no production firmware change
Evidence from the diff
The patch completes the Random HAL implementation for simulator-graphical-bb03. It adds the ‘rand 0.9.2’ dependency and implements random_32_bytes() and mcu_32_bytes() by calling rand::rng().fill(out). Previously both methods were todo!() stubs. The simulator is a host-side testing/development tool; it does not run on the secure MCU and is not part of the production firmware image. The Rust ‘rand’ crate’s default RNG is suitable for simulation/testing but is not a hardware TRNG and should not be used for real cryptographic key material.
Changed components
test/simulator-graphical-bb03/src/hal/random.rstest/simulator-graphical-bb03/Cargo.tomltest/simulator-graphical-bb03/Cargo.lockInspect captured patch +10 / −4
diff --git a/test/simulator-graphical-bb03/Cargo.lock b/test/simulator-graphical-bb03/Cargo.lock
index f4805a0..cb75850 100644
--- a/test/simulator-graphical-bb03/Cargo.lock
+++ b/test/simulator-graphical-bb03/Cargo.lock
@@ -2831,6 +2831,7 @@ dependencies = [
"glutin-winit",
"hex",
"image",
+ "rand",
"tracing",
"tracing-subscriber",
"util",
diff --git a/test/simulator-graphical-bb03/Cargo.toml b/test/simulator-graphical-bb03/Cargo.toml
index 577ce82..a48bc18 100644
--- a/test/simulator-graphical-bb03/Cargo.toml
+++ b/test/simulator-graphical-bb03/Cargo.toml
@@ -23,3 +23,4 @@ critical-section = { version = "1.2", features = ["std"] }
bitbox03 = { path = "../../src/rust/bitbox03" }
bitbox-lvgl = { path = "../../src/rust/bitbox-lvgl" }
zeroize = "1.7.0"
+rand = "0.9.2"
diff --git a/test/simulator-graphical-bb03/src/hal/random.rs b/test/simulator-graphical-bb03/src/hal/random.rs
index a9b87e3..d7ab636 100644
--- a/test/simulator-graphical-bb03/src/hal/random.rs
+++ b/test/simulator-graphical-bb03/src/hal/random.rs
@@ -1,15 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
+use alloc::boxed::Box;
use bitbox_hal as hal;
+use rand::Rng;
pub struct BitBox03Random;
impl hal::random::Random for BitBox03Random {
- fn random_32_bytes(&mut self) -> alloc::boxed::Box<zeroize::Zeroizing<[u8; 32]>> {
- todo!()
+ fn random_32_bytes(&mut self) -> Box<zeroize::Zeroizing<[u8; 32]>> {
+ let mut out = Box::new(zeroize::Zeroizing::new([0u8; 32]));
+ self.mcu_32_bytes(out.as_mut());
+ out
}
- fn mcu_32_bytes(&mut self, _out: &mut [u8; 32]) {
- todo!()
+ fn mcu_32_bytes(&mut self, out: &mut [u8; 32]) {
+ rand::rng().fill(out);
}
}
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.