1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13#include <command.h>
14#include <hash.h>
15#include <linux/ctype.h>
16
17static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
18{
19 char *s;
20 int flags = HASH_FLAG_ENV;
21
22#ifdef CONFIG_HASH_VERIFY
23 if (argc < 4)
24 return CMD_RET_USAGE;
25 if (!strcmp(argv[1], "-v")) {
26 flags |= HASH_FLAG_VERIFY;
27 argc--;
28 argv++;
29 }
30#endif
31
32 argc--;
33 argv++;
34 for (s = *argv; *s; s++)
35 *s = tolower(*s);
36 return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
37}
38
39#ifdef CONFIG_HASH_VERIFY
40#define HARGS 6
41#else
42#define HARGS 5
43#endif
44
45U_BOOT_CMD(
46 hash, HARGS, 1, do_hash,
47 "compute hash message digest",
48 "algorithm address count [[*]hash_dest]\n"
49 " - compute message digest [save to env var / *address]"
50#ifdef CONFIG_HASH_VERIFY
51 "\nhash -v algorithm address count [*]hash\n"
52 " - verify message digest of memory area to immediate value, \n"
53 " env var or *address"
54#endif
55);
56