]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: rsa: Move verification algorithm to a linker list
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Wed, 14 Jul 2021 22:05:40 +0000 (17:05 -0500)
committerTom Rini <trini@konsulko.com>
Fri, 16 Jul 2021 19:38:49 +0000 (15:38 -0400)
Move the RSA verification crytpo_algo structure out of the
crypto_algos array, and into a linker list.

Although it appears we are adding an #ifdef to rsa-verify.c, the gains
outweigh this small inconvenience. This is because rsa_verify() is
defined differently based on #ifdefs. This change allows us to have
a single definition of rsa_verify().

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/image-sig.c
lib/rsa/rsa-verify.c

index 81a3b739febc9d3322a97b64500af177bd12b0ab..83f3e9fa09e7aa19b8e4b56638b8dee64cd8804a 100644 (file)
@@ -52,16 +52,6 @@ struct checksum_algo checksum_algos[] = {
 };
 
 struct crypto_algo crypto_algos[] = {
-       {
-               .name = "rsa2048",
-               .key_len = RSA2048_BYTES,
-               .verify = rsa_verify,
-       },
-       {
-               .name = "rsa4096",
-               .key_len = RSA4096_BYTES,
-               .verify = rsa_verify,
-       },
 };
 
 struct padding_algo padding_algos[] = {
index 1998c773fc7f0bdeb61d39704623d5cac11be914..bb8cc61d94b50857abc71534dfafb8304a0f69c7 100644 (file)
@@ -571,3 +571,19 @@ int rsa_verify(struct image_sign_info *info,
 
        return rsa_verify_hash(info, hash, sig, sig_len);
 }
+
+#ifndef USE_HOSTCC
+
+U_BOOT_CRYPTO_ALGO(rsa2048) = {
+       .name = "rsa2048",
+       .key_len = RSA2048_BYTES,
+       .verify = rsa_verify,
+};
+
+U_BOOT_CRYPTO_ALGO(rsa4096) = {
+       .name = "rsa4096",
+       .key_len = RSA4096_BYTES,
+       .verify = rsa_verify,
+};
+
+#endif