cancel
Showing results for 
Search instead for 
Did you mean: 

Lightweight Encryption Methods for SD Card on STM32F412RB

Sujith
Associate III

Hi everyone,

I am working on an STM32F412RB-based project where I need to secure data stored on an SD card while maintaining fast accessibility. However, I have very limited flash memory available (only 40 KB free), so I need a lightweight encryption method that does not consume too many resources.

Current Setup:

  • MCU: STM32F412RB

  • SD Card Interface: SDIO

  • File System: FATFS

  • Encryption: None implemented yet

  • Remaining Flash Memory: 40 KB

Questions:

  1. What are some efficient lightweight encryption methods for securing SD card data on STM32 with minimal resource usage?

  2. Does the STM32F412RB have any hardware-accelerated encryption support that I can utilize?

  3. Would a simple XOR-based encryption be sufficient for basic security, or is there a better lightweight alternative?

  4. Are there any recommended STM32 libraries for secure but fast data storage on SD cards?

  5. Is there any available code or a GitHub link that I can refer to?

I would appreciate any insights or experiences regarding this. Thank you!

3 REPLIES 3
CMYL
ST Employee

Hello @Sujith 

Do you mean STM32F412RG or STM32F412RE ? there is no STM32F412RB part number in the STM32F412 series.

  1.  Lightweight encryption methods is always possible (i.e Consider using lightweight encryption algorithms such as ChaCha20, Noekon or Speck, which are designed for constrained environments). However security level is weak. I suggest using the X-Cube-CryptoLib with the "ECC mathematics configuration option = Small", You have a wide range of algorithms that you can use for 40 Kbytes of Footprint. Refer to this wiki and choose the adequate for you: Cryptographic performance on STM32G4 Series - stm32mcu, it is for STM32G4 but it should be similar to STM32F4 as well.  
  2. There is no HW crypto accelerator on STM32F412 series. For STM32F4 series with hw crypto accelerator refer to the STM32F4 home page (STM32F4 series - Products)  and apply the filter for the HW Crypto algo to check if it exists. 
  3. Would a simple XOR-based encryption be sufficient for basic security ..... ? no refer to question 1.

  4. "Are there any recommended STM32 libraries for secure but fast data storage on SD cards?" The STM32 X-Cube-CryptoLIB is secure as explained above.

  5. "Is there any available code or a GitHub link that I can refer to?" not for you sd card use case but you can adapt it to your use case. 

Note: the question seems be generated using GenAI !! Do not ask questions looking like autogenerated otherwise they will be filtered by the system.

 

Best regards


@Sujith wrote:

3. Would a simple XOR-based encryption be sufficient for basic security, or is there a better lightweight alternative?


That depends entirely on what you define as "basic security".

 


@Sujith wrote:

4. Are there any recommended STM32 libraries for secure but fast data storage on SD cards?


As @CMYL said, the STM32F412RG or STM32F412RE has no HW crypto accelerator - so you would just be using standard, general software - not specific to STM32.

Also not specific to SD-Cards.

 


@Sujith wrote:

5. Is there any available code or a GitHub link that I can refer to?


GitHub has a search facility; eg, https://github.com/search?q=lightweight%20encryption&type=repositories

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil wrote:


That depends entirely on what you define as "basic security".


The US National Institute of Standards and Technology (NIST) offers some definitions here; eg,

"Security commensurate with the risk and the magnitude of harm resulting from the loss, misuse, or unauthorized access to or modification of information"

 

See also: 

How secure is secure enough? 

How Secure is Secure Enough?

and more: https://www.google.com/search?q=how+secure+is+%22secure+enough%22 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.