Skip to contentSkip to conversation

Kconfig: Add support for hash and sha1sum commands

PATCH New Daniel Thompson 3 participants 7 messages May 19, 2017 – May 31, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

---
 cmd/Kconfig | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
cmd/Kconfig +27 -0
index d9f7151bacdc..f459f8440346 100644
@@ -338,6 +338,19 @@ config CMD_CRC32
 	help
 	  Compute CRC32.
 
+config CMD_HASH
+	bool "hash"
+	default n
+	help
+	  Compute a hash using any algorithm supported by hash_lookup_algo().
+
+config HASH_VERIFY
+	bool "hash -v"
+	default n
+	depends on CMD_HASH
+	help
+	  Add -v option to verify data against a hash.
+
 config CMD_MD5SUM
 	bool "md5sum"
 	default n
@@ -352,6 +365,20 @@ config MD5SUM_VERFIY
 	help
 	  Add -v option to verify data against an MD5 checksum.
 
+config CMD_SHA1SUM
+	bool "sha1sum"
+	default n
+	select SHA1
+	help
+	  Compute SHA1 checksum.
+
+config SHA1SUM_VERFIY
+	bool "sha1sum -v"
+	default n
+	depends on CMD_SHA1SUM
+	help
+	  Add -v option to verify data against an SHA1 checksum.
+
 config LOOPW
 	bool "loopw"
 	help

--
2.9.4

#1 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Hi Daniel,

Quoted 7 lines · Daniel Thompson

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

---
 cmd/Kconfig | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Great to see this. However CMD_HASH is already in progress at u-boot-dm/kconfig-working. I hope it will make it to mainline soon. But in the meantime could you please rebase on that and send v2?

Regards,
Simon

#2 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Quoted 6 lines · Simon Glass

Hi Daniel,

Quoted 3 lines · Daniel Thompson

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

Quoted 8 lines
Quoted 4 lines
---
 cmd/Kconfig | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Great to see this. However CMD_HASH is already in progress at u-boot-dm/kconfig-working. I hope it will make it to mainline soon. But in the meantime could you please rebase on that and send v2?

Since this needs moveconfig.py run as well, I'll just v2 it, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170522/98e233ea/attachment.sig>
#3 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Quoted 12 lines · Tom Rini
Quoted 11 lines · Simon Glass

Hi Daniel,

Quoted 7 lines · Daniel Thompson

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

---
  cmd/Kconfig | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
Quoted 5 lines
Quoted 3 lines

Great to see this. However CMD_HASH is already in progress at u-boot-dm/kconfig-working. I hope it will make it to mainline soon. But in the meantime could you please rebase on that and send v2?

Since this needs moveconfig.py run as well, I'll just v2 it, thanks!

Does that translate into "Daniel, don't worry about the rebase there are other things that I'd need to change as well and its quicker and easier for me just to do them".

I totally happy with that translation but just want to check it's correct.

Daniel.

#4 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Quoted 17 lines · Daniel Thompson
Quoted 16 lines · Tom Rini
Quoted 14 lines · Simon Glass

Hi Daniel,

Quoted 7 lines · Daniel Thompson

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

---
 cmd/Kconfig | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Great to see this. However CMD_HASH is already in progress at u-boot-dm/kconfig-working. I hope it will make it to mainline soon. But in the meantime could you please rebase on that and send v2?

Quoted 7 lines
Quoted 1 line

Since this needs moveconfig.py run as well, I'll just v2 it, thanks!

Does that translate into "Daniel, don't worry about the rebase there are other things that I'd need to change as well and its quicker and easier for me just to do them".

I totally happy with that translation but just want to check it's correct.

Correct, I'll pick it up and rebase it and so forth.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170523/cca3984e/attachment.sig>
#5 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

In reply to Daniel Thompson

From: Daniel Thompson <[email protected]>

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

[trini: Re-apply, add imply for a few cases, run moveconfig.py]
---
 README                              | 11 -----------
 arch/Kconfig                        |  1 +
 arch/arm/Kconfig                    |  1 +
 arch/arm/mach-exynos/Kconfig        |  1 +
 cmd/Kconfig                         | 18 ++++++++++++++++++
 configs/bcm958622hr_defconfig       |  1 +
 include/configs/bcm_ep_board.h      |  3 ---
 include/configs/exynos5-common.h    |  3 ---
 include/configs/imx6qdl_icore.h     |  1 -
 include/configs/imx6qdl_icore_rqs.h |  1 -
 include/configs/imx6ul_geam.h       |  1 -
 include/configs/imx6ul_isiot.h      |  1 -
 include/configs/sandbox.h           |  2 --
 include/hash.h                      |  4 ----
 scripts/config_whitelist.txt        |  1 -
 15 files changed, 22 insertions(+), 28 deletions(-)
README +0 -11
index 9d351ec5ad..f9931f6a6f 100644
@@ -889,8 +889,6 @@ The following options need to be configured:
 		CONFIG_CMD_SETGETDCR	  Support for DCR Register access
 					  (4xx only)
 		CONFIG_CMD_SF		* Read/write/erase SPI NOR flash
-		CONFIG_CMD_SHA1SUM	* print sha1 memory digest
-					  (requires CONFIG_CMD_MEMORY)
 		CONFIG_CMD_SOFTSWITCH	* Soft switch setting command for BF60x
 		CONFIG_CMD_SOURCE	  "source" command Support
 		CONFIG_CMD_SPI		* SPI serial bus support
@@ -2679,15 +2677,6 @@ The following options need to be configured:
 		A better solution is to properly configure the firewall,
 		but sometimes that is not allowed.
 
-- Hashing support:
-		CONFIG_HASH_VERIFY
-
-		Enable the hash verify command (hash -v). This adds to code
-		size a little.
-
-		Note: There is also a sha1sum command, which should perhaps
-		be deprecated in favour of 'hash sha1'.
-
 - bootcount support:
 		CONFIG_BOOTCOUNT_LIMIT
 
arch/Kconfig +1 -0
index 02e887ac86..6e291e7316 100644
@@ -76,6 +76,7 @@ config SANDBOX
 	imply CMD_IOTRACE
 	imply LZMA
 	imply CMD_LZMADEC
+	imply HASH_VERIFY
 
 config SH
 	bool "SuperH architecture"
arch/arm/Kconfig +1 -0
index 91f50b0637..0df99904a2 100644
@@ -504,6 +504,7 @@ config TARGET_BCMCYGNUS
 	bool "Support bcmcygnus"
 	select CPU_V7
 	imply CMD_HASH
+	imply HASH_VERIFY
 
 config TARGET_BCMNSP
 	bool "Support bcmnsp"
arch/arm/mach-exynos/Kconfig +1 -0
index 5b6c5ea328..9c5387e37a 100644
@@ -19,6 +19,7 @@ config ARCH_EXYNOS5
 	select BOARD_EARLY_INIT_F
 	select SHA_HW_ACCEL
 	imply CMD_HASH
+	imply HASH_VERIFY
 	help
 	  Samsung Exynos5 SoC family are based on ARM Cortex-A15 CPU (and
 	  Cortex-A7 CPU in big.LITTLE configuration). There are multiple SoCs
cmd/Kconfig +18 -0
index 5ee52f62cc..d3580ec779 100644
@@ -417,6 +417,18 @@ config MD5SUM_VERFIY
 	help
 	  Add -v option to verify data against an MD5 checksum.
 
+config CMD_SHA1SUM
+	bool "sha1sum"
+	select SHA1
+	help
+	  Compute SHA1 checksum.
+
+config SHA1SUM_VERFIY
+	bool "sha1sum -v"
+	depends on CMD_SHA1SUM
+	help
+	  Add -v option to verify data against an SHA1 checksum.
+
 config LOOPW
 	bool "loopw"
 	help
@@ -1068,6 +1080,12 @@ config CMD_HASH
 	  saved to memory or to an environment variable. It is also possible
 	  to verify a hash against data in memory.
 
+config HASH_VERIFY
+	bool "hash -v"
+	depends on CMD_HASH
+	help
+	  Add -v option to verify data against a hash.
+
 config CMD_TPM
 	bool "Enable the 'tpm' command"
 	depends on TPM
configs/bcm958622hr_defconfig +1 -0
index c2713c61fa..69b9fe878b 100644
@@ -14,6 +14,7 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_HASH=y
+CONFIG_HASH_VERIFY=y
 CONFIG_CMD_FAT=y
 # CONFIG_MMC is not set
 CONFIG_SYS_NS16550=y
include/configs/bcm_ep_board.h +0 -3
index 957cd9e0ba..53220491b8 100644
@@ -66,9 +66,6 @@
 /* Commands */
 #define CONFIG_FAT_WRITE
 
-/* SHA hashing */
-#define CONFIG_HASH_VERIFY
-
 /* Enable Time Command */
 
 /* Misc utility code */
include/configs/exynos5-common.h +0 -3
index 6915dc1a48..378219d83a 100644
@@ -131,9 +131,6 @@
 #define CONFIG_ENV_SROM_BANK		1
 #endif /*CONFIG_CMD_NET*/
 
-/* SHA hashing */
-#define CONFIG_HASH_VERIFY
-
 /* Enable Time Command */
 
 /* USB */
include/configs/imx6qdl_icore.h +0 -1
index 741bdfa807..13fc48fa3a 100644
@@ -125,7 +125,6 @@
 
 /* FIT */
 #ifdef CONFIG_FIT
-# define CONFIG_HASH_VERIFY
 # define CONFIG_IMAGE_FORMAT_LEGACY
 #endif
 
include/configs/imx6qdl_icore_rqs.h +0 -1
index f52865b5a0..a588823da0 100644
@@ -107,7 +107,6 @@
 
 /* FIT */
 #ifdef CONFIG_FIT
-# define CONFIG_HASH_VERIFY
 # define CONFIG_IMAGE_FORMAT_LEGACY
 #endif
 
include/configs/imx6ul_geam.h +0 -1
index 2e12b97767..1d48726086 100644
@@ -124,7 +124,6 @@
 
 /* FIT */
 #ifdef CONFIG_FIT
-# define CONFIG_HASH_VERIFY
 # define CONFIG_IMAGE_FORMAT_LEGACY
 #endif
 
include/configs/imx6ul_isiot.h +0 -1
index 76ae159da3..a0eb6e25fe 100644
@@ -124,7 +124,6 @@
 
 /* FIT */
 #ifdef CONFIG_FIT
-# define CONFIG_HASH_VERIFY
 # define CONFIG_IMAGE_FORMAT_LEGACY
 #endif
 
include/configs/sandbox.h +0 -2
index c62b45e51c..fbbd6cd99b 100644
@@ -98,8 +98,6 @@
 #define CONFIG_BOOTP_SERVERIP
 #define CONFIG_IP_DEFRAG
 
-#define CONFIG_HASH_VERIFY
-
 #define CONFIG_CMD_SANDBOX
 
 #define CONFIG_BOOTARGS ""
include/hash.h +0 -4
index d81433772f..4f9a8cf1db 100644
@@ -17,10 +17,6 @@ enum {
 	HASH_FLAG_ENV		= 1 << 1,	/* Allow env vars */
 };
 
-#if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY)
-#define CONFIG_HASH_VERIFY
-#endif
-
 struct hash_algo {
 	const char *name;			/* Name of algorithm */
 	int digest_size;			/* Length of digest */
scripts/config_whitelist.txt +0 -1
index e8f49ebe5d..a20f1c593c 100644
@@ -1074,7 +1074,6 @@ CONFIG_H264_FREQ
 CONFIG_H8300
 CONFIG_HALEAKALA
 CONFIG_HARD_SPI
-CONFIG_HASH_VERIFY
 CONFIG_HAS_DATAFLASH
 CONFIG_HAS_ETH0
 CONFIG_HAS_ETH1
Signature · 1 line
2.11.0
#6 lore raw

PATCH 1/1 Kconfig: Add support for hash and sha1sum commands

Quoted 17 lines · Tom Rini

From: Daniel Thompson <[email protected]>

Currently these (board agnostic) commands cannot be selected using menuconfig and friends. Fix this the obvious way.

[trini: Re-apply, add imply for a few cases, run moveconfig.py]
---
 README                              | 11 -----------
 arch/Kconfig                        |  1 +
 arch/arm/Kconfig                    |  1 +
 arch/arm/mach-exynos/Kconfig        |  1 +
 cmd/Kconfig                         | 18 ++++++++++++++++++
 configs/bcm958622hr_defconfig       |  1 +
 include/configs/bcm_ep_board.h      |  3 ---
 include/configs/exynos5-common.h    |  3 ---
Quoted 8 lines
 include/configs/imx6qdl_icore.h     |  1 -
 include/configs/imx6qdl_icore_rqs.h |  1 -
 include/configs/imx6ul_geam.h       |  1 -
 include/configs/imx6ul_isiot.h      |  1 -
 include/configs/sandbox.h           |  2 --
 include/hash.h                      |  4 ----
 scripts/config_whitelist.txt        |  1 -
 15 files changed, 22 insertions(+), 28 deletions(-)