diff options
author | Bob Wolff <bob.wolff68@gmail.com> | 2024-02-27 15:57:03 -0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-03-07 07:41:41 -0500 |
commit | 9522956605205d23fe99142547ca3227574d418a (patch) | |
tree | 7bb5ff48beb02cd32ca5c94cb066ecbdc98a75ac /lib/ecdsa | |
parent | 6eb682bc7ea398fad4aadb612c690884e73edc03 (diff) | |
download | u-boot-9522956605205d23fe99142547ca3227574d418a.tar.gz |
Check curve_name for null to avoid crash
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>
Diffstat (limited to 'lib/ecdsa')
-rw-r--r-- | lib/ecdsa/ecdsa-verify.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ecdsa/ecdsa-verify.c b/lib/ecdsa/ecdsa-verify.c index 0601700c4fc..4d1835b598a 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); |