Skip to main content
MK..1
Associate III
May 22, 2024
Question

STM32 firmware update (USB DFU) and encryption

Hi

I successfully got the USB DFU bootlader working in 2 hours.

This one: https://www.youtube.com/watch?v=n_LDXOQHerU

Now i would like to add some encryption to it with a time budget of couple of hours.

I am already using python for USB DFU update.

What is the quickest way forward?

thx

This topic has been closed for replies.

1 reply

ST Technical Moderator
June 18, 2024

Hello @MK..1 

 

Here's a step-by-step guide to get you started:

Step 1: Choose an Encryption Algorithm

Step 2: Install a Python Encryption Library

You can use the pycryptodome library, which is a self-contained Python package of low-level cryptographic primitives. Install it using pip:

pip install pycryptodome

Step 3: Encrypt the firmware

Before sending the firmware via DFU, you'll need to encrypt it.

Step 4: Decrypt the firmware in the bootloader

Your bootloader will need to decrypt the firmware before applying the update. You'll need to securely transfer the encryption key and IV (Initialization Vector) to the bootloader. The decryption process will be the inverse of the encryption process.

Step 5: Update the DFU script

Modify your existing Python DFU script to encrypt the firmware before sending it to the device.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om