]> git.sur5r.net Git - u-boot/blobdiff - tools/image-host.c
Merge branch 'master' of git://git.denx.de/u-boot-sh
[u-boot] / tools / image-host.c
index 5e4d690714160dcd68932f8eb6cf728640532ea6..8e43671714b8936f572c47bd2971d492c7cbad71 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2013, Google Inc.
  *
@@ -5,8 +6,6 @@
  *
  * (C) Copyright 2000-2006
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include "mkimage.h"
@@ -166,7 +165,7 @@ static int fit_image_setup_sig(struct image_sign_info *info,
        info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
        info->fit = fit;
        info->node_offset = noffset;
-       info->name = algo_name;
+       info->name = strdup(algo_name);
        info->checksum = image_get_checksum_algo(algo_name);
        info->crypto = image_get_crypto_algo(algo_name);
        info->require_keys = require_keys;
@@ -242,18 +241,19 @@ static int fit_image_process_sig(const char *keydir, void *keydest,
        /* Get keyname again, as FDT has changed and invalidated our pointer */
        info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
 
-       if (keydest)
-               ret = info.crypto->add_verify_data(&info, keydest);
-       else
-               return -1;
-
        /*
         * Write the public key into the supplied FDT file; this might fail
         * several times, since we try signing with successively increasing
         * size values
         */
-       if (keydest && ret)
-               return ret;
+       if (keydest) {
+               ret = info.crypto->add_verify_data(&info, keydest);
+               if (ret) {
+                       printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
+                              node_name, image_name);
+                       return ret;
+               }
+       }
 
        return 0;
 }
@@ -269,16 +269,16 @@ static int fit_image_process_sig(const char *keydir, void *keydest,
  *
  * Input component image node structure:
  *
- * o image@1 (at image_noffset)
+ * o image-1 (at image_noffset)
  *   | - data = [binary data]
- *   o hash@1
+ *   o hash-1
  *     |- algo = "sha1"
  *
  * Output component image node structure:
  *
- * o image@1 (at image_noffset)
+ * o image-1 (at image_noffset)
  *   | - data = [binary data]
- *   o hash@1
+ *   o hash-1
  *     |- algo = "sha1"
  *     |- value = sha1(data)
  *
@@ -320,7 +320,7 @@ int fit_image_add_verification_data(const char *keydir, void *keydest,
                /*
                 * Check subnode name, must be equal to "hash" or "signature".
                 * Multiple hash nodes require unique unit node
-                * names, e.g. hash@1, hash@2, signature@1, etc.
+                * names, e.g. hash-1, hash-2, signature-1, etc.
                 */
                node_name = fit_get_name(fit, noffset, NULL);
                if (!strncmp(node_name, FIT_HASH_NODENAME,
@@ -513,7 +513,7 @@ static int fit_config_get_data(void *fit, int conf_noffset, int noffset,
        int ret, len;
 
        conf_name = fit_get_name(fit, conf_noffset, NULL);
-       sig_name = fit_get_name(fit, conf_noffset, NULL);
+       sig_name = fit_get_name(fit, noffset, NULL);
        debug("%s: conf='%s', sig='%s'\n", __func__, conf_name, sig_name);
 
        /* Get a list of nodes we want to hash */
@@ -625,10 +625,8 @@ static int fit_config_process_sig(const char *keydir, void *keydest,
        /* Write the public key into the supplied FDT file */
        if (keydest) {
                ret = info.crypto->add_verify_data(&info, keydest);
-               if (ret == -ENOSPC)
-                       return -ENOSPC;
                if (ret) {
-                       printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
+                       printf("Failed to add verification data for '%s' signature node in '%s' configuration node\n",
                               node_name, conf_name);
                }
                return ret;