You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update using an encrypted firmware does not appear to work correctly as it seems to try to decrypt incorrectly.
When using a slightly modified version of the example sketch "OTAWebUpdater" to include
const uint8_t key[32] = {/* PUT YOUR KEY HERE */};
Update.setupCrypt(key, 0, 0, U_AES_DECRYPT_ON);
in void handleUpdate(), the update does not work and during it the error "Wrong Magic Byte" is printed repeatedly.
Proposed solution
By changing MBEDTLS_AES_ENCRYPT to MBEDTLS_AES_DECRYPTin line 331 of Updater.cpp the code works as expected.
AES algorithm is used inverted in flash encryption, so the flash encryption "encrypt" operation is AES decrypt and the "decrypt" operation is AES encrypt. This is for performance reasons and does not alter the effeciency of the algorithm.
Board
ESP32-S3-DevKitC-1
Device Description
ESP32-S3-DevKitC-1 v1.0
Hardware Configuration
No other hardware attached.
Version
3.0.4
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
40Mhz
PSRAM enabled
no
Upload speed
460800
Description
Update using an encrypted firmware does not appear to work correctly as it seems to try to decrypt incorrectly.
When using a slightly modified version of the example sketch "OTAWebUpdater" to include
in
void handleUpdate()
, the update does not work and during it the error "Wrong Magic Byte" is printed repeatedly.Proposed solution
By changing
MBEDTLS_AES_ENCRYPT
toMBEDTLS_AES_DECRYPT
in line 331 of Updater.cpp the code works as expected.Sketch
Debug Message
Other Steps to Reproduce
Having an encrypted binary along with its key is of course necessary.
platformio.ini:
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: