fix(ota): Fix OTA decryption when HW acceleration is not available#12320
fix(ota): Fix OTA decryption when HW acceleration is not available#12320lucasssvaz wants to merge 1 commit intoespressif:masterfrom
Conversation
👋 Hello lucasssvaz, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 90 files 90 suites 27m 37s ⏱️ Results for commit ebadd1a. ♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description of Change
This PR aims to fix decryption of images when using non-Hardware-Accelerated functions form mbedtls by removing a useless
mbedtls_aes_setkey_deccall.This pull request also improves the documentation and clarity of the ESP32 flash encryption and decryption logic in
Updater.cpp, making the cryptographic implementation easier to understand and maintain. The changes focus on adding detailed comments explaining the key tweaking and decryption algorithms, clarifying the reasoning behind certain cryptographic choices, and cleaning up the code for readability.Enhanced documentation and clarity for ESP32 flash encryption
_cryptKeyTweakfunction, explaining the concept of address-based key tweaking, its security benefits, configuration options via_cryptCfg, and how it matches ESP32's hardware flash encryption scheme._cryptKeyTweakto clarify how address bits are mixed into the key, the role of the pattern array, and the logic for partial tweaking based on_cryptCfg.Improved documentation and explanation for decryption logic
_decryptBuffer, describing the ESP32 flash encryption scheme, the involutory transform (using AES encryption for both encrypt and decrypt), the rationale for byte reversal, and how key tweaking is applied per flash region._decryptBufferto clarify the process: block byte reversal, key tweaking, AES encryption (for decryption), and reversing the result back to plaintext.Code readability and maintainability improvements
mbedtls_aes_setkey_decand clarified that onlymbedtls_aes_setkey_encis needed due to the involutory nature of the encryption scheme.Test Scenarios
Tested locally with ESP32 and ESP32-C2
Related links
Closes #12217