Skip to contentSkip to conversation

lib: rsa: check algo match in rsa_verify_with_keynode

PATCH New Matthieu CASTET 2 participants 2 messages Sep 23, 2020 – Oct 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 lib/rsa/rsa-verify.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/rsa/rsa-verify.c +5 -0
index 2057f6819d..b9c800c7dc 100644
@@ -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);
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/1 lib: rsa: check algo match in rsa_verify_with_keynode

Quoted 7 lines · Matthieu CASTET

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201013/2ede574e/attachment.sig>