blob: 783ea2e32db3725909d13e76b843aeb7e5f92bc3 [file] [log] [blame]
Mike Frysingerc3d2a172011-04-02 21:40:19 -04001/*
Joe Hershbergere6e77d32012-08-17 11:00:45 +00002 * (C) Copyright 2011
3 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4 *
Mike Frysingerc3d2a172011-04-02 21:40:19 -04005 * (C) Copyright 2000
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Mike Frysingerc3d2a172011-04-02 21:40:19 -04009 */
10
11#include <common.h>
12#include <command.h>
Simon Glasse50b12c2012-12-05 14:46:37 +000013#include <hash.h>
Jeroen Hofstee2b9912e2014-06-12 22:27:12 +020014#include <u-boot/sha1.h>
Mike Frysingerc3d2a172011-04-02 21:40:19 -040015
Joe Hershbergere6e77d32012-08-17 11:00:45 +000016int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
17{
Simon Glassd5b76672013-02-24 17:33:26 +000018 int flags = HASH_FLAG_ENV;
Joe Hershbergere6e77d32012-08-17 11:00:45 +000019 int ac;
20 char * const *av;
21
22 if (argc < 3)
23 return CMD_RET_USAGE;
24
25 av = argv + 1;
26 ac = argc - 1;
Simon Glasse50b12c2012-12-05 14:46:37 +000027#ifdef CONFIG_SHA1SUM_VERIFY
Joe Hershbergere6e77d32012-08-17 11:00:45 +000028 if (strcmp(*av, "-v") == 0) {
Simon Glassd5b76672013-02-24 17:33:26 +000029 flags |= HASH_FLAG_VERIFY;
Joe Hershbergere6e77d32012-08-17 11:00:45 +000030 av++;
31 ac--;
Joe Hershbergere6e77d32012-08-17 11:00:45 +000032 }
Joe Hershbergere6e77d32012-08-17 11:00:45 +000033#endif
Mike Frysingerc3d2a172011-04-02 21:40:19 -040034
Simon Glassd5b76672013-02-24 17:33:26 +000035 return hash_command("sha1", flags, cmdtp, flag, ac, av);
Simon Glasse50b12c2012-12-05 14:46:37 +000036}
37
Joe Hershbergere6e77d32012-08-17 11:00:45 +000038#ifdef CONFIG_SHA1SUM_VERIFY
39U_BOOT_CMD(
40 sha1sum, 5, 1, do_sha1sum,
41 "compute SHA1 message digest",
Joe Hershberger3c210e22012-08-17 11:00:46 +000042 "address count [[*]sum]\n"
43 " - compute SHA1 message digest [save to sum]\n"
Joe Hershbergere6e77d32012-08-17 11:00:45 +000044 "sha1sum -v address count [*]sum\n"
45 " - verify sha1sum of memory area"
46);
47#else
Mike Frysingerc3d2a172011-04-02 21:40:19 -040048U_BOOT_CMD(
Joe Hershberger3c210e22012-08-17 11:00:46 +000049 sha1sum, 4, 1, do_sha1sum,
Mike Frysingerc3d2a172011-04-02 21:40:19 -040050 "compute SHA1 message digest",
Joe Hershberger3c210e22012-08-17 11:00:46 +000051 "address count [[*]sum]\n"
52 " - compute SHA1 message digest [save to sum]"
Mike Frysingerc3d2a172011-04-02 21:40:19 -040053);
Joe Hershbergere6e77d32012-08-17 11:00:45 +000054#endif