Merge tag 'xilinx-for-v2025.01-rc3-v2' of https://source.denx.de/u-boot/custodians...
[u-boot.git] / cmd / md5sum.c
blobded3f9e1831413c0dbc33e77826841052b30953e
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 <env.h>
12 #include <image.h>
13 #include <hash.h>
14 #include <mapmem.h>
15 #include <u-boot/md5.h>
16 #include <asm/io.h>
18 static int do_md5sum(struct cmd_tbl *cmdtp, int flag, int argc,
19 char *const argv[])
21 int flags = HASH_FLAG_ENV;
22 int ac;
23 char *const *av;
25 if (argc < 3)
26 return CMD_RET_USAGE;
28 av = argv + 1;
29 ac = argc - 1;
30 if (IS_ENABLED(CONFIG_MD5SUM_VERIFY) && strcmp(*av, "-v") == 0) {
31 flags |= HASH_FLAG_VERIFY;
32 av++;
33 ac--;
36 return hash_command("md5", flags, cmdtp, flag, ac, av);
39 #if IS_ENABLED(CONFIG_MD5SUM_VERIFY)
40 U_BOOT_CMD(
41 md5sum, 5, 1, do_md5sum,
42 "compute MD5 message digest",
43 "address count [[*]sum]\n"
44 " - compute MD5 message digest [save to sum]\n"
45 "md5sum -v address count [*]sum\n"
46 " - verify md5sum of memory area"
48 #else
49 U_BOOT_CMD(
50 md5sum, 4, 1, do_md5sum,
51 "compute MD5 message digest",
52 "address count [[*]sum]\n"
53 " - compute MD5 message digest [save to sum]"
55 #endif /* IS_ENABLED(CONFIG_MD5SUM_VERIFY) */