diff --git a/bitbox-da14531-firmware.o b/bitbox-da14531-firmware.o index d7479a183..b013cfeec 100644 Binary files a/bitbox-da14531-firmware.o and b/bitbox-da14531-firmware.o differ diff --git a/src/bootloader/bootloader.c b/src/bootloader/bootloader.c index ea888dbf9..d3b8c4ccf 100644 --- a/src/bootloader/bootloader.c +++ b/src/bootloader/bootloader.c @@ -956,7 +956,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified) bool res = memory_spi_get_active_ble_firmware_version(&version); if (res) { char buf[50]; - snprintf(buf, sizeof(buf), "ble fw: %d.%d.%d", version.major, version.minor, version.patch); + snprintf(buf, sizeof(buf), "ble: %d (%s)", version.version, util_dbg_hex(version.hash, 4)); UG_PutString(0, SCREEN_HEIGHT - 18, buf, false); } #endif diff --git a/src/factorysetup.c b/src/factorysetup.c index 778ff75e1..8f61f1ef3 100644 --- a/src/factorysetup.c +++ b/src/factorysetup.c @@ -47,8 +47,8 @@ // We commit to the BLE firmware hash here to avoid accidentally installing an unexpected firmware. static const uint8_t _allowed_ble_fw_hash[32] = - "\x6d\x9e\x19\xe4\x94\x31\x0b\x73\x0b\xfe\x22\x8a\x4d\xdc\x50\x3b\xee\xd1\x5f\xa1\x28\xd2\xea" - "\x35\x44\x6f\xb8\xad\x35\x02\xac\x7a"; + "\x18\xca\x5a\xcb\x3a\x60\x2f\x89\xb2\x65\x25\xdb\xff\x1c\x4f\x07\x60\x3d\x76\x70\xd2\xf5\x4e" + "\x7a\x76\xfb\x1f\x9c\x4b\x29\x66\x4f"; // 65 bytes uncompressed secp256k1 root attestation pubkey. #define ROOT_PUBKEY_SIZE 65 diff --git a/src/firmware.c b/src/firmware.c index 4320d05ea..a16ba717f 100644 --- a/src/firmware.c +++ b/src/firmware.c @@ -43,12 +43,6 @@ int main(void) if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { da14531_protocol_init(); } - - struct da14531_firmware_version version; - if (memory_spi_get_active_ble_firmware_version(&version)) { - util_log("%d.%d.%d", version.major, version.minor, version.patch); - util_log("hex %s", util_dbg_hex(version.hash, 20)); - } usb_processing_init(); firmware_main_loop(); return 0; diff --git a/src/memory/memory_spi.c b/src/memory/memory_spi.c index ae0a274b1..85ce6be8b 100644 --- a/src/memory/memory_spi.c +++ b/src/memory/memory_spi.c @@ -76,6 +76,8 @@ USE_RESULT bool memory_spi_get_active_ble_firmware_version(struct da14531_firmwa memcpy((uint8_t*)version, firmware, sizeof(struct da14531_firmware_version)); free(firmware); + ASSERT(version->version == 1); + if (version->version == 1) { return true; } diff --git a/src/memory/memory_spi.h b/src/memory/memory_spi.h index f673ac5eb..9ef20c0c0 100644 --- a/src/memory/memory_spi.h +++ b/src/memory/memory_spi.h @@ -53,12 +53,9 @@ USE_RESULT bool memory_spi_get_active_ble_firmware( // This struct is always placed at 0x110 in the firmware struct da14531_firmware_version { - uint8_t version; // The version of the format of this struct. - uint16_t major; - uint16_t minor; - uint16_t patch; + uint8_t metadata_version; // The version of the format of this struct. + uint16_t version; // The version of the firmware uint8_t hash[20]; - uint8_t modified; } __attribute__((packed)); USE_RESULT bool memory_spi_get_active_ble_firmware_version( diff --git a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs index fbbe73154..d03f347f7 100644 --- a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs +++ b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs @@ -27,7 +27,7 @@ use alloc::vec::Vec; use bitbox02::{memory, spi_mem}; -const ALLOWED_HASH: &[u8; 32] = b"\x6d\x9e\x19\xe4\x94\x31\x0b\x73\x0b\xfe\x22\x8a\x4d\xdc\x50\x3b\xee\xd1\x5f\xa1\x28\xd2\xea\x35\x44\x6f\xb8\xad\x35\x02\xac\x7a"; +const ALLOWED_HASH: &[u8; 32] = b"\x18\xca\x5a\xcb\x3a\x60\x2f\x89\xb2\x65\x25\xdb\xff\x1c\x4f\x07\x60\x3d\x76\x70\xd2\xf5\x4e\x7a\x76\xfb\x1f\x9c\x4b\x29\x66\x4f"; // 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. diff --git a/src/rust/bitbox02/src/spi_mem.rs b/src/rust/bitbox02/src/spi_mem.rs index d6c6a679d..e4ccdb3c8 100644 --- a/src/rust/bitbox02/src/spi_mem.rs +++ b/src/rust/bitbox02/src/spi_mem.rs @@ -35,12 +35,8 @@ pub fn get_active_ble_firmware_version() -> Result { true => { let ble_fw_version = ble_fw_version.assume_init(); // Copy to avoid taking references to unaligned struct fields. - let (major, minor, patch) = ( - ble_fw_version.major, - ble_fw_version.minor, - ble_fw_version.patch, - ); - Ok(format!("{}.{}.{}", major, minor, patch)) + let version = ble_fw_version.version; + Ok(format!("{}", version)) } false => Err(()), }