newton123 wrote:..No amount of enctryption/decryption is going to help if you are storing your key in memory which can be read back.
sory, the key is not stored in memory, there is no key availabel to read.
try to think pictured about this:
"consideration"
simple example without signing:
one part of key is a src of the chip id ( not chip id cleartext! )
the next part of key is a src of individal key ( company sign with a unique id each unit : example own serial number ) .. is a part
the next part of key is a src of mac id from spi flash ( its a unique mac id ) not the product nr this is a other and not unique id
.. and more extends..
the parts are all not equal - each esp8266 chip has its own const HARDWARE chip id in register, each spi flash has its own const MAC ID ( 64 bit ) in register,
the company gives a unique encrypted seed in the unit ( watermark )
this parts are part of a key for encrypting the file.
if hacker have the firmware dump, there is no clear text of key*s
there are only funtions like this:
*boot = decrypt( file *0x01000 , key_a *system_get_chip_id(), key_b *system_get_mac_id_flash(),........................)
if one parameter not the same like company has flashed it with originaly chips, the decrypted firmware file will be corupt.
simple example
the encrypting key will be the originally unique chip id
in factory the firmware will encrypt by the originally unique chip id
only decrypting with the right originally unique chip id is possible
if firmware was dump and copy it to other chip ( this has a other chip id )
the bootprocess decrypt the firmware not with the originally unique chip id - it decrypt with copy unique chip id of destination chip -
this will be go false. if revers enginiering the firmware dump, you will see only the function "system_get_chip_id()", but not the cleartext,
that was originally encrypted.
this only one of more as 12 possiblte parts. (**)
newton123 wrote:So its just a matter of few hours or at most few days for a hacker to dump the code & isolate the part that is reading the keys for decryption and be able to figure out the keys!
one possible way for the hacker:
he must know, which data was take for encrypting in the first time of flashing the original chip.
then he can emulate parts of this at every boot at the copy chip.
but not all - ( i have not sayed all here

)
so the firmware will be corupt.
the bootloader is signed
the firmware is signed
only update's with signed firmware exactly written for this chip is possible
but you are right.
one day AES256 will be hacked

but then espressif have many many many new series of esp8266 on market with aes512.. or other and we are all old or died in > 2050

hope this helps a little.
best wishes
rudi

edit:
(**)
which is currently standing here,
to form the key from a concatenation of more than 12 parts,
which are comparatively different for each chip hardware.
nothing is 100 percent secure- which is random to blame
"nichts ist 100 prozent sicher - der zufall ist schuld daran"