Hi, @Mr_red
I checked the bootloader's size before flash it, cause the instruction mentioned about that. It's smaller than that (<16k), cause I changed the settings for bootloader logging.
And I just tested the Verify function of espsecure.py which is in the bundle of esptool.
I've found that espsecure.py can only verify the Data bin file with the signing private key. It worked with the private key.
espsecure.py v2.5.0
Verifying 216016 bytes of data
Signature is valid
I extract_public_key from the private key with espsecure.py extract_public_key command.
espsecure.py v2.5.0
secure_boot_signing_key.pem public key extracted to public_key.pem
And then I verify_signature the Data bin file with the generated public_key, error occurs.
I pasted the log here:
python espsecure.py verify_signature --keyfile public_key.pem VS_app_signed.bin
espsecure.py v2.5.0
Traceback (most recent call last):
File "espsecure.py", line 156, in verify_signature
sk = _load_key(args) # try to load as private key first
File "espsecure.py", line 123, in _load_key
sk = ecdsa.SigningKey.from_pem(args.keyfile.read())
File "C:\Python37\lib\site-packages\ecdsa-0.13-py3.7.egg\ecdsa\keys.py", line 159, in from_pem
privkey_pem = string[string.index(b("-----BEGIN EC PRIVATE KEY-----")):]
ValueError: subsection not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "espsecure.py", line 401, in <module>
_main()
File "espsecure.py", line 394, in _main
main()
File "espsecure.py", line 389, in main
operation_func(args)
File "espsecure.py", line 160, in verify_signature
vk = ecdsa.VerifyingKey.from_pem(args.keyfile.read())
File "C:\Python37\lib\site-packages\ecdsa-0.13-py3.7.egg\ecdsa\keys.py", line 52, in from_pem
return klass.from_der(der.unpem(string))
File "C:\Python37\lib\site-packages\ecdsa-0.13-py3.7.egg\ecdsa\der.py", line 191, in unpem
return base64.b64decode(d)
File "C:\Python37\lib\base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
I doubt if the bootloader will use the same method and went wrong.
Secure boot won’t be enabled until after a valid partitions table and app image have been flashed. This is to prevent accidents before the system is fully configured.
I can tell that the eFuse of ABS_DONE_0 is checked with 1. So my partitions table and app is checked.
And the flash encryption also worked. I noticed the change of FLASH_CRYPT_CNT.
But the secure boot check fail. I'm doubtful about the verification.
So I use espsecure.py to verify my files on PC.
I think I will post this to Bug Report, at least there is a bug for espsecure.py.