Blame view

common/cmd_sha1sum.c 1.82 KB
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
1
  /*
e6e77d354   Joe Hershberger   Implement verify ...
2
3
4
   * (C) Copyright 2011
   * Joe Hershberger, National Instruments, joe.hershberger@ni.com
   *
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
   * (C) Copyright 2000
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
   * See file CREDITS for list of people who contributed to this
   * project.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
   * published by the Free Software Foundation; either version 2 of
   * the License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   * MA 02111-1307 USA
   */
  
  #include <common.h>
  #include <command.h>
e50b12c95   Simon Glass   sha1sum: Use gene...
29
  #include <hash.h>
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
30
  #include <sha1.h>
e6e77d354   Joe Hershberger   Implement verify ...
31
32
  int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  {
d5b76673a   Simon Glass   hash: Add a flag ...
33
  	int flags = HASH_FLAG_ENV;
e6e77d354   Joe Hershberger   Implement verify ...
34
35
36
37
38
39
40
41
  	int ac;
  	char * const *av;
  
  	if (argc < 3)
  		return CMD_RET_USAGE;
  
  	av = argv + 1;
  	ac = argc - 1;
e50b12c95   Simon Glass   sha1sum: Use gene...
42
  #ifdef CONFIG_SHA1SUM_VERIFY
e6e77d354   Joe Hershberger   Implement verify ...
43
  	if (strcmp(*av, "-v") == 0) {
d5b76673a   Simon Glass   hash: Add a flag ...
44
  		flags |= HASH_FLAG_VERIFY;
e6e77d354   Joe Hershberger   Implement verify ...
45
46
  		av++;
  		ac--;
e6e77d354   Joe Hershberger   Implement verify ...
47
  	}
e50b12c95   Simon Glass   sha1sum: Use gene...
48
  #endif
e6e77d354   Joe Hershberger   Implement verify ...
49

d5b76673a   Simon Glass   hash: Add a flag ...
50
  	return hash_command("sha1", flags, cmdtp, flag, ac, av);
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
51
  }
e6e77d354   Joe Hershberger   Implement verify ...
52
53
54
55
  #ifdef CONFIG_SHA1SUM_VERIFY
  U_BOOT_CMD(
  	sha1sum,	5,	1,	do_sha1sum,
  	"compute SHA1 message digest",
3c210e29c   Joe Hershberger   Add parameter to ...
56
57
58
59
  	"address count [[*]sum]
  "
  		"    - compute SHA1 message digest [save to sum]
  "
e6e77d354   Joe Hershberger   Implement verify ...
60
61
62
63
64
  	"sha1sum -v address count [*]sum
  "
  		"    - verify sha1sum of memory area"
  );
  #else
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
65
  U_BOOT_CMD(
3c210e29c   Joe Hershberger   Add parameter to ...
66
  	sha1sum,	4,	1,	do_sha1sum,
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
67
  	"compute SHA1 message digest",
3c210e29c   Joe Hershberger   Add parameter to ...
68
69
70
  	"address count [[*]sum]
  "
  		"    - compute SHA1 message digest [save to sum]"
c3d2a17c1   Mike Frysinger   md5sum/sha1sum/un...
71
  );
e6e77d354   Joe Hershberger   Implement verify ...
72
  #endif