From: ARUN MANKUZHI <aru...@samsung.com> sha256 command is added which can be used to test SHA 256 hash algorithm.
Signed-off-by: ARUN MANKUZHI <aru...@samsung.com> Signed-off-by: Simon Glass <s...@chromium.org> --- README | 1 + common/Makefile | 1 + common/cmd_sha256.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sha256.c diff --git a/README b/README index 785953f..31e25fe 100644 --- a/README +++ b/README @@ -861,6 +861,7 @@ The following options need to be configured: (requires CONFIG_CMD_I2C) CONFIG_CMD_SETGETDCR Support for DCR Register access (4xx only) + CONFIG_CMD_SHA256 * Calculate SHA256 for block CONFIG_CMD_SF * Read/write/erase SPI NOR flash CONFIG_CMD_SHA1SUM print sha1 memory digest (requires CONFIG_CMD_MEMORY) diff --git a/common/Makefile b/common/Makefile index 84968f8..6f6f0fa 100644 --- a/common/Makefile +++ b/common/Makefile @@ -150,6 +150,7 @@ COBJS-$(CONFIG_CMD_SF) += cmd_sf.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o COBJS-$(CONFIG_CMD_SHA1SUM) += cmd_sha1sum.o COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o +COBJS-$(CONFIG_CMD_SHA256) += cmd_sha256.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o diff --git a/common/cmd_sha256.c b/common/cmd_sha256.c new file mode 100644 index 0000000..006391d --- /dev/null +++ b/common/cmd_sha256.c @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, w...@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> +#include <sha256.h> + +int do_sha256(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + unsigned long inlen; + unsigned char *input, *out; + int i; + sha256_context sha_cnxt; + if (argc < 4) { + printf("usage: sha256 <input> <input length> <output>\n"); + return 0; + } + input = (unsigned char *)simple_strtoul(argv[1], NULL, 16); + inlen = simple_strtoul(argv[2], NULL, 16); + out = (unsigned char *)simple_strtoul(argv[3], NULL, 16); + + sha256_starts(&sha_cnxt); + sha256_update(&sha_cnxt, input, inlen); + sha256_finish(&sha_cnxt, out); + + for (i = 0; i < 32; i++) + printf("0x%02X ", out[i]); + printf("\n"); + + return 0; +} + +U_BOOT_CMD( + sha256, 4, 1, do_sha256, + "print hash result", + "<input> <inputlength> <output>" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 148d676..efd17e6 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -79,6 +79,7 @@ #define CONFIG_CMD_SDRAM /* SDRAM DIMM SPD info printout */ #define CONFIG_CMD_SETEXPR /* setexpr support */ #define CONFIG_CMD_SETGETDCR /* DCR support on 4xx */ +#define CONFIG_CMD_SHA256 /* Calculate SHA256 for block */ #define CONFIG_CMD_SNTP /* SNTP support */ #define CONFIG_CMD_SOURCE /* "source" command support */ #define CONFIG_CMD_SPI /* SPI utility */ -- 1.7.7.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot