M404 / M-SoM: cryptographic signing and on-device verification of user firmware

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_sig in platform/MCU/rtl872x/inc/rtl_header.h, referenced through .sboot_address in bootloader/src/rtl872x/rtl_header.cpp.
  • The user application module has no signature field. build/create_module.py appends a ModuleFooter with a SHA-256 and the product ID, then a CRC32.
  • On RTL872x, MODULE_VALIDATION_INTEGRITY resolves to a CRC32 check (hal/src/rtl872x/ota_module.cpp, fetch_module → verify_crc32), and HAL_FLASH_End in hal/src/rtl872x/ota_flash_hal.cpp queues the downloaded module with MODULE_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 the Spark_*_Firmware_Update calls return SYSTEM_ERROR_PROTECTED, but HAL_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.

User firmware is not signed at this time, though it is planned for the future.

While you obviously could generate a signature for your binaries yourself, it's not clear to me how you'd securely validate them. The validation code would either need to be in the user binary itself, or at a higher layer like the Device OS system part. But this just adds a layer of obfuscation and doesn't really make it secure.

The secure boot bootloader uses a key pair that is per-device. This is why you cannot flash the generic prebootloader-mbr to the boot sector flash of the RTL872x MCU because it won't validate and won't boot. Also you can't build your own, because you won't have the private key, even with physical access to the device, which is what makes the boot secure.