Merge tag 'dm-pull-3dec19' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
[oweals/u-boot.git] / common / image-sig.c
index 4f6b4ec412c30c11989080e7c3e56a61959d572f..639a1124504f5c0450e950912e98e8f5c1023fa0 100644 (file)
@@ -89,6 +89,21 @@ struct checksum_algo *image_get_checksum_algo(const char *full_name)
        int i;
        const char *name;
 
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+       static bool done;
+
+       if (!done) {
+               done = true;
+               for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
+                       checksum_algos[i].name += gd->reloc_off;
+#if IMAGE_ENABLE_SIGN
+                       checksum_algos[i].calculate_sign += gd->reloc_off;
+#endif
+                       checksum_algos[i].calculate += gd->reloc_off;
+               }
+       }
+#endif
+
        for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
                name = checksum_algos[i].name;
                /* Make sure names match and next char is a comma */
@@ -105,6 +120,20 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
        int i;
        const char *name;
 
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+       static bool done;
+
+       if (!done) {
+               done = true;
+               for (i = 0; i < ARRAY_SIZE(crypto_algos); i++) {
+                       crypto_algos[i].name += gd->reloc_off;
+                       crypto_algos[i].sign += gd->reloc_off;
+                       crypto_algos[i].add_verify_data += gd->reloc_off;
+                       crypto_algos[i].verify += gd->reloc_off;
+               }
+       }
+#endif
+
        /* Move name to after the comma */
        name = strchr(full_name, ',');
        if (!name)
@@ -211,7 +240,7 @@ static int fit_image_setup_verify(struct image_sign_info *info,
        info->required_keynode = required_keynode;
        printf("%s:%s", algo_name, info->keyname);
 
-       if (!info->checksum || !info->crypto) {
+       if (!info->checksum || !info->crypto || !info->padding) {
                *err_msgp = "Unknown signature algorithm";
                return -1;
        }