image-host.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * Copyright (c) 2013, Google Inc.
  3. *
  4. * (C) Copyright 2008 Semihalf
  5. *
  6. * (C) Copyright 2000-2006
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include "mkimage.h"
  12. #include <image.h>
  13. #include <version.h>
  14. /**
  15. * fit_set_hash_value - set hash value in requested has node
  16. * @fit: pointer to the FIT format image header
  17. * @noffset: hash node offset
  18. * @value: hash value to be set
  19. * @value_len: hash value length
  20. *
  21. * fit_set_hash_value() attempts to set hash value in a node at offset
  22. * given and returns operation status to the caller.
  23. *
  24. * returns
  25. * 0, on success
  26. * -1, on failure
  27. */
  28. static int fit_set_hash_value(void *fit, int noffset, uint8_t *value,
  29. int value_len)
  30. {
  31. int ret;
  32. ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len);
  33. if (ret) {
  34. printf("Can't set hash '%s' property for '%s' node(%s)\n",
  35. FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL),
  36. fdt_strerror(ret));
  37. return -1;
  38. }
  39. return 0;
  40. }
  41. /**
  42. * fit_image_process_hash - Process a single subnode of the images/ node
  43. *
  44. * Check each subnode and process accordingly. For hash nodes we generate
  45. * a hash of the supplised data and store it in the node.
  46. *
  47. * @fit: pointer to the FIT format image header
  48. * @image_name: name of image being processes (used to display errors)
  49. * @noffset: subnode offset
  50. * @data: data to process
  51. * @size: size of data in bytes
  52. * @return 0 if ok, -1 on error
  53. */
  54. static int fit_image_process_hash(void *fit, const char *image_name,
  55. int noffset, const void *data, size_t size)
  56. {
  57. uint8_t value[FIT_MAX_HASH_LEN];
  58. const char *node_name;
  59. int value_len;
  60. char *algo;
  61. node_name = fit_get_name(fit, noffset, NULL);
  62. if (fit_image_hash_get_algo(fit, noffset, &algo)) {
  63. printf("Can't get hash algo property for '%s' hash node in '%s' image node\n",
  64. node_name, image_name);
  65. return -1;
  66. }
  67. if (calculate_hash(data, size, algo, value, &value_len)) {
  68. printf("Unsupported hash algorithm (%s) for '%s' hash node in '%s' image node\n",
  69. algo, node_name, image_name);
  70. return -1;
  71. }
  72. if (fit_set_hash_value(fit, noffset, value, value_len)) {
  73. printf("Can't set hash value for '%s' hash node in '%s' image node\n",
  74. node_name, image_name);
  75. return -1;
  76. }
  77. return 0;
  78. }
  79. /**
  80. * fit_image_write_sig() - write the signature to a FIT
  81. *
  82. * This writes the signature and signer data to the FIT.
  83. *
  84. * @fit: pointer to the FIT format image header
  85. * @noffset: hash node offset
  86. * @value: signature value to be set
  87. * @value_len: signature value length
  88. * @comment: Text comment to write (NULL for none)
  89. *
  90. * returns
  91. * 0, on success
  92. * -FDT_ERR_..., on failure
  93. */
  94. static int fit_image_write_sig(void *fit, int noffset, uint8_t *value,
  95. int value_len, const char *comment, const char *region_prop,
  96. int region_proplen)
  97. {
  98. int string_size;
  99. int ret;
  100. /*
  101. * Get the current string size, before we update the FIT and add
  102. * more
  103. */
  104. string_size = fdt_size_dt_strings(fit);
  105. ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len);
  106. if (!ret) {
  107. ret = fdt_setprop_string(fit, noffset, "signer-name",
  108. "mkimage");
  109. }
  110. if (!ret) {
  111. ret = fdt_setprop_string(fit, noffset, "signer-version",
  112. PLAIN_VERSION);
  113. }
  114. if (comment && !ret)
  115. ret = fdt_setprop_string(fit, noffset, "comment", comment);
  116. if (!ret)
  117. ret = fit_set_timestamp(fit, noffset, time(NULL));
  118. if (region_prop && !ret) {
  119. uint32_t strdata[2];
  120. ret = fdt_setprop(fit, noffset, "hashed-nodes",
  121. region_prop, region_proplen);
  122. strdata[0] = 0;
  123. strdata[1] = cpu_to_fdt32(string_size);
  124. if (!ret) {
  125. ret = fdt_setprop(fit, noffset, "hashed-strings",
  126. strdata, sizeof(strdata));
  127. }
  128. }
  129. return ret;
  130. }
  131. static int fit_image_setup_sig(struct image_sign_info *info,
  132. const char *keydir, void *fit, const char *image_name,
  133. int noffset, const char *require_keys)
  134. {
  135. const char *node_name;
  136. char *algo_name;
  137. node_name = fit_get_name(fit, noffset, NULL);
  138. if (fit_image_hash_get_algo(fit, noffset, &algo_name)) {
  139. printf("Can't get algo property for '%s' signature node in '%s' image node\n",
  140. node_name, image_name);
  141. return -1;
  142. }
  143. memset(info, '\0', sizeof(*info));
  144. info->keydir = keydir;
  145. info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
  146. info->fit = fit;
  147. info->node_offset = noffset;
  148. info->algo = image_get_sig_algo(algo_name);
  149. info->require_keys = require_keys;
  150. if (!info->algo) {
  151. printf("Unsupported signature algorithm (%s) for '%s' signature node in '%s' image node\n",
  152. algo_name, node_name, image_name);
  153. return -1;
  154. }
  155. return 0;
  156. }
  157. /**
  158. * fit_image_process_sig- Process a single subnode of the images/ node
  159. *
  160. * Check each subnode and process accordingly. For signature nodes we
  161. * generate a signed hash of the supplised data and store it in the node.
  162. *
  163. * @keydir: Directory containing keys to use for signing
  164. * @keydest: Destination FDT blob to write public keys into
  165. * @fit: pointer to the FIT format image header
  166. * @image_name: name of image being processes (used to display errors)
  167. * @noffset: subnode offset
  168. * @data: data to process
  169. * @size: size of data in bytes
  170. * @comment: Comment to add to signature nodes
  171. * @require_keys: Mark all keys as 'required'
  172. * @return 0 if ok, -1 on error
  173. */
  174. static int fit_image_process_sig(const char *keydir, void *keydest,
  175. void *fit, const char *image_name,
  176. int noffset, const void *data, size_t size,
  177. const char *comment, int require_keys)
  178. {
  179. struct image_sign_info info;
  180. struct image_region region;
  181. const char *node_name;
  182. uint8_t *value;
  183. uint value_len;
  184. int ret;
  185. if (fit_image_setup_sig(&info, keydir, fit, image_name, noffset,
  186. require_keys ? "image" : NULL))
  187. return -1;
  188. node_name = fit_get_name(fit, noffset, NULL);
  189. region.data = data;
  190. region.size = size;
  191. ret = info.algo->sign(&info, &region, 1, &value, &value_len);
  192. if (ret) {
  193. printf("Failed to sign '%s' signature node in '%s' image node: %d\n",
  194. node_name, image_name, ret);
  195. /* We allow keys to be missing */
  196. if (ret == -ENOENT)
  197. return 0;
  198. return -1;
  199. }
  200. ret = fit_image_write_sig(fit, noffset, value, value_len, comment,
  201. NULL, 0);
  202. if (ret) {
  203. printf("Can't write signature for '%s' signature node in '%s' image node: %s\n",
  204. node_name, image_name, fdt_strerror(ret));
  205. return -1;
  206. }
  207. free(value);
  208. /* Get keyname again, as FDT has changed and invalidated our pointer */
  209. info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
  210. /* Write the public key into the supplied FDT file */
  211. if (keydest && info.algo->add_verify_data(&info, keydest)) {
  212. printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
  213. node_name, image_name);
  214. return -1;
  215. }
  216. return 0;
  217. }
  218. /**
  219. * fit_image_add_verification_data() - calculate/set verig. data for image node
  220. *
  221. * This adds hash and signature values for an component image node.
  222. *
  223. * All existing hash subnodes are checked, if algorithm property is set to
  224. * one of the supported hash algorithms, hash value is computed and
  225. * corresponding hash node property is set, for example:
  226. *
  227. * Input component image node structure:
  228. *
  229. * o image@1 (at image_noffset)
  230. * | - data = [binary data]
  231. * o hash@1
  232. * |- algo = "sha1"
  233. *
  234. * Output component image node structure:
  235. *
  236. * o image@1 (at image_noffset)
  237. * | - data = [binary data]
  238. * o hash@1
  239. * |- algo = "sha1"
  240. * |- value = sha1(data)
  241. *
  242. * For signature details, please see doc/uImage.FIT/signature.txt
  243. *
  244. * @keydir Directory containing *.key and *.crt files (or NULL)
  245. * @keydest FDT Blob to write public keys into (NULL if none)
  246. * @fit: Pointer to the FIT format image header
  247. * @image_noffset: Requested component image node
  248. * @comment: Comment to add to signature nodes
  249. * @require_keys: Mark all keys as 'required'
  250. * @return: 0 on success, <0 on failure
  251. */
  252. int fit_image_add_verification_data(const char *keydir, void *keydest,
  253. void *fit, int image_noffset, const char *comment,
  254. int require_keys)
  255. {
  256. const char *image_name;
  257. const void *data;
  258. size_t size;
  259. int noffset;
  260. /* Get image data and data length */
  261. if (fit_image_get_data(fit, image_noffset, &data, &size)) {
  262. printf("Can't get image data/size\n");
  263. return -1;
  264. }
  265. image_name = fit_get_name(fit, image_noffset, NULL);
  266. /* Process all hash subnodes of the component image node */
  267. for (noffset = fdt_first_subnode(fit, image_noffset);
  268. noffset >= 0;
  269. noffset = fdt_next_subnode(fit, noffset)) {
  270. const char *node_name;
  271. int ret = 0;
  272. /*
  273. * Check subnode name, must be equal to "hash" or "signature".
  274. * Multiple hash nodes require unique unit node
  275. * names, e.g. hash@1, hash@2, signature@1, etc.
  276. */
  277. node_name = fit_get_name(fit, noffset, NULL);
  278. if (!strncmp(node_name, FIT_HASH_NODENAME,
  279. strlen(FIT_HASH_NODENAME))) {
  280. ret = fit_image_process_hash(fit, image_name, noffset,
  281. data, size);
  282. } else if (IMAGE_ENABLE_SIGN && keydir &&
  283. !strncmp(node_name, FIT_SIG_NODENAME,
  284. strlen(FIT_SIG_NODENAME))) {
  285. ret = fit_image_process_sig(keydir, keydest,
  286. fit, image_name, noffset, data, size,
  287. comment, require_keys);
  288. }
  289. if (ret)
  290. return -1;
  291. }
  292. return 0;
  293. }
  294. struct strlist {
  295. int count;
  296. char **strings;
  297. };
  298. static void strlist_init(struct strlist *list)
  299. {
  300. memset(list, '\0', sizeof(*list));
  301. }
  302. static void strlist_free(struct strlist *list)
  303. {
  304. int i;
  305. for (i = 0; i < list->count; i++)
  306. free(list->strings[i]);
  307. free(list->strings);
  308. }
  309. static int strlist_add(struct strlist *list, const char *str)
  310. {
  311. char *dup;
  312. dup = strdup(str);
  313. list->strings = realloc(list->strings,
  314. (list->count + 1) * sizeof(char *));
  315. if (!list || !str)
  316. return -1;
  317. list->strings[list->count++] = dup;
  318. return 0;
  319. }
  320. static const char *fit_config_get_image_list(void *fit, int noffset,
  321. int *lenp, int *allow_missingp)
  322. {
  323. static const char default_list[] = FIT_KERNEL_PROP "\0"
  324. FIT_FDT_PROP;
  325. const char *prop;
  326. /* If there is an "image" property, use that */
  327. prop = fdt_getprop(fit, noffset, "sign-images", lenp);
  328. if (prop) {
  329. *allow_missingp = 0;
  330. return *lenp ? prop : NULL;
  331. }
  332. /* Default image list */
  333. *allow_missingp = 1;
  334. *lenp = sizeof(default_list);
  335. return default_list;
  336. }
  337. static int fit_config_get_hash_list(void *fit, int conf_noffset,
  338. int sig_offset, struct strlist *node_inc)
  339. {
  340. int allow_missing;
  341. const char *prop, *iname, *end;
  342. const char *conf_name, *sig_name;
  343. char name[200], path[200];
  344. int image_count;
  345. int ret, len;
  346. conf_name = fit_get_name(fit, conf_noffset, NULL);
  347. sig_name = fit_get_name(fit, sig_offset, NULL);
  348. /*
  349. * Build a list of nodes we need to hash. We always need the root
  350. * node and the configuration.
  351. */
  352. strlist_init(node_inc);
  353. snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH, conf_name);
  354. if (strlist_add(node_inc, "/") ||
  355. strlist_add(node_inc, name))
  356. goto err_mem;
  357. /* Get a list of images that we intend to sign */
  358. prop = fit_config_get_image_list(fit, sig_offset, &len,
  359. &allow_missing);
  360. if (!prop)
  361. return 0;
  362. /* Locate the images */
  363. end = prop + len;
  364. image_count = 0;
  365. for (iname = prop; iname < end; iname += strlen(iname) + 1) {
  366. int noffset;
  367. int image_noffset;
  368. int hash_count;
  369. image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
  370. iname);
  371. if (image_noffset < 0) {
  372. printf("Failed to find image '%s' in configuration '%s/%s'\n",
  373. iname, conf_name, sig_name);
  374. if (allow_missing)
  375. continue;
  376. return -ENOENT;
  377. }
  378. ret = fdt_get_path(fit, image_noffset, path, sizeof(path));
  379. if (ret < 0)
  380. goto err_path;
  381. if (strlist_add(node_inc, path))
  382. goto err_mem;
  383. snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH,
  384. conf_name);
  385. /* Add all this image's hashes */
  386. hash_count = 0;
  387. for (noffset = fdt_first_subnode(fit, image_noffset);
  388. noffset >= 0;
  389. noffset = fdt_next_subnode(fit, noffset)) {
  390. const char *name = fit_get_name(fit, noffset, NULL);
  391. if (strncmp(name, FIT_HASH_NODENAME,
  392. strlen(FIT_HASH_NODENAME)))
  393. continue;
  394. ret = fdt_get_path(fit, noffset, path, sizeof(path));
  395. if (ret < 0)
  396. goto err_path;
  397. if (strlist_add(node_inc, path))
  398. goto err_mem;
  399. hash_count++;
  400. }
  401. if (!hash_count) {
  402. printf("Failed to find any hash nodes in configuration '%s/%s' image '%s' - without these it is not possible to verify this image\n",
  403. conf_name, sig_name, iname);
  404. return -ENOMSG;
  405. }
  406. image_count++;
  407. }
  408. if (!image_count) {
  409. printf("Failed to find any images for configuration '%s/%s'\n",
  410. conf_name, sig_name);
  411. return -ENOMSG;
  412. }
  413. return 0;
  414. err_mem:
  415. printf("Out of memory processing configuration '%s/%s'\n", conf_name,
  416. sig_name);
  417. return -ENOMEM;
  418. err_path:
  419. printf("Failed to get path for image '%s' in configuration '%s/%s': %s\n",
  420. iname, conf_name, sig_name, fdt_strerror(ret));
  421. return -ENOENT;
  422. }
  423. static int fit_config_get_data(void *fit, int conf_noffset, int noffset,
  424. struct image_region **regionp, int *region_countp,
  425. char **region_propp, int *region_proplen)
  426. {
  427. char * const exc_prop[] = {"data"};
  428. struct strlist node_inc;
  429. struct image_region *region;
  430. struct fdt_region fdt_regions[100];
  431. const char *conf_name, *sig_name;
  432. char path[200];
  433. int count, i;
  434. char *region_prop;
  435. int ret, len;
  436. conf_name = fit_get_name(fit, conf_noffset, NULL);
  437. sig_name = fit_get_name(fit, conf_noffset, NULL);
  438. debug("%s: conf='%s', sig='%s'\n", __func__, conf_name, sig_name);
  439. /* Get a list of nodes we want to hash */
  440. ret = fit_config_get_hash_list(fit, conf_noffset, noffset, &node_inc);
  441. if (ret)
  442. return ret;
  443. /* Get a list of regions to hash */
  444. count = fdt_find_regions(fit, node_inc.strings, node_inc.count,
  445. exc_prop, ARRAY_SIZE(exc_prop),
  446. fdt_regions, ARRAY_SIZE(fdt_regions),
  447. path, sizeof(path), 1);
  448. if (count < 0) {
  449. printf("Failed to hash configuration '%s/%s': %s\n", conf_name,
  450. sig_name, fdt_strerror(ret));
  451. return -EIO;
  452. }
  453. if (count == 0) {
  454. printf("No data to hash for configuration '%s/%s': %s\n",
  455. conf_name, sig_name, fdt_strerror(ret));
  456. return -EINVAL;
  457. }
  458. /* Build our list of data blocks */
  459. region = fit_region_make_list(fit, fdt_regions, count, NULL);
  460. if (!region) {
  461. printf("Out of memory hashing configuration '%s/%s'\n",
  462. conf_name, sig_name);
  463. return -ENOMEM;
  464. }
  465. /* Create a list of all hashed properties */
  466. debug("Hash nodes:\n");
  467. for (i = len = 0; i < node_inc.count; i++) {
  468. debug(" %s\n", node_inc.strings[i]);
  469. len += strlen(node_inc.strings[i]) + 1;
  470. }
  471. region_prop = malloc(len);
  472. if (!region_prop) {
  473. printf("Out of memory setting up regions for configuration '%s/%s'\n",
  474. conf_name, sig_name);
  475. return -ENOMEM;
  476. }
  477. for (i = len = 0; i < node_inc.count;
  478. len += strlen(node_inc.strings[i]) + 1, i++)
  479. strcpy(region_prop + len, node_inc.strings[i]);
  480. strlist_free(&node_inc);
  481. *region_countp = count;
  482. *regionp = region;
  483. *region_propp = region_prop;
  484. *region_proplen = len;
  485. return 0;
  486. }
  487. static int fit_config_process_sig(const char *keydir, void *keydest,
  488. void *fit, const char *conf_name, int conf_noffset,
  489. int noffset, const char *comment, int require_keys)
  490. {
  491. struct image_sign_info info;
  492. const char *node_name;
  493. struct image_region *region;
  494. char *region_prop;
  495. int region_proplen;
  496. int region_count;
  497. uint8_t *value;
  498. uint value_len;
  499. int ret;
  500. node_name = fit_get_name(fit, noffset, NULL);
  501. if (fit_config_get_data(fit, conf_noffset, noffset, &region,
  502. &region_count, &region_prop, &region_proplen))
  503. return -1;
  504. if (fit_image_setup_sig(&info, keydir, fit, conf_name, noffset,
  505. require_keys ? "conf" : NULL))
  506. return -1;
  507. ret = info.algo->sign(&info, region, region_count, &value, &value_len);
  508. free(region);
  509. if (ret) {
  510. printf("Failed to sign '%s' signature node in '%s' conf node\n",
  511. node_name, conf_name);
  512. /* We allow keys to be missing */
  513. if (ret == -ENOENT)
  514. return 0;
  515. return -1;
  516. }
  517. if (fit_image_write_sig(fit, noffset, value, value_len, comment,
  518. region_prop, region_proplen)) {
  519. printf("Can't write signature for '%s' signature node in '%s' conf node\n",
  520. node_name, conf_name);
  521. return -1;
  522. }
  523. free(value);
  524. free(region_prop);
  525. /* Get keyname again, as FDT has changed and invalidated our pointer */
  526. info.keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
  527. /* Write the public key into the supplied FDT file */
  528. if (keydest && info.algo->add_verify_data(&info, keydest)) {
  529. printf("Failed to add verification data for '%s' signature node in '%s' image node\n",
  530. node_name, conf_name);
  531. return -1;
  532. }
  533. return 0;
  534. }
  535. static int fit_config_add_verification_data(const char *keydir, void *keydest,
  536. void *fit, int conf_noffset, const char *comment,
  537. int require_keys)
  538. {
  539. const char *conf_name;
  540. int noffset;
  541. conf_name = fit_get_name(fit, conf_noffset, NULL);
  542. /* Process all hash subnodes of the configuration node */
  543. for (noffset = fdt_first_subnode(fit, conf_noffset);
  544. noffset >= 0;
  545. noffset = fdt_next_subnode(fit, noffset)) {
  546. const char *node_name;
  547. int ret = 0;
  548. node_name = fit_get_name(fit, noffset, NULL);
  549. if (!strncmp(node_name, FIT_SIG_NODENAME,
  550. strlen(FIT_SIG_NODENAME))) {
  551. ret = fit_config_process_sig(keydir, keydest,
  552. fit, conf_name, conf_noffset, noffset, comment,
  553. require_keys);
  554. }
  555. if (ret)
  556. return ret;
  557. }
  558. return 0;
  559. }
  560. int fit_add_verification_data(const char *keydir, void *keydest, void *fit,
  561. const char *comment, int require_keys)
  562. {
  563. int images_noffset, confs_noffset;
  564. int noffset;
  565. int ret;
  566. /* Find images parent node offset */
  567. images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
  568. if (images_noffset < 0) {
  569. printf("Can't find images parent node '%s' (%s)\n",
  570. FIT_IMAGES_PATH, fdt_strerror(images_noffset));
  571. return images_noffset;
  572. }
  573. /* Process its subnodes, print out component images details */
  574. for (noffset = fdt_first_subnode(fit, images_noffset);
  575. noffset >= 0;
  576. noffset = fdt_next_subnode(fit, noffset)) {
  577. /*
  578. * Direct child node of the images parent node,
  579. * i.e. component image node.
  580. */
  581. ret = fit_image_add_verification_data(keydir, keydest,
  582. fit, noffset, comment, require_keys);
  583. if (ret)
  584. return ret;
  585. }
  586. /* If there are no keys, we can't sign configurations */
  587. if (!IMAGE_ENABLE_SIGN || !keydir)
  588. return 0;
  589. /* Find configurations parent node offset */
  590. confs_noffset = fdt_path_offset(fit, FIT_CONFS_PATH);
  591. if (confs_noffset < 0) {
  592. printf("Can't find images parent node '%s' (%s)\n",
  593. FIT_IMAGES_PATH, fdt_strerror(confs_noffset));
  594. return -ENOENT;
  595. }
  596. /* Process its subnodes, print out component images details */
  597. for (noffset = fdt_first_subnode(fit, confs_noffset);
  598. noffset >= 0;
  599. noffset = fdt_next_subnode(fit, noffset)) {
  600. ret = fit_config_add_verification_data(keydir, keydest,
  601. fit, noffset, comment,
  602. require_keys);
  603. if (ret)
  604. return ret;
  605. }
  606. return 0;
  607. }
  608. #ifdef CONFIG_FIT_SIGNATURE
  609. int fit_check_sign(const void *working_fdt, const void *key)
  610. {
  611. int cfg_noffset;
  612. int ret;
  613. cfg_noffset = fit_conf_get_node(working_fdt, NULL);
  614. if (!cfg_noffset)
  615. return -1;
  616. ret = fit_config_verify(working_fdt, cfg_noffset);
  617. return ret;
  618. }
  619. #endif