ports/esp32: Add ESP32-S3 digital signature support. by edel-macias-cubix · Pull Request #19121 · micropython/micropython · GitHub
Skip to content

ports/esp32: Add ESP32-S3 digital signature support.#19121

Open
edel-macias-cubix wants to merge 1 commit intomicropython:masterfrom
edel-macias-cubix:esp32-add-digital-signature-support
Open

ports/esp32: Add ESP32-S3 digital signature support.#19121
edel-macias-cubix wants to merge 1 commit intomicropython:masterfrom
edel-macias-cubix:esp32-add-digital-signature-support

Conversation

@edel-macias-cubix
Copy link
Copy Markdown

Summary

Micropython builds don't have access to the underlying ESP-IDF DS (Digital Signature Peripheral), which allows to use keys saved in eFuses to retrieve an encrypted private key to then generate a signature for a given payload.
This PR adds an entrypoint to support DS operations from ESP-IDF via esp32.DS, which is added to builds via new board variants for ESPS3:

make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT_DS

and

make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=DS

Other variants and builds don't include DS, as it is a somewhat niche use case.
Having this functionality available allows for device verification/authentication.

Testing

  • I built both Octal SPIRAM and regular ESP32 S3 builds with and without DS. It was included conditionally as expected.
  • Non S3 builds don't compile DS support.
  • e2e testing was performed:
    • Created and burnt HMAC key into ESP32-S3
    • Generated a new RSA key
    • Generate a new DS blob and save it onto the board
    • Sign a test payload using this feature
    • Verify the signature on PC
    • Signature is valid.

Trade-offs and Alternatives

Main tradeoff is a slight increase in build size, which is balanced with increased functionality.
DS support remains fully opt-in.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

Additional notes

Using this functionality requires building a DS blob that encrypts a private key using the HMAC key burnt into the eFuses in a format that ESP-IDF accepts. I have the python script that generates them but was unsure where to put it, if at all. It was made using the same logic as the ESP-IDF test files for DS.
I also have the testing code I used on the board to perform payload signing using the feature and DS blob.
I think they would be very useful but I'd like some guidance on this.

@edel-macias-cubix edel-macias-cubix force-pushed the esp32-add-digital-signature-support branch 2 times, most recently from 1974c68 to 4b82194 Compare April 17, 2026 04:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

@Josverl
Copy link
Copy Markdown
Contributor

Josverl commented Apr 17, 2026

Thanks for tha contribution, this appears a useful, but somewhat niche functionality, do it is good that it is properly guarded and disabled by default.

I do not think that there should be two additional variants defined though. Instead a custom build should be enabled by defining the macro as a build flag.

@edel-macias-cubix edel-macias-cubix force-pushed the esp32-add-digital-signature-support branch from 4b82194 to 82d4ea6 Compare April 17, 2026 05:19
@edel-macias-cubix
Copy link
Copy Markdown
Author

@Josverl Thanks for the suggestion, I've removed the variants and added a build flag for it:

CMAKE_ARGS='-DMICROPY_PY_ESP32_DS=1'

@Josverl
Copy link
Copy Markdown
Contributor

Josverl commented Apr 17, 2026

Thanks for the quick update

I also have the testing code I used on the board to perform payload signing using the feature and DS blob.\nI think they would be very useful but I'd like some guidance on this.

Please add that**, the test should first check if the feature is activated on the test target, and SKIP otherwise.
See the testing documentation for details.

** I hope that that does not require permanently burning fuses

That would allow repeatable tests with actual hardware.
And may also help others in understanding how to set up their own keys.

@edel-macias-cubix edel-macias-cubix force-pushed the esp32-add-digital-signature-support branch from 82d4ea6 to f0fcdc4 Compare April 18, 2026 09:19
@edel-macias-cubix
Copy link
Copy Markdown
Author

I've added tests for this, however, they require burning efuses. I've used a board with the same key set in the tests and worked correctly. I then retried with a different board with another key and a brand new board: both failed as expected. Test is guarded by imports.

I've also added under ports/esp32/tools/gen_ds_blob.py the utility to generate the DS blob so users can easily generate them and use the added functionality.

@edel-macias-cubix edel-macias-cubix force-pushed the esp32-add-digital-signature-support branch from f0fcdc4 to e034290 Compare April 18, 2026 09:22
Expose the ESP32-S3 DS peripheral through esp32.DS when enabled.
Wire the port into the build, add build flags, and document the API.
Add tests for ESP32-S3 DS peripheral functionality.
Add DS blob generation tool for ease of use.

Signed-off-by: Edel Macias <edel.macias@cubix.com.mx>
@edel-macias-cubix edel-macias-cubix force-pushed the esp32-add-digital-signature-support branch from e034290 to 0306dfb Compare April 18, 2026 09:25
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants