diff mbox

[U-Boot,v3,30/48] Kconfig: Add CONFIG_HASH to enable hashing API

Message ID 20170517092544.19357-31-sjg@chromium.org
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass May 17, 2017, 9:25 a.m. UTC
At present CONFIG_CMD_HASH enables the 'hash' command which also brings
in the hashing API. Some boards may wish to enable the API without the
command. Add a separate CONFIG to permit this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 cmd/Kconfig     |  2 ++
 common/Kconfig  | 12 ++++++++++++
 common/Makefile |  2 +-
 common/hash.c   |  4 ++--
 4 files changed, 17 insertions(+), 3 deletions(-)

Comments

Tom Rini May 17, 2017, 1:13 p.m. UTC | #1
On Wed, May 17, 2017 at 03:25:26AM -0600, Simon Glass wrote:

> At present CONFIG_CMD_HASH enables the 'hash' command which also brings
> in the hashing API. Some boards may wish to enable the API without the
> command. Add a separate CONFIG to permit this.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v3: None
> Changes in v2: None
> 
>  cmd/Kconfig     |  2 ++
>  common/Kconfig  | 12 ++++++++++++
>  common/Makefile |  2 +-
>  common/hash.c   |  4 ++--
>  4 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index b05e69a8b7..1e3cd02703 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -350,6 +350,7 @@ config CMD_MEMORY
>  
>  config CMD_CRC32
>  	bool "crc32"
> +	select HASH
>  	default y
>  	help
>  	  Compute CRC32.
> @@ -998,6 +999,7 @@ config CMD_BLOB
>  
>  config CMD_HASH
>  	bool "Support 'hash' command"
> +	select HASH
>  	help
>  	  This provides a way to hash data in memory using various supported
>  	  algorithms (such as SHA1, MD5, CRC32). The computed digest can be
> diff --git a/common/Kconfig b/common/Kconfig
> index 1879aefaf8..23bcf99a2c 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -493,4 +493,16 @@ config BOARD_EARLY_INIT_F
>  
>  endmenu
>  
> +menu "Security support"
> +
> +config HASH
> +	bool "Support hashing API (SHA1, SHA256, etc.)"
> +	help
> +	  This provides a way to hash data in memory using various supported
> +	  algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
> +	  and the algorithms it supports are defined in common/hash.c. See
> +	  also CMD_HASH for command-line access.

No need to resend the whole series.  But I think we should make this a
hidden (but with the help!) option.  It's framework, so if you say y
here and then don't use it anywhere (in say a command or another
framework) it will just get discarded at link time.
Simon Glass May 17, 2017, 3:07 p.m. UTC | #2
Hi Tom,

On 17 May 2017 at 07:13, Tom Rini <trini@konsulko.com> wrote:
> On Wed, May 17, 2017 at 03:25:26AM -0600, Simon Glass wrote:
>
>> At present CONFIG_CMD_HASH enables the 'hash' command which also brings
>> in the hashing API. Some boards may wish to enable the API without the
>> command. Add a separate CONFIG to permit this.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v3: None
>> Changes in v2: None
>>
>>  cmd/Kconfig     |  2 ++
>>  common/Kconfig  | 12 ++++++++++++
>>  common/Makefile |  2 +-
>>  common/hash.c   |  4 ++--
>>  4 files changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>> index b05e69a8b7..1e3cd02703 100644
>> --- a/cmd/Kconfig
>> +++ b/cmd/Kconfig
>> @@ -350,6 +350,7 @@ config CMD_MEMORY
>>
>>  config CMD_CRC32
>>       bool "crc32"
>> +     select HASH
>>       default y
>>       help
>>         Compute CRC32.
>> @@ -998,6 +999,7 @@ config CMD_BLOB
>>
>>  config CMD_HASH
>>       bool "Support 'hash' command"
>> +     select HASH
>>       help
>>         This provides a way to hash data in memory using various supported
>>         algorithms (such as SHA1, MD5, CRC32). The computed digest can be
>> diff --git a/common/Kconfig b/common/Kconfig
>> index 1879aefaf8..23bcf99a2c 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -493,4 +493,16 @@ config BOARD_EARLY_INIT_F
>>
>>  endmenu
>>
>> +menu "Security support"
>> +
>> +config HASH
>> +     bool "Support hashing API (SHA1, SHA256, etc.)"
>> +     help
>> +       This provides a way to hash data in memory using various supported
>> +       algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
>> +       and the algorithms it supports are defined in common/hash.c. See
>> +       also CMD_HASH for command-line access.
>
> No need to resend the whole series.  But I think we should make this a
> hidden (but with the help!) option.  It's framework, so if you say y
> here and then don't use it anywhere (in say a command or another
> framework) it will just get discarded at link time.

OK I just resent that one patch/

Regards,
Simon
diff mbox

Patch

diff --git a/cmd/Kconfig b/cmd/Kconfig
index b05e69a8b7..1e3cd02703 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -350,6 +350,7 @@  config CMD_MEMORY
 
 config CMD_CRC32
 	bool "crc32"
+	select HASH
 	default y
 	help
 	  Compute CRC32.
@@ -998,6 +999,7 @@  config CMD_BLOB
 
 config CMD_HASH
 	bool "Support 'hash' command"
+	select HASH
 	help
 	  This provides a way to hash data in memory using various supported
 	  algorithms (such as SHA1, MD5, CRC32). The computed digest can be
diff --git a/common/Kconfig b/common/Kconfig
index 1879aefaf8..23bcf99a2c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -493,4 +493,16 @@  config BOARD_EARLY_INIT_F
 
 endmenu
 
+menu "Security support"
+
+config HASH
+	bool "Support hashing API (SHA1, SHA256, etc.)"
+	help
+	  This provides a way to hash data in memory using various supported
+	  algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
+	  and the algorithms it supports are defined in common/hash.c. See
+	  also CMD_HASH for command-line access.
+
+endmenu
+
 source "common/spl/Kconfig"
diff --git a/common/Makefile b/common/Makefile
index 14d01844ad..b2d663530d 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -10,7 +10,7 @@  ifndef CONFIG_SPL_BUILD
 obj-y += init/
 obj-y += main.o
 obj-y += exports.o
-obj-y += hash.o
+obj-$(CONFIG_HASH) += hash.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
diff --git a/common/hash.c b/common/hash.c
index b645298afc..a0eded98d0 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -473,5 +473,5 @@  int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 
 	return 0;
 }
-#endif
-#endif
+#endif /* CONFIG_CMD_HASH || CONFIG_CMD_SHA1SUM || CONFIG_CMD_CRC32) */
+#endif /* !USE_HOSTCC */