Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 2 | /* |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 3 | * (C) Copyright 2011 |
| 4 | * Joe Hershberger, National Instruments, joe.hershberger@ni.com |
| 5 | * |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 6 | * (C) Copyright 2000 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 8 | */ |
| 9 | |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 10 | #include <command.h> |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 11 | #include <hash.h> |
Jeroen Hofstee | bfe88fe | 2014-06-12 22:27:12 +0200 | [diff] [blame] | 12 | #include <u-boot/sha1.h> |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 13 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 14 | int do_sha1sum(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 15 | { |
Simon Glass | 80e345a | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 16 | int flags = HASH_FLAG_ENV; |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 17 | int ac; |
| 18 | char * const *av; |
| 19 | |
| 20 | if (argc < 3) |
| 21 | return CMD_RET_USAGE; |
| 22 | |
| 23 | av = argv + 1; |
| 24 | ac = argc - 1; |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 25 | #ifdef CONFIG_SHA1SUM_VERIFY |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 26 | if (strcmp(*av, "-v") == 0) { |
Simon Glass | 80e345a | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 27 | flags |= HASH_FLAG_VERIFY; |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 28 | av++; |
| 29 | ac--; |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 30 | } |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 31 | #endif |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 32 | |
Simon Glass | 80e345a | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 33 | return hash_command("sha1", flags, cmdtp, flag, ac, av); |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 34 | } |
| 35 | |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 36 | #ifdef CONFIG_SHA1SUM_VERIFY |
| 37 | U_BOOT_CMD( |
| 38 | sha1sum, 5, 1, do_sha1sum, |
| 39 | "compute SHA1 message digest", |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 40 | "address count [[*]sum]\n" |
| 41 | " - compute SHA1 message digest [save to sum]\n" |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 42 | "sha1sum -v address count [*]sum\n" |
| 43 | " - verify sha1sum of memory area" |
| 44 | ); |
| 45 | #else |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 46 | U_BOOT_CMD( |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 47 | sha1sum, 4, 1, do_sha1sum, |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 48 | "compute SHA1 message digest", |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 49 | "address count [[*]sum]\n" |
| 50 | " - compute SHA1 message digest [save to sum]" |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 51 | ); |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 52 | #endif |