summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/image-sig.c23
-rw-r--r--include/image.h4
-rw-r--r--lib/rsa/rsa-verify.c15
3 files changed, 25 insertions, 17 deletions
diff --git a/common/image-sig.c b/common/image-sig.c
index fb0035524e..fa9407bb30 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -51,19 +51,6 @@ struct checksum_algo checksum_algos[] = {
};
-struct padding_algo padding_algos[] = {
- {
- .name = "pkcs-1.5",
- .verify = padding_pkcs_15_verify,
- },
-#ifdef CONFIG_FIT_RSASSA_PSS
- {
- .name = "pss",
- .verify = padding_pss_verify,
- }
-#endif /* CONFIG_FIT_RSASSA_PSS */
-};
-
struct checksum_algo *image_get_checksum_algo(const char *full_name)
{
int i;
@@ -129,14 +116,16 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
struct padding_algo *image_get_padding_algo(const char *name)
{
- int i;
+ struct padding_algo *padding, *end;
if (!name)
return NULL;
- for (i = 0; i < ARRAY_SIZE(padding_algos); i++) {
- if (!strcmp(padding_algos[i].name, name))
- return &padding_algos[i];
+ padding = ll_entry_start(struct padding_algo, paddings);
+ end = ll_entry_end(struct padding_algo, paddings);
+ for (; padding < end; padding++) {
+ if (!strcmp(padding->name, name))
+ return padding;
}
return NULL;
diff --git a/include/image.h b/include/image.h
index 98b33d0629..73a763a693 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1312,6 +1312,10 @@ struct padding_algo {
const uint8_t *hash, int hash_len);
};
+/* Declare a new U-Boot padding algorithm handler */
+#define U_BOOT_PADDING_ALGO(__name) \
+ll_entry_declare(struct padding_algo, __name, paddings)
+
/**
* image_get_checksum_algo() - Look up a checksum algorithm
*
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 3840764e42..ad6d33d043 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -95,6 +95,13 @@ int padding_pkcs_15_verify(struct image_sign_info *info,
return 0;
}
+#ifndef USE_HOSTCC
+U_BOOT_PADDING_ALGO(pkcs_15) = {
+ .name = "pkcs-1.5",
+ .verify = padding_pkcs_15_verify,
+};
+#endif
+
#ifdef CONFIG_FIT_RSASSA_PSS
static void u32_i2osp(uint32_t val, uint8_t *buf)
{
@@ -296,6 +303,14 @@ out:
return ret;
}
+
+#ifndef USE_HOSTCC
+U_BOOT_PADDING_ALGO(pss) = {
+ .name = "pss",
+ .verify = padding_pss_verify,
+};
+#endif
+
#endif
#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY)