]> git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_hash.c
Merge branch 'master' of git://git.denx.de/u-boot-mips
[people/ms/u-boot.git] / common / cmd_hash.c
1 /*
2 * Copyright (c) 2012 The Chromium OS Authors.
3 *
4 * (C) Copyright 2011
5 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
6 *
7 * (C) Copyright 2000
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26 #include <common.h>
27 #include <command.h>
28 #include <hash.h>
29
30 static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
31 {
32 #ifdef CONFIG_HASH_VERIFY
33 int verify = 0;
34
35 if (!strcmp(argv[1], "-v")) {
36 verify = 1;
37 argc--;
38 argv++;
39 }
40 #endif
41 /* Move forward to 'algorithm' parameter */
42 argc--;
43 argv++;
44 return hash_command(*argv, verify, cmdtp, flag, argc - 1, argv + 1);
45 }
46
47 #ifdef CONFIG_HASH_VERIFY
48 U_BOOT_CMD(
49 hash, 6, 1, do_hash,
50 "compute hash message digest",
51 "algorithm address count [[*]sum_dest]\n"
52 " - compute message digest [save to env var / *address]\n"
53 "hash -v algorithm address count [*]sum\n"
54 " - verify hash of memory area with env var / *address"
55 );
56 #else
57 U_BOOT_CMD(
58 hash, 5, 1, do_hash,
59 "compute message digest",
60 "algorithm address count [[*]sum_dest]\n"
61 " - compute message digest [save to env var / *address]"
62 );
63 #endif