xref: /openbmc/u-boot/cmd/sha1sum.c (revision 3ba98ed8)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2011
4  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
5  *
6  * (C) Copyright 2000
7  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8  */
9 
10 #include <common.h>
11 #include <command.h>
12 #include <hash.h>
13 #include <u-boot/sha1.h>
14 
15 int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
16 {
17 	int flags = HASH_FLAG_ENV;
18 	int ac;
19 	char * const *av;
20 
21 	if (argc < 3)
22 		return CMD_RET_USAGE;
23 
24 	av = argv + 1;
25 	ac = argc - 1;
26 #ifdef CONFIG_SHA1SUM_VERIFY
27 	if (strcmp(*av, "-v") == 0) {
28 		flags |= HASH_FLAG_VERIFY;
29 		av++;
30 		ac--;
31 	}
32 #endif
33 
34 	return hash_command("sha1", flags, cmdtp, flag, ac, av);
35 }
36 
37 #ifdef CONFIG_SHA1SUM_VERIFY
38 U_BOOT_CMD(
39 	sha1sum,	5,	1,	do_sha1sum,
40 	"compute SHA1 message digest",
41 	"address count [[*]sum]\n"
42 		"    - compute SHA1 message digest [save to sum]\n"
43 	"sha1sum -v address count [*]sum\n"
44 		"    - verify sha1sum of memory area"
45 );
46 #else
47 U_BOOT_CMD(
48 	sha1sum,	4,	1,	do_sha1sum,
49 	"compute SHA1 message digest",
50 	"address count [[*]sum]\n"
51 		"    - compute SHA1 message digest [save to sum]"
52 );
53 #endif
54