image: Use constants for 'required' and 'key-name-hint'
authorSimon Glass <sjg@chromium.org>
Wed, 18 Mar 2020 17:44:06 +0000 (11:44 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 1 Apr 2020 13:45:09 +0000 (07:45 -0600)
These are used in multiple places so update them to use a shared #define.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>
common/image-cipher.c
common/image-fit.c
common/image-sig.c
include/image.h
lib/rsa/rsa-sign.c
tools/image-host.c

index cee3b03ee50622c95ce59d9da8f3e0c4f369afe2..f50c3d31bd5ef48a35e5347228e846fa7c28dec4 100644 (file)
@@ -88,7 +88,7 @@ static int fit_image_setup_decrypt(struct image_cipher_info *info,
                return -1;
        }
 
-       info->keyname = fdt_getprop(fit, cipher_noffset, "key-name-hint", NULL);
+       info->keyname = fdt_getprop(fit, cipher_noffset, FIT_KEY_HINT, NULL);
        if (!info->keyname) {
                printf("Can't get key name\n");
                return -1;
index 47fc84aa4e3f0224aba7d271beef7266928eb6bb..0fef0a918da4b7979faae3749016a121822e4c4a 100644 (file)
@@ -168,7 +168,7 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p,
        int value_len;
        char *algo;
        const char *padding;
-       int required;
+       bool required;
        int ret, i;
 
        debug("%s  %s node:    '%s'\n", p, type,
@@ -179,8 +179,8 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p,
                return;
        }
        printf("%s", algo);
-       keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
-       required = fdt_getprop(fit, noffset, "required", NULL) != NULL;
+       keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
+       required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL) != NULL;
        if (keyname)
                printf(":%s", keyname);
        if (required)
index 03143a40401e90ee4222e8b9011fc2077ec1355b..6563effcf347d359350fe7193ffccf0371af52af 100644 (file)
@@ -229,7 +229,7 @@ static int fit_image_setup_verify(struct image_sign_info *info,
                padding_name = RSA_DEFAULT_PADDING_NAME;
 
        memset(info, '\0', sizeof(*info));
-       info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+       info->keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
        info->fit = (void *)fit;
        info->node_offset = noffset;
        info->name = algo_name;
@@ -340,7 +340,8 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset,
                const char *required;
                int ret;
 
-               required = fdt_getprop(sig_blob, noffset, "required", NULL);
+               required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
+                                      NULL);
                if (!required || strcmp(required, "image"))
                        continue;
                ret = fit_image_verify_sig(fit, image_noffset, data, size,
@@ -557,7 +558,8 @@ int fit_config_verify_required_sigs(const void *fit, int conf_noffset,
                const char *required;
                int ret;
 
-               required = fdt_getprop(sig_blob, noffset, "required", NULL);
+               required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
+                                      NULL);
                if (!required || strcmp(required, "conf"))
                        continue;
                ret = fit_config_verify_sig(fit, conf_noffset, sig_blob,
index 512243f159a7308bd4f10d934651f154e5df110e..3ffc0fdd6822a1ba6a68d2a81e53f5b42ced3528 100644 (file)
@@ -939,12 +939,14 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
 #define FIT_IMAGES_PATH                "/images"
 #define FIT_CONFS_PATH         "/configurations"
 
-/* hash/signature node */
+/* hash/signature/key node */
 #define FIT_HASH_NODENAME      "hash"
 #define FIT_ALGO_PROP          "algo"
 #define FIT_VALUE_PROP         "value"
 #define FIT_IGNORE_PROP                "uboot-ignore"
 #define FIT_SIG_NODENAME       "signature"
+#define FIT_KEY_REQUIRED       "required"
+#define FIT_KEY_HINT           "key-name-hint"
 
 /* cipher node */
 #define FIT_CIPHER_NODENAME    "cipher"
index 6400ef63d6a92a05ca83780138231e0787506dc7..580c74470939c580f8181583df1d860c7afb8b56 100644 (file)
@@ -792,8 +792,8 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest)
        }
 
        if (!ret) {
-               ret = fdt_setprop_string(keydest, node, "key-name-hint",
-                                info->keyname);
+               ret = fdt_setprop_string(keydest, node, FIT_KEY_HINT,
+                                        info->keyname);
        }
        if (!ret)
                ret = fdt_setprop_u32(keydest, node, "rsa,num-bits", bits);
@@ -815,7 +815,7 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest)
                                         info->name);
        }
        if (!ret && info->require_keys) {
-               ret = fdt_setprop_string(keydest, node, "required",
+               ret = fdt_setprop_string(keydest, node, FIT_KEY_REQUIRED,
                                         info->require_keys);
        }
 done:
index dfea48e894f482ff8422935e13eec12766bcbd8b..4e57ddea969cb614b6ff60b22d9f44fe64147610 100644 (file)
@@ -170,7 +170,7 @@ static int fit_image_setup_sig(struct image_sign_info *info,
 
        memset(info, '\0', sizeof(*info));
        info->keydir = keydir;
-       info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+       info->keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
        info->fit = fit;
        info->node_offset = noffset;
        info->name = strdup(algo_name);
@@ -249,7 +249,7 @@ static int fit_image_process_sig(const char *keydir, void *keydest,
        free(value);
 
        /* Get keyname again, as FDT has changed and invalidated our pointer */
-       info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+       info.keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
 
        /*
         * Write the public key into the supplied FDT file; this might fail
@@ -337,7 +337,7 @@ static int fit_image_setup_cipher(struct image_cipher_info *info,
        info->keydir = keydir;
 
        /* Read the key name */
-       info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+       info->keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
        if (!info->keyname) {
                printf("Can't get key name for cipher '%s' in image '%s'\n",
                       node_name, image_name);
@@ -886,7 +886,7 @@ static int fit_config_process_sig(const char *keydir, void *keydest,
        free(region_prop);
 
        /* Get keyname again, as FDT has changed and invalidated our pointer */
-       info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+       info.keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
 
        /* Write the public key into the supplied FDT file */
        if (keydest) {