From: Bob Wolff <bob.wolff68@gmail.com>
To: u-boot@lists.denx.de
Cc: seanga2@gmail.com, pbrobinson@gmail.com,
Bob Wolff <bob.wolff68@gmail.com>, Tom Rini <trini@konsulko.com>
Subject: [PATCH] Check curve_name for null to avoid crash
Date: Tue, 27 Feb 2024 15:57:03 -0800 [thread overview]
Message-ID: <20240227235704.48386-1-bob.wolff68@gmail.com> (raw)
If mixed rsa and ecdsa keys are specified in dtsi, an rsa key can be sent
into the ecdsa verify. Without the ecdsa,curve property, this function will
crash due to lack of checking the null pointer return.
Signed-off-by: Bob Wolff <bob.wolff68@gmail.com>
---
lib/ecdsa/ecdsa-verify.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/ecdsa/ecdsa-verify.c b/lib/ecdsa/ecdsa-verify.c
index 0601700c4f..4d1835b598 100644
--- a/lib/ecdsa/ecdsa-verify.c
+++ b/lib/ecdsa/ecdsa-verify.c
@@ -31,6 +31,11 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node)
int x_len, y_len;
key->curve_name = fdt_getprop(fdt, node, "ecdsa,curve", NULL);
+ if (!key->curve_name) {
+ debug("Error: ecdsa cannot get 'ecdsa,curve' property from key. Likely not an ecdsa key.\n");
+ return -ENOMSG;
+ }
+
key->size_bits = ecdsa_key_size(key->curve_name);
if (key->size_bits == 0) {
debug("Unknown ECDSA curve '%s'", key->curve_name);
--
2.39.3 (Apple Git-145)
next reply other threads:[~2024-02-28 4:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 23:57 Bob Wolff [this message]
2024-03-06 22:55 ` [PATCH] Check curve_name for null to avoid crash Bob Wolff
2024-03-07 17:12 ` Tom Rini
-- strict thread matches above, loose matches on Subject: below --
2024-02-22 22:18 Bob Wolff
2024-02-23 1:24 ` Sean Anderson
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=20240227235704.48386-1-bob.wolff68@gmail.com \
--to=bob.wolff68@gmail.com \
--cc=pbrobinson@gmail.com \
--cc=seanga2@gmail.com \
--cc=trini@konsulko.com \
--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