bluetooth: use hex literal for the allowed Bluetooth FW hash
What changed, and why it matters
This commit is a minor code cleanup in the BitBox02 firmware. It changes how a hardcoded Bluetooth firmware hash is written in the source code, switching from a raw byte string to a more readable hexadecimal literal. The actual hash value and the security check that uses it remain unchanged. There is no indication this fixes a security vulnerability.
No security action required. Treat as a normal readability/maintenance refactor.
Security signals we found
Hardcoded firmware integrity hash (expected, not a vulnerability)
No change to the hash value or verification logic
No bounds-checking, input-validation, or cryptographic changes
Evidence from the diff
The patch refactors the declaration of ALLOWED_HASH in src/rust/bitbox02-rust/src/hww/api/bluetooth.rs. Previously it was a byte string literal b”…” with 32 escaped hex bytes; now it uses the hex_lit crate’s hex!() macro with the same 32-byte value. The dependency hex_lit is moved from dev-dependencies to normal dependencies. The constant’s type changes from &[u8; 32] to [u8; 32], and the call site passes &ALLOWED_HASH instead. The hash value itself is identical, and the Bluetooth firmware upgrade verification logic is functionally unchanged.
Changed components
src/rust/bitbox02-rust/src/hww/api/bluetooth.rssrc/rust/bitbox02-rust/Cargo.tomlInspect captured patch +7 / −3
diff --git a/src/rust/bitbox02-rust/Cargo.toml b/src/rust/bitbox02-rust/Cargo.toml
index eb326ac..7e312b7 100644
--- a/src/rust/bitbox02-rust/Cargo.toml
+++ b/src/rust/bitbox02-rust/Cargo.toml
@@ -57,6 +57,7 @@ bip39 = { workspace = true }
# writing, this might fluctuate over time).
bitcoin_hashes = { version = "0.14.0", default-features = false, features = ["small-hash"] }
futures-lite = { workspace = true }
+hex_lit = { workspace = true, features = ["rust_v_1_46"] }
[dependencies.prost]
# keep version in sync with tools/prost-build/Cargo.toml.
@@ -66,7 +67,6 @@ features = ["derive"]
[dev-dependencies]
bitbox-aes = { path = "../bitbox-aes" }
-hex_lit = { workspace = true }
[features]
ed25519 = [
diff --git a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
index dcee051..cdaf058 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
@@ -15,6 +15,8 @@
use super::Error;
use super::pb;
+use hex_lit::hex;
+
use pb::bluetooth_request::Request;
use pb::bluetooth_response::Response;
@@ -27,7 +29,9 @@ use alloc::vec::Vec;
use bitbox02::{memory, spi_mem};
-const ALLOWED_HASH: &[u8; 32] = b"\x1e\x4a\xa8\x36\x4e\x93\x5c\x07\x85\xe4\xf8\x91\x20\x83\x07\xd8\x32\xf7\x88\x17\x2e\x4b\xf6\x16\x21\xde\x6d\xf9\xec\x3c\x21\x5f";
+// See also bitbox-da14531-firmware.bin.sha256.
+const ALLOWED_HASH: [u8; 32] =
+ hex!("1e4aa8364e935c0785e4f891208307d832f788172e4bf61621de6df9ec3c215f");
// We want to write FW to the memory chip in erase-size chunks, so that we don't repeatedly need to
// read-erase-write the same sector.
@@ -159,7 +163,7 @@ async fn process_upgrade(
})
.await?;
- let response = _process_upgrade(&mut RealFuncs, request, ALLOWED_HASH).await;
+ let response = _process_upgrade(&mut RealFuncs, request, &ALLOWED_HASH).await;
if response.is_ok() {
hal.ui().status("Upgrade\nsuccessful", true).await;
Why this scored 18/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.