diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-17 08:10:25 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-17 08:10:25 +0200 |
commit | e66acf22a48a8163292eae03bca9baac874905bc (patch) | |
tree | 16cbd12d66b6c85637be89a2939306a4c9406ccb /common | |
parent | 9156b904baf981561a8ed486db52746b04d2e464 (diff) | |
parent | 9341918ba869bcbdd1b9147d1ae85f1f27440557 (diff) | |
download | barebox-e66acf22a48a8163292eae03bca9baac874905bc.tar.gz barebox-e66acf22a48a8163292eae03bca9baac874905bc.tar.xz |
Merge branch 'for-next/rsa'
Diffstat (limited to 'common')
-rw-r--r-- | common/command.c | 8 | ||||
-rw-r--r-- | common/image-fit.c | 33 |
2 files changed, 24 insertions, 17 deletions
diff --git a/common/command.c b/common/command.c index d9cc4a6d48..49845938ae 100644 --- a/common/command.c +++ b/common/command.c @@ -149,12 +149,12 @@ EXPORT_SYMBOL(find_cmd); */ static int init_command_list(void) { - struct command *cmdtp; + struct command * const *cmdtp; - for (cmdtp = &__barebox_cmd_start; - cmdtp != &__barebox_cmd_end; + for (cmdtp = __barebox_cmd_start; + cmdtp != __barebox_cmd_end; cmdtp++) - register_command(cmdtp); + register_command(*cmdtp); return 0; } diff --git a/common/image-fit.c b/common/image-fit.c index 6ac4644686..2681d62a9a 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -269,7 +269,7 @@ static struct digest *fit_alloc_digest(struct device_node *sig_node, static int fit_check_rsa_signature(struct device_node *sig_node, enum hash_algo algo, void *hash) { - struct rsa_public_key key = {}; + struct rsa_public_key *key; const char *key_name; char *key_path; struct device_node *key_node; @@ -287,27 +287,34 @@ 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; - } - free(key_path); - ret = rsa_of_read_key(key_node, &key); - if (ret) { - pr_info("failed to read key in %s\n", key_node->full_name); - return -ENOENT; + 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); + ret = rsa_verify(key, sig_value, sig_len, hash, algo); if (ret) pr_err("image signature BAD\n"); else pr_info("image signature OK\n"); + rsa_key_free(key); + return ret; } |