ESP32 Flash Encryption

prodigysounds
Posts: 3
Joined: Thu Jul 27, 2023 3:49 am

ESP32 Flash Encryption

Postby prodigysounds » Fri Jul 28, 2023 7:40 pm

I am developing a product that will utilize the ESP32-C6.

The ESP32-C6 will be the core MCU of the product and it will interface with an interchangeable/removable external flash memory chip.
The product will access the data contents of the external flash memory chip when one is connected to the ESP32-C6 in the main device.

The data on the flash memory chip must be written and stored prior to its connection with the main device. This data is required to be encrypted for protection and preservation of intellectual property. I would like to know if the ESP32 Flash Encryption feature could be adapted to support this architecture. The main device is to interact with various flash memory chips that contain unique data storage contents to be accessed and read by the ESP32-C6.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 Flash Encryption

Postby ESP_Sprite » Sun Jul 30, 2023 9:28 am

The internal flash has transparent en/decryption, but if you use external flash you'd need to use e.g. MbedTLS to encrypt/decrypt the data manually. (This is not necessarily a bad thing btw; it means you can encrypt the internal flash using a per-device key while the external key is global in order to be able to exchange that flash between devices, presuming that is what you want.)

prodigysounds
Posts: 3
Joined: Thu Jul 27, 2023 3:49 am

Re: ESP32 Flash Encryption

Postby prodigysounds » Mon Jul 31, 2023 4:31 am

From my understanding and please correct me if I am wrong, I would be able to encrypt/decrypt data on an external flash memory device using MbedTLS. Having a global key will allow me to interface with any other external flash memory chip and decrypt the data that is being accessed by my core device.

I see that MbedTLS is a transport layer protocol so my question is how would MbedTLS be applied to communications initiated between hardware devices (ESP32-C6 -> Flash memory chip)? Are there any examples available that I could refer too? What other protocols (other than MbedTLS) would be suitable for this application assuming that MbedTLS is not the best solution?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 Flash Encryption

Postby ESP_Sprite » Mon Jul 31, 2023 7:31 am

MbedTLS mainly provides for TLS-level security, but because of the nature of that it also provides a bunch of crypto primitives. For instance, here is an example that uses AES-CBC. (Note that AES-CBC may not be the best encryption for your use case, the link is simply an illustration.)

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 Flash Encryption

Postby MicroController » Thu Aug 03, 2023 10:03 am


Who is online

Users browsing this forum: No registered users and 133 guests