]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
bf36c5d5 SG |
2 | /* |
3 | * Copyright (c) 2012 The Chromium OS Authors. | |
4 | * | |
5 | * (C) Copyright 2011 | |
6 | * Joe Hershberger, National Instruments, joe.hershberger@ni.com | |
7 | * | |
8 | * (C) Copyright 2000 | |
9 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
bf36c5d5 SG |
10 | */ |
11 | ||
12 | #include <common.h> | |
13 | #include <command.h> | |
14 | #include <hash.h> | |
218da0f3 | 15 | #include <linux/ctype.h> |
bf36c5d5 | 16 | |
348ea878 IO |
17 | #if IS_ENABLED(CONFIG_HASH_VERIFY) |
18 | #define HARGS 6 | |
19 | #else | |
20 | #define HARGS 5 | |
21 | #endif | |
22 | ||
09140113 SG |
23 | static int do_hash(struct cmd_tbl *cmdtp, int flag, int argc, |
24 | char *const argv[]) | |
bf36c5d5 | 25 | { |
218da0f3 | 26 | char *s; |
d5b76673 | 27 | int flags = HASH_FLAG_ENV; |
bf36c5d5 | 28 | |
348ea878 | 29 | if (argc < (HARGS - 1)) |
6b3ff98d | 30 | return CMD_RET_USAGE; |
348ea878 IO |
31 | |
32 | #if IS_ENABLED(CONFIG_HASH_VERIFY) | |
bf36c5d5 | 33 | if (!strcmp(argv[1], "-v")) { |
d5b76673 | 34 | flags |= HASH_FLAG_VERIFY; |
bf36c5d5 SG |
35 | argc--; |
36 | argv++; | |
37 | } | |
38 | #endif | |
39 | /* Move forward to 'algorithm' parameter */ | |
40 | argc--; | |
41 | argv++; | |
218da0f3 SG |
42 | for (s = *argv; *s; s++) |
43 | *s = tolower(*s); | |
d5b76673 | 44 | return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1); |
bf36c5d5 SG |
45 | } |
46 | ||
bf36c5d5 | 47 | U_BOOT_CMD( |
3ef46a99 ND |
48 | hash, HARGS, 1, do_hash, |
49 | "compute hash message digest", | |
50 | "algorithm address count [[*]hash_dest]\n" | |
bf36c5d5 | 51 | " - compute message digest [save to env var / *address]" |
348ea878 | 52 | #if IS_ENABLED(CONFIG_HASH_VERIFY) |
3ef46a99 ND |
53 | "\nhash -v algorithm address count [*]hash\n" |
54 | " - verify message digest of memory area to immediate value, \n" | |
55 | " env var or *address" | |
bf36c5d5 | 56 | #endif |
3ef46a99 | 57 | ); |