Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

98 lines
2.0 KiB

  1. /*
  2. * (C) Copyright 2014
  3. * DENX Software Engineering
  4. * Heiko Schocher <hs@denx.de>
  5. *
  6. * Based on:
  7. * (C) Copyright 2008 Semihalf
  8. *
  9. * (C) Copyright 2000-2004
  10. * DENX Software Engineering
  11. * Wolfgang Denk, wd@denx.de
  12. *
  13. * Updated-by: Prafulla Wadaskar <prafulla@marvell.com>
  14. * FIT image specific code abstracted from mkimage.c
  15. * some functions added to address abstraction
  16. *
  17. * All rights reserved.
  18. *
  19. * SPDX-License-Identifier: GPL-2.0+
  20. */
  21. #include "mkimage.h"
  22. #include "fit_common.h"
  23. #include <image.h>
  24. #include <u-boot/crc.h>
  25. void usage(char *cmdname)
  26. {
  27. fprintf(stderr, "Usage: %s -f fit file -k key file\n"
  28. " -f ==> set fit file which should be checked'\n"
  29. " -k ==> set key file which contains the key'\n",
  30. cmdname);
  31. exit(EXIT_FAILURE);
  32. }
  33. int main(int argc, char **argv)
  34. {
  35. int ffd = -1;
  36. int kfd = -1;
  37. struct stat fsbuf;
  38. struct stat ksbuf;
  39. void *fit_blob;
  40. char *fdtfile = NULL;
  41. char *keyfile = NULL;
  42. char cmdname[256];
  43. int ret;
  44. void *key_blob;
  45. int c;
  46. strncpy(cmdname, *argv, sizeof(cmdname) - 1);
  47. cmdname[sizeof(cmdname) - 1] = '\0';
  48. while ((c = getopt(argc, argv, "f:k:")) != -1)
  49. switch (c) {
  50. case 'f':
  51. fdtfile = optarg;
  52. break;
  53. case 'k':
  54. keyfile = optarg;
  55. break;
  56. default:
  57. usage(cmdname);
  58. break;
  59. }
  60. if (!fdtfile) {
  61. fprintf(stderr, "%s: Missing fdt file\n", *argv);
  62. usage(*argv);
  63. }
  64. if (!keyfile) {
  65. fprintf(stderr, "%s: Missing key file\n", *argv);
  66. usage(*argv);
  67. }
  68. ffd = mmap_fdt(cmdname, fdtfile, 0, &fit_blob, &fsbuf, false);
  69. if (ffd < 0)
  70. return EXIT_FAILURE;
  71. kfd = mmap_fdt(cmdname, keyfile, 0, &key_blob, &ksbuf, false);
  72. if (kfd < 0)
  73. return EXIT_FAILURE;
  74. image_set_host_blob(key_blob);
  75. ret = fit_check_sign(fit_blob, key_blob);
  76. if (!ret) {
  77. ret = EXIT_SUCCESS;
  78. fprintf(stderr, "Signature check OK\n");
  79. } else {
  80. ret = EXIT_FAILURE;
  81. fprintf(stderr, "Signature check Bad (error %d)\n", ret);
  82. }
  83. (void) munmap((void *)fit_blob, fsbuf.st_size);
  84. (void) munmap((void *)key_blob, ksbuf.st_size);
  85. close(ffd);
  86. close(kfd);
  87. exit(ret);
  88. }