Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 2 | /* |
Joe Hershberger | e6e77d3 | 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 | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 6 | * (C) Copyright 2000 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 8 | */ |
| 9 | |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 10 | #include <command.h> |
Simon Glass | e50b12c | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 11 | #include <hash.h> |
Jeroen Hofstee | 2b9912e | 2014-06-12 22:27:12 +0200 | [diff] [blame] | 12 | #include <u-boot/sha1.h> |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 13 | |
Simon Glass | 0914011 | 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 | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 15 | { |
Simon Glass | d5b7667 | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 16 | int flags = HASH_FLAG_ENV; |
Joe Hershberger | e6e77d3 | 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 | e50b12c | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 25 | #ifdef CONFIG_SHA1SUM_VERIFY |
Joe Hershberger | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 26 | if (strcmp(*av, "-v") == 0) { |
Simon Glass | d5b7667 | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 27 | flags |= HASH_FLAG_VERIFY; |
Joe Hershberger | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 28 | av++; |
| 29 | ac--; |
Joe Hershberger | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 30 | } |
Joe Hershberger | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 31 | #endif |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 32 | |
Simon Glass | d5b7667 | 2013-02-24 17:33:26 +0000 | [diff] [blame] | 33 | return hash_command("sha1", flags, cmdtp, flag, ac, av); |
Simon Glass | e50b12c | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Joe Hershberger | e6e77d3 | 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 | 3c210e2 | 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 | e6e77d3 | 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 | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 46 | U_BOOT_CMD( |
Joe Hershberger | 3c210e2 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 47 | sha1sum, 4, 1, do_sha1sum, |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 48 | "compute SHA1 message digest", |
Joe Hershberger | 3c210e2 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 49 | "address count [[*]sum]\n" |
| 50 | " - compute SHA1 message digest [save to sum]" |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 51 | ); |
Joe Hershberger | e6e77d3 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 52 | #endif |