Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 1 | /* |
Joe Hershberger | d448312 | 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 | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 5 | * (C) Copyright 2000 |
| 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include <command.h> |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 29 | #include <hash.h> |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 30 | #include <sha1.h> |
| 31 | |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 32 | int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 33 | { |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 34 | int verify = 0; |
| 35 | int ac; |
| 36 | char * const *av; |
| 37 | |
| 38 | if (argc < 3) |
| 39 | return CMD_RET_USAGE; |
| 40 | |
| 41 | av = argv + 1; |
| 42 | ac = argc - 1; |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 43 | #ifdef CONFIG_SHA1SUM_VERIFY |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 44 | if (strcmp(*av, "-v") == 0) { |
| 45 | verify = 1; |
| 46 | av++; |
| 47 | ac--; |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 48 | } |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 49 | #endif |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 50 | |
Simon Glass | ff436e0 | 2012-12-05 14:46:37 +0000 | [diff] [blame] | 51 | return hash_command("sha1", verify, cmdtp, flag, ac, av); |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 54 | #ifdef CONFIG_SHA1SUM_VERIFY |
| 55 | U_BOOT_CMD( |
| 56 | sha1sum, 5, 1, do_sha1sum, |
| 57 | "compute SHA1 message digest", |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 58 | "address count [[*]sum]\n" |
| 59 | " - compute SHA1 message digest [save to sum]\n" |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 60 | "sha1sum -v address count [*]sum\n" |
| 61 | " - verify sha1sum of memory area" |
| 62 | ); |
| 63 | #else |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 64 | U_BOOT_CMD( |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 65 | sha1sum, 4, 1, do_sha1sum, |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 66 | "compute SHA1 message digest", |
Joe Hershberger | 95e1108 | 2012-08-17 11:00:46 +0000 | [diff] [blame] | 67 | "address count [[*]sum]\n" |
| 68 | " - compute SHA1 message digest [save to sum]" |
Mike Frysinger | a227490 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 69 | ); |
Joe Hershberger | d448312 | 2012-08-17 11:00:45 +0000 | [diff] [blame] | 70 | #endif |