What changed, and why it matters
This commit is a code-size optimization for the BitBox02 bootloader. It switches the Bluetooth Low Energy (BLE) firmware hash verification from a Rust SHA-256 implementation to an existing C-based SHA-256 implementation already used by the bootloader. The change saves 1,352 bytes and adds a CI check to prevent the larger Rust SHA-256 code from creeping back into production bootloaders. There is no indication this fixes a security vulnerability.
No security action required. Treat as a normal refactor/size optimization. If auditing, confirm that pukcc_sha256_compute() produces correct SHA-256 outputs and that the metadata.allowed_firmware_hash is still set by trusted firmware.
Security signals we found
Change is described by the vendor as a size optimization, not a security fix.
No functional change to the hash verification logic: SHA-256 digest is still computed and compared against metadata.allowed_firmware_hash.
CI check added to enforce use of the smaller PUKCC SHA-256 path in production bootloaders.
No diff evidence of buffer overflow, missing length check, bypass, or cryptographic weakness.
Evidence from the diff
The patch modifies memory_spi.c so that when compiled as BOOTLOADER, the BLE firmware integrity check uses pukcc_sha256_compute() instead of rust_sha256(). Firmware builds continue using the Rust wrapper. A CI script is updated to reject RustCrypto SHA-256 symbols in production bootloader ELF files. The change is framed purely as a size-reduction refactor, not a security fix.
Changed components
BitBox02 bootloader BLE firmware verification pathsrc/memory/memory_spi.c.ci/check-unwanted-symbolsInspect captured patch +18 / −0
diff --git a/.ci/check-unwanted-symbols b/.ci/check-unwanted-symbols
index 058ca42..9af9072 100755
--- a/.ci/check-unwanted-symbols
+++ b/.ci/check-unwanted-symbols
@@ -84,6 +84,13 @@ check_production_bootloader() {
"$rust_fmt_symbol_pattern" \
"Rust format!/write! formatting pulls in significant bootloader bloat." \
"Avoid Rust formatting in production bootloaders; use fixed-format helpers instead."
+
+ check_symbols \
+ "$elf" \
+ "Rust SHA-256" \
+ "sha26sha256|sha2::sha256::compress256" \
+ "The RustCrypto SHA-256 implementation pulls in significant production bootloader bloat." \
+ "Use the existing PUKCC SHA-256 implementation in production bootloaders instead."
}
firmware_elf=build/bin/firmware.elf
diff --git a/src/memory/memory_spi.c b/src/memory/memory_spi.c
index 9d5cb7f..d42ce52 100644
--- a/src/memory/memory_spi.c
+++ b/src/memory/memory_spi.c
@@ -8,6 +8,9 @@
#include <rust/rust.h>
#include <util.h>
#include <utils_assert.h>
+#ifdef BOOTLOADER
+ #include <pukcc/pukcc.h>
+#endif
bool memory_spi_get_active_ble_firmware(
uint8_t** firmware_out,
@@ -32,7 +35,15 @@ bool memory_spi_get_active_ble_firmware(
return false;
}
uint8_t fw_hash[32] = {0};
+#ifdef BOOTLOADER
+ if (pukcc_sha256_compute(*firmware_out, size, fw_hash) != 0) {
+ free(*firmware_out);
+ *firmware_out = NULL;
+ return false;
+ }
+#else
rust_sha256(*firmware_out, size, fw_hash);
+#endif
if (!MEMEQ(fw_hash, metadata.allowed_firmware_hash, 32)) {
free(*firmware_out);
*firmware_out = NULL;
Why 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.