Subject: [PATCH] image-fit: ignore rsa by image selection
From: Denis Osterland-Heim <[email-masked]>
To: [email-masked]
Date: Thu, 11 Mar 2021 18:03:34 +0100

From: Denis Osterland-Heim <[email-masked]>

For hash algorithm selection, only the first argument of the tuple is
needed. The ',' is included to avoid false-positive matches.

Signed-off-by: Denis Osterland-Heim <[email-masked]>
---
 common/image-fit.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 538e61f51..2c5ef7f68 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -230,11 +230,9 @@ static struct digest *fit_alloc_digest(struct device_node *sig_node,
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (strcmp(algo_name, "sha1,rsa2048") == 0) {
+	if (strncmp(algo_name, "sha1,", 5) == 0) {
 		algo = HASH_ALGO_SHA1;
-	} else if (strcmp(algo_name, "sha256,rsa2048") == 0) {
-		algo = HASH_ALGO_SHA256;
-	} else if (strcmp(algo_name, "sha256,rsa4096") == 0) {
+	} else if (strncmp(algo_name, "sha256,", 7) == 0) {
 		algo = HASH_ALGO_SHA256;
 	} else	{
 		pr_err("unknown algo %s\n", algo_name);
-- 
2.30.2