]> Git Repo - J-u-boot.git/blob - cmd/hash.c
Merge tag 'u-boot-stm32-20241017' of https://source.denx.de/u-boot/custodians/u-boot-stm
[J-u-boot.git] / cmd / hash.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2012 The Chromium OS Authors.
4  *
5  * (C) Copyright 2011
6  * Joe Hershberger, National Instruments, [email protected]
7  *
8  * (C) Copyright 2000
9  * Wolfgang Denk, DENX Software Engineering, [email protected].
10  */
11
12 #include <command.h>
13 #include <hash.h>
14 #include <linux/ctype.h>
15
16 #if IS_ENABLED(CONFIG_HASH_VERIFY)
17 #define HARGS 6
18 #else
19 #define HARGS 5
20 #endif
21
22 static int do_hash(struct cmd_tbl *cmdtp, int flag, int argc,
23                    char *const argv[])
24 {
25         char *s;
26         int flags = HASH_FLAG_ENV;
27
28         if (argc < (HARGS - 1))
29                 return CMD_RET_USAGE;
30
31 #if IS_ENABLED(CONFIG_HASH_VERIFY)
32         if (!strcmp(argv[1], "-v")) {
33                 flags |= HASH_FLAG_VERIFY;
34                 argc--;
35                 argv++;
36         }
37 #endif
38         /* Move forward to 'algorithm' parameter */
39         argc--;
40         argv++;
41         for (s = *argv; *s; s++)
42                 *s = tolower(*s);
43         return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
44 }
45
46 U_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 #if IS_ENABLED(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 );
This page took 0.027837 seconds and 4 git commands to generate.