mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/5] fit-image: Use compiled-in keys
Date: Tue, 15 Oct 2019 09:55:49 +0200	[thread overview]
Message-ID: <20191015075549.4380-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20191015075549.4380-1-s.hauer@pengutronix.de>

The compiled-in keys can be retrieved with rsa_get_key(). Try to use
them first before falling back to looking up the keys in the device
tree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/image-fit.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 71053fbef5..ca4d9ca10c 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -287,16 +287,21 @@ static int fit_check_rsa_signature(struct device_node *sig_node,
 		pr_err("key name not found in %s\n", sig_node->full_name);
 		return -EINVAL;
 	}
-	key_path = xasprintf("/signature/key-%s", key_name);
-	key_node = of_find_node_by_path(key_path);
-	if (!key_node) {
-		pr_info("failed to find key node %s\n", key_path);
+
+	key = rsa_get_key(key_name);
+	if (IS_ERR(key)) {
+		key_path = xasprintf("/signature/key-%s", key_name);
+		key_node = of_find_node_by_path(key_path);
+		if (!key_node) {
+			pr_info("failed to find key node %s\n", key_path);
+			free(key_path);
+			return -ENOENT;
+		}
 		free(key_path);
-		return -ENOENT;
+
+		key = rsa_of_read_key(key_node);
 	}
-	free(key_path);
 
-	key = rsa_of_read_key(key_node);
 	if (IS_ERR(key)) {
 		pr_info("failed to read key in %s\n", key_node->full_name);
 		return -ENOENT;
-- 
2.23.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2019-10-15  7:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  7:55 [PATCH 0/5] Allow to compile in rsa public keys directly Sascha Hauer
2019-10-15  7:55 ` [PATCH 1/5] Kbuild: Add config_filename macro from kernel Sascha Hauer
2019-10-15  7:55 ` [PATCH 2/5] scripts: Add rsatoc tool Sascha Hauer
2019-10-15 10:21   ` Ahmad Fatoum
2019-10-15 13:15     ` Sascha Hauer
2019-10-15 13:19       ` Ahmad Fatoum
2019-10-15  7:55 ` [PATCH 3/5] rsa: let rsa_of_read_key() return a fully allocated key Sascha Hauer
2019-10-15  7:55 ` [PATCH 4/5] rsa: Allow to directly compile in rsa public keys Sascha Hauer
2019-10-15  7:55 ` Sascha Hauer [this message]

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=20191015075549.4380-6-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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