]> git.ipfire.org Git - people/ms/u-boot.git/blame - common/cmd_hash.c
ARM: tegra: Add Tegra20 PCIe device tree node
[people/ms/u-boot.git] / common / cmd_hash.c
CommitLineData
bf36c5d5
SG
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 *
1a459660 10 * SPDX-License-Identifier: GPL-2.0+
bf36c5d5
SG
11 */
12
13#include <common.h>
14#include <command.h>
15#include <hash.h>
218da0f3 16#include <linux/ctype.h>
bf36c5d5
SG
17
18static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
19{
218da0f3 20 char *s;
bf36c5d5 21#ifdef CONFIG_HASH_VERIFY
d5b76673 22 int flags = HASH_FLAG_ENV;
bf36c5d5 23
6b3ff98d
SG
24 if (argc < 4)
25 return CMD_RET_USAGE;
bf36c5d5 26 if (!strcmp(argv[1], "-v")) {
d5b76673 27 flags |= HASH_FLAG_VERIFY;
bf36c5d5
SG
28 argc--;
29 argv++;
30 }
6b3ff98d 31#else
d5b76673 32 const int flags = HASH_FLAG_ENV;
bf36c5d5
SG
33#endif
34 /* Move forward to 'algorithm' parameter */
35 argc--;
36 argv++;
218da0f3
SG
37 for (s = *argv; *s; s++)
38 *s = tolower(*s);
d5b76673 39 return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
bf36c5d5
SG
40}
41
42#ifdef CONFIG_HASH_VERIFY
43U_BOOT_CMD(
44 hash, 6, 1, do_hash,
45 "compute hash message digest",
46 "algorithm address count [[*]sum_dest]\n"
47 " - compute message digest [save to env var / *address]\n"
48 "hash -v algorithm address count [*]sum\n"
49 " - verify hash of memory area with env var / *address"
50);
51#else
52U_BOOT_CMD(
53 hash, 5, 1, do_hash,
54 "compute message digest",
55 "algorithm address count [[*]sum_dest]\n"
56 " - compute message digest [save to env var / *address]"
57);
58#endif