Merge tag 'xilinx-for-v2025.01-rc3-v2' of https://source.denx.de/u-boot/custodians...
[u-boot.git] / cmd / sha1sum.c
blob52aa26c78d2f9b8b81d5390adc771700b1569e6d
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2011
4 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
6 * (C) Copyright 2000
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 */
10 #include <command.h>
11 #include <hash.h>
12 #include <u-boot/sha1.h>
14 int do_sha1sum(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
16 int flags = HASH_FLAG_ENV;
17 int ac;
18 char * const *av;
20 if (argc < 3)
21 return CMD_RET_USAGE;
23 av = argv + 1;
24 ac = argc - 1;
25 #ifdef CONFIG_SHA1SUM_VERIFY
26 if (strcmp(*av, "-v") == 0) {
27 flags |= HASH_FLAG_VERIFY;
28 av++;
29 ac--;
31 #endif
33 return hash_command("sha1", flags, cmdtp, flag, ac, av);
36 #ifdef CONFIG_SHA1SUM_VERIFY
37 U_BOOT_CMD(
38 sha1sum, 5, 1, do_sha1sum,
39 "compute SHA1 message digest",
40 "address count [[*]sum]\n"
41 " - compute SHA1 message digest [save to sum]\n"
42 "sha1sum -v address count [*]sum\n"
43 " - verify sha1sum of memory area"
45 #else
46 U_BOOT_CMD(
47 sha1sum, 4, 1, do_sha1sum,
48 "compute SHA1 message digest",
49 "address count [[*]sum]\n"
50 " - compute SHA1 message digest [save to sum]"
52 #endif