tools: image-host: support add all images of sub list into hash list

Like the image list assigned by "loadables" = ...

configurations {
	default = "config@1";
	config@1 {
		...
		loadables = "uboot@1", "atf@2", "atf@3";
		signature@1 {
			algo = "sha1,rsa2048";
			key-name-hint = "dev";
			sign-images = "fdt", "firmware", "loadables";
		};
	};
};

Assuming the maximum sub image count is 5.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I0454f6ad108342b5d85e831f7920baac642fb01a
This commit is contained in:
Joseph Chen 2020-03-08 14:33:03 +08:00 committed by Jianhong Chen
parent f63c73dbcf
commit 3a183b396d
1 changed files with 43 additions and 36 deletions

View File

@ -431,52 +431,59 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
int noffset; int noffset;
int image_noffset; int image_noffset;
int hash_count; int hash_count;
int i;
image_noffset = fit_conf_get_prop_node(fit, conf_noffset, for (i = 0; i < 5; i++) {
iname); image_noffset =
if (image_noffset < 0) { fit_conf_get_prop_node_index(fit, conf_noffset,
printf("Failed to find image '%s' in configuration '%s/%s'\n", iname, i);
iname, conf_name, sig_name); if (image_noffset < 0) {
if (allow_missing) if (i > 0)
continue; break;
return -ENOENT; printf("Failed to find image '%s' in configuration '%s/%s'\n",
} iname, conf_name, sig_name);
if (allow_missing)
continue;
ret = fdt_get_path(fit, image_noffset, path, sizeof(path)); return -ENOENT;
if (ret < 0) }
goto err_path;
if (strlist_add(node_inc, path))
goto err_mem;
snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH, ret = fdt_get_path(fit, image_noffset, path, sizeof(path));
conf_name);
/* Add all this image's hashes */
hash_count = 0;
for (noffset = fdt_first_subnode(fit, image_noffset);
noffset >= 0;
noffset = fdt_next_subnode(fit, noffset)) {
const char *name = fit_get_name(fit, noffset, NULL);
if (strncmp(name, FIT_HASH_NODENAME,
strlen(FIT_HASH_NODENAME)))
continue;
ret = fdt_get_path(fit, noffset, path, sizeof(path));
if (ret < 0) if (ret < 0)
goto err_path; goto err_path;
if (strlist_add(node_inc, path)) if (strlist_add(node_inc, path))
goto err_mem; goto err_mem;
hash_count++;
}
if (!hash_count) { snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH,
printf("Failed to find any hash nodes in configuration '%s/%s' image '%s' - without these it is not possible to verify this image\n", conf_name);
conf_name, sig_name, iname);
return -ENOMSG;
}
image_count++; /* Add all this image's hashes */
hash_count = 0;
for (noffset = fdt_first_subnode(fit, image_noffset);
noffset >= 0;
noffset = fdt_next_subnode(fit, noffset)) {
const char *name = fit_get_name(fit, noffset, NULL);
if (strncmp(name, FIT_HASH_NODENAME,
strlen(FIT_HASH_NODENAME)))
continue;
ret = fdt_get_path(fit, noffset, path, sizeof(path));
if (ret < 0)
goto err_path;
if (strlist_add(node_inc, path))
goto err_mem;
hash_count++;
}
if (!hash_count) {
printf("Failed to find any hash nodes in configuration '%s/%s' image '%s' - without these it is not possible to verify this image\n",
conf_name, sig_name, iname);
return -ENOMSG;
}
image_count++;
}
} }
if (!image_count) { if (!image_count) {