How to encrypt data before storing to flash without exposing the encryption key?

I'm using nrf52840  and NVS module to store some data samples, I need these samples to be encrypted, How can I achieve that? Where to store the key securely?

Parents
  • The nRF52840 does not have a KMU, but it is possible lo push a key to cryptocell that is never exposed, but can be used to derive other keys. This will stay in volatile memory inside CrytpoCell, so it needs to be loaded at every boot, though. By letting the immutable bootloader load the key, and then prevent further read access to the flash page, the key is not accessible to the application. See the Hardware unique key sample.

    With this, you can use the derived key to encrypt the data before storing to flash, and decrypt it after retreaving it. The derived key that you use to encrypt/decrypt will be accessible when you have derived it before you wipe it from memory, but the attack window is minimized.

    To get a higher level of security you would need a form of security by separation, which is provided by TrustZone and TF-M in the nRF5340, for instance, but that is not possible on the nF52840.

  • Thanks Einar.
    "By letting the immutable bootloader load the key, and then prevent further read access to the flash page, the key is not accessible to the application." This can be effective for internal flash, but for external flash this wouldn't be effective, as external flash can be directly accesses(Hacked externally), right?

    Any examples for implementing the immutable bootloader with the hardware unique key?

Reply
  • Thanks Einar.
    "By letting the immutable bootloader load the key, and then prevent further read access to the flash page, the key is not accessible to the application." This can be effective for internal flash, but for external flash this wouldn't be effective, as external flash can be directly accesses(Hacked externally), right?

    Any examples for implementing the immutable bootloader with the hardware unique key?

Children
No Data
Related