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