summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-10-01 23:45:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-15 14:55:11 +0200
commit9341918ba869bcbdd1b9147d1ae85f1f27440557 (patch)
treee9fa7d2c24a558cadc8f05548df1dd92697d4017 /common
parentb39100bcea12b29d64c536ea5f4c57380dfcf056 (diff)
downloadbarebox-9341918ba869bcbdd1b9147d1ae85f1f27440557.tar.gz
fit-image: Use compiled-in keys
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>
Diffstat (limited to 'common')
-rw-r--r--common/image-fit.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/common/image-fit.c b/common/image-fit.c
index 71053fb..2681d62 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -287,19 +287,24 @@ 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);
- free(key_path);
- return -ENOENT;
- }
- free(key_path);
- key = rsa_of_read_key(key_node);
+ key = rsa_get_key(key_name);
if (IS_ERR(key)) {
- pr_info("failed to read key in %s\n", key_node->full_name);
- return -ENOENT;
+ 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);
+
+ 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;
+ }
}
ret = rsa_verify(key, sig_value, sig_len, hash, algo);