summaryrefslogtreecommitdiff
path: root/lib/rsa
diff options
context:
space:
mode:
authorMatthieu CASTET <castet.matthieu@free.fr>2020-09-23 19:11:44 +0200
committerTom Rini <trini@konsulko.com>2020-10-12 21:30:38 -0400
commit167fb1f8dc4bb2b99228c4582a462484ad41fa34 (patch)
tree61cb0b6cdff9191fd3ded48a03f12d94126681f6 /lib/rsa
parent54ab7cf1dd3f88e124d16c5ef64b0aae4e704ffc (diff)
lib: rsa: check algo match in rsa_verify_with_keynode
The algo name should match between the FIT's signature node and the U-Boot's control FDT. If we do not check it, U-Boot's control FDT can expect sha512 hash but nothing will prevent to accept image with sha1 hash if the signature is correct. Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
Diffstat (limited to 'lib/rsa')
-rw-r--r--lib/rsa/rsa-verify.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 2057f6819d..b9c800c7dc 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -439,12 +439,17 @@ static int rsa_verify_with_keynode(struct image_sign_info *info,
struct key_prop prop;
int length;
int ret = 0;
+ const char *algo;
if (node < 0) {
debug("%s: Skipping invalid node", __func__);
return -EBADF;
}
+ algo = fdt_getprop(blob, node, "algo", NULL);
+ if (strcmp(info->name, algo))
+ return -EFAULT;
+
prop.num_bits = fdtdec_get_int(blob, node, "rsa,num-bits", 0);
prop.n0inv = fdtdec_get_int(blob, node, "rsa,n0-inverse", 0);