Page 1 of 1

Remote signing of images with espsecure using yubikey

Posted: Mon Aug 29, 2022 5:32 pm
by bobbygz
To keep the code signing private key secure I would like to configure and use a yubikey to sign the images (2nd stage boot loader / OTA apps). The instructions for signing images and creating the required signature blocks assume the private key is accessible on the signing server. By using an HSM (yubikey) the private key would but be accessible and therefore not be compromised.

Can espsecure be used as is to support this? If not can it be extended? Is this a good idea?

Thanks you!!

Re: Remote signing of images with espsecure using yubikey

Posted: Tue Aug 30, 2022 7:35 am
by ESP_igrr
This sounds like a good idea! We had a discussion about adding PKCS11 support to espsecure, but seems like this hasn't been implemented yet.

Re: Remote signing of images with espsecure using yubikey

Posted: Mon Dec 05, 2022 9:54 am
by DCSBL-
Hey @ESP_igrr,

Is there any update on this, or at least some insights into if it is even possible? I am also curious if there are other HSM's to keep the sign process really secure in our CI/CD.

Re: Remote signing of images with espsecure using yubikey

Posted: Wed Dec 07, 2022 12:27 pm
by ESP_harshal
Secure boot version 2 uses an RSA-3072-based app signing scheme. YubiKey only supports RSA-2048 and hence, it cannot be used for app signing. Although, in the case of ESP32-C2, secure boot version 2 uses ECDSA-192/256-based signing scheme, which is supported by YubiKey.

We have been working on adding a PKCS11 interface to get the binaries signed using an HSM, please check this out https://github.com/Harshal5/esptool/tre ... _interface.
Before using this feature, you will need to install PyKCS (https://github.com/LudovicRousseau/PyKCS11) on your host, populate fields in the HSM espsecure/ext_hsm.ini config file, and generate the public key for the HSM private key to be used for signing.
(This workflow has been tested with ECDSA-256 signing using YubiKey5.)

Re: Remote signing of images with espsecure using yubikey

Posted: Fri Dec 09, 2022 3:36 pm
by DCSBL-
Thank you! I will take a look!

Re: Remote signing of images with espsecure using yubikey

Posted: Sun Feb 12, 2023 1:17 pm
by DCSBL-
This awesome post can also help others: https://blog.espressif.com/secure-signi ... e855a2f2ef