cmd_sha1sum.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * (C) Copyright 2011
  3. * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  4. *
  5. * (C) Copyright 2000
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. #include <hash.h>
  29. #include <sha1.h>
  30. int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  31. {
  32. int flags = HASH_FLAG_ENV;
  33. int ac;
  34. char * const *av;
  35. if (argc < 3)
  36. return CMD_RET_USAGE;
  37. av = argv + 1;
  38. ac = argc - 1;
  39. #ifdef CONFIG_SHA1SUM_VERIFY
  40. if (strcmp(*av, "-v") == 0) {
  41. flags |= HASH_FLAG_VERIFY;
  42. av++;
  43. ac--;
  44. }
  45. #endif
  46. return hash_command("sha1", flags, cmdtp, flag, ac, av);
  47. }
  48. #ifdef CONFIG_SHA1SUM_VERIFY
  49. U_BOOT_CMD(
  50. sha1sum, 5, 1, do_sha1sum,
  51. "compute SHA1 message digest",
  52. "address count [[*]sum]\n"
  53. " - compute SHA1 message digest [save to sum]\n"
  54. "sha1sum -v address count [*]sum\n"
  55. " - verify sha1sum of memory area"
  56. );
  57. #else
  58. U_BOOT_CMD(
  59. sha1sum, 4, 1, do_sha1sum,
  60. "compute SHA1 message digest",
  61. "address count [[*]sum]\n"
  62. " - compute SHA1 message digest [save to sum]"
  63. );
  64. #endif