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