blob: 644b9a0e668e661b4add6f3eab5c90705edc5f48 [file] [log] [blame]
Mike Frysingera2274902011-04-02 21:40:19 -04001/*
Joe Hershbergerd4483122012-08-17 11:00:45 +00002 * (C) Copyright 2011
3 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4 *
Mike Frysingera2274902011-04-02 21:40:19 -04005 * (C) Copyright 2000
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Mike Frysingera2274902011-04-02 21:40:19 -04009 */
10
11#include <common.h>
12#include <command.h>
Simon Glassff436e02012-12-05 14:46:37 +000013#include <hash.h>
Mike Frysingera2274902011-04-02 21:40:19 -040014#include <sha1.h>
15
Joe Hershbergerd4483122012-08-17 11:00:45 +000016int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
17{
Simon Glass80e345a2013-02-24 17:33:26 +000018 int flags = HASH_FLAG_ENV;
Joe Hershbergerd4483122012-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 Glassff436e02012-12-05 14:46:37 +000027#ifdef CONFIG_SHA1SUM_VERIFY
Joe Hershbergerd4483122012-08-17 11:00:45 +000028 if (strcmp(*av, "-v") == 0) {
Simon Glass80e345a2013-02-24 17:33:26 +000029 flags |= HASH_FLAG_VERIFY;
Joe Hershbergerd4483122012-08-17 11:00:45 +000030 av++;
31 ac--;
Joe Hershbergerd4483122012-08-17 11:00:45 +000032 }
Simon Glassff436e02012-12-05 14:46:37 +000033#endif
Joe Hershberger95e11082012-08-17 11:00:46 +000034
Simon Glass80e345a2013-02-24 17:33:26 +000035 return hash_command("sha1", flags, cmdtp, flag, ac, av);
Mike Frysingera2274902011-04-02 21:40:19 -040036}
37
Joe Hershbergerd4483122012-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 Hershberger95e11082012-08-17 11:00:46 +000042 "address count [[*]sum]\n"
43 " - compute SHA1 message digest [save to sum]\n"
Joe Hershbergerd4483122012-08-17 11:00:45 +000044 "sha1sum -v address count [*]sum\n"
45 " - verify sha1sum of memory area"
46);
47#else
Mike Frysingera2274902011-04-02 21:40:19 -040048U_BOOT_CMD(
Joe Hershberger95e11082012-08-17 11:00:46 +000049 sha1sum, 4, 1, do_sha1sum,
Mike Frysingera2274902011-04-02 21:40:19 -040050 "compute SHA1 message digest",
Joe Hershberger95e11082012-08-17 11:00:46 +000051 "address count [[*]sum]\n"
52 " - compute SHA1 message digest [save to sum]"
Mike Frysingera2274902011-04-02 21:40:19 -040053);
Joe Hershbergerd4483122012-08-17 11:00:45 +000054#endif