From: "Marko Mäkelä" <marko.makela@iki.fi>
To: u-boot@lists.denx.de
Subject: How to use ECDSA for signature verification?
Date: Mon, 13 Oct 2025 21:36:44 +0300 [thread overview]
Message-ID: <aO1GvGrXUw-co84_@kehys.lan> (raw)
Hi all,
Yesterday, I successfully built the u-boot master branch with
CONFIG_FIT_SIGNATURE=y and CONFIG_RSA=y and got the signature
verification working with sha256,rsa2048.
Today, I wanted to try out CONFIG_ECDSA=y, but I am facing some trouble.
I am generating the key and trying to add its public part to the device
tree blob as with fdt_add_pubkey as follows:
openssl ecparam -name secp521r1 -genkey -noout -out dev-private.pem
openssl ec -in dev-private.pem -pubout -out dev.pem
cd u-boot
make ...
cp u-boot.dtb u-pubkey.dtb
tools/fdt_add_pubkey -a sha512,secp521r1 -n dev -k .. -r conf u-pubkey.dtb
The next step would be to run make EXT_DTB=u-pubkey.dtb ... so that the
public key will be embedded and the signature verification will be
enabled in the final u-boot.img.
Alas, the fdt_add_pubkey command would crash in SIGSEGV in alloc_ctx().
I figured out that the hash algorithm is not being looked up and
assigned. Maybe this is not necessary for the -a sha256,rsa2048 which I
was successfully using previously. The following patch fixes the
SIGSEGV:
diff --git a/tools/fdt_add_pubkey.c b/tools/fdt_add_pubkey.c
index 5582d7a8efe..4f7028cc15c 100644
--- a/tools/fdt_add_pubkey.c
+++ b/tools/fdt_add_pubkey.c
@@ -73,9 +73,10 @@ static void reset_info(struct image_sign_info *info)
info->keyname = keyname;
info->name = algo_name;
info->require_keys = require_keys;
+ info->checksum = image_get_checksum_algo(algo_name);
info->crypto = image_get_crypto_algo(algo_name);
- if (!info->crypto) {
+ if (!info->checksum || !info->crypto) {
fprintf(stderr, "Unsupported signature algorithm '%s'\n",
algo_name);
exit(EXIT_FAILURE);
However, with the above patch applied, I am facing the next trouble:
tools/fdt_add_pubkey -a sha512,secp521r1 -n dev -k .. -r conf u-boot-key.dtb
Can not read key from '../dev.pem'
tools/fdt_add_pubkey: Cannot add public key to FIT blob: Unknown error -5
In GDB, I can see that read_key() in lib/ecdsa/ecdsa-libcrypto.c would
invoke PEM_read_PrivateKey(), which I assume will fail, because
../dev.pem only contains a public key. In the planned deployment, the
private key would be private to a HSM or an external service. Moreover,
I do not understand why fdt_add_pubkey would attempt to access a private
key in the first place; that should only be needed for signing the
fitImage. Both prepare_ctx() and ecdsa_add_verify_data() would return
-5, which main() is reporting to stderr.
Has some way of using ECDSA based signature verification been tested?
The reason why I would like to avoid RSA is that it is not thought to be
quantum-secure, or secure against a cryptalalytic attack by a quantum
computer.
With best regards,
Marko Mäkelä
next reply other threads:[~2025-10-13 21:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 18:36 Marko Mäkelä [this message]
2025-11-08 17:24 ` How to use ECDSA for signature verification? Marko Mäkelä
2025-11-11 4:22 ` Anshul Dalal
2025-11-11 15:56 ` Marko Mäkelä
2026-02-03 5:32 ` Anshul Dalal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aO1GvGrXUw-co84_@kehys.lan \
--to=marko.makela@iki.fi \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox