We build a field device on the M404 (Device OS 6.3.4, product fleet, OTA through Fleet Management). Utility customers' security reviews are now asking a very specific question: "Are firmware images cryptographically signed and verified on the device before execution?" We want to answer it accurately, so we read the docs, the older threads here, and the Device OS source before asking.
What we found (please correct anything wrong):
- The M404 has hardware Secure Boot with factory-provisioned per-device keys (
prebootloader-mbr). The RTL872x bootloader image carries a 64-byte secure-boot signature:rtl_secure_boot_footer.sb_siginplatform/MCU/rtl872x/inc/rtl_header.h, referenced through.sboot_addressinbootloader/src/rtl872x/rtl_header.cpp. - The user application module has no signature field.
build/create_module.pyappends aModuleFooterwith a SHA-256 and the product ID, then a CRC32. - On RTL872x,
MODULE_VALIDATION_INTEGRITYresolves to a CRC32 check (hal/src/rtl872x/ota_module.cpp,fetch_module→verify_crc32), andHAL_FLASH_Endinhal/src/rtl872x/ota_flash_hal.cppqueues the downloaded module withMODULE_VERIFY_CRC | MODULE_VERIFY_DESTINATION_IS_START_ADDRESS | MODULE_VERIFY_FUNCTION. - So, as we read it: Secure Boot protects the low-level boot code, OTA transport is authenticated and encrypted (DTLS), and the user application is protected for integrity (SHA-256 + CRC32) but not for authenticity by a signature. That matches the "Digital Signatures for Security" thread and the OTA docs.
Question 1: Secure Boot scope on the M404. Which images does the RTL872x boot ROM / prebootloader verify cryptographically: prebootloader-mbr, prebootloader-part1, bootloader, system-part1, user-part? Which signature algorithm is used, and is the verifying key per-device or common across the fleet?
Question 2: customer-controlled signing of the user application. If Fleet OTA does not authenticate the user part itself, what is the recommended way to add our own signing? What we have in mind:
CI: build user-part → SHA-256 → ECDSA sign with our HSM-held key
↓ delivered to the device (Asset OTA, or a download the app performs)
running app: verify signature against an embedded public key → reject if invalid
↓
HAL_FLASH_Begin / HAL_FLASH_Update / HAL_FLASH_End / HAL_FLASH_ApplyPendingUpdate (hal_dynalib_ota.h)
↓
normal Device OS staging and install
- Is calling those dynalib-exported
HAL_FLASH_*functions from a user application supported on Gen 4, or should we use something else? We noticed that under Device Protection theSpark_*_Firmware_Updatecalls returnSYSTEM_ERROR_PROTECTED, butHAL_FLASH_*has no such guard. Which behavior is intended? - Can a product turn off cloud-pushed user-part OTA, so that a signed path like this is the only way in, while still using Fleet Management for Device OS and for monitoring?
- Is customer-key signing of the user part on the roadmap? (A 2015 post mentioned "user and organizational signing certificates".)
We would rather build on a supported mechanism than modify the bootloader or fight future Device OS updates. Pointers to M-SoM-specific docs or code are very welcome.