From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
To: trini@konsulko.com, u-boot@lists.denx.de
Cc: sjg@chromium.org, Alexandru Gagniuc <mr.nuke.me@gmail.com>
Subject: [PATCH v2 2/6] lib: Drop SHA512_ALGO in lieu of SHA512
Date: Thu, 2 Sep 2021 19:54:18 -0500 [thread overview]
Message-ID: <20210903005422.1336362-3-mr.nuke.me@gmail.com> (raw)
In-Reply-To: <20210903005422.1336362-1-mr.nuke.me@gmail.com>
SHA512_ALGO was used as a "either SHA512 or SHA384", although the
implementations of these two algorithms share a majority of code.
From a Kconfig interface perspective, it makes sense to present two
distinct options. This requires #ifdefing out the SHA512
implementation from sha512.c. The latter doesn't make any sense.
It's reasonable to say in Kconfig that SHA384 depends on SHA512, and
seems to be the more polite way to handle the selection.
Thus, automatically select SHA512 when SHA384 is enabled.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
arch/arm/mach-socfpga/Kconfig | 2 +-
lib/Kconfig | 12 ++++--------
lib/Makefile | 2 +-
lib/crypt/Kconfig | 2 +-
lib/efi_loader/Kconfig | 2 +-
lib/sha512.c | 2 --
6 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index f4791c1ebe..bddfd44427 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -11,7 +11,7 @@ config SOCFPGA_SECURE_VAB_AUTH
depends on TARGET_SOCFPGA_AGILEX || TARGET_SOCFPGA_N5X
select FIT_IMAGE_POST_PROCESS
select SHA384
- select SHA512_ALGO
+ select SHA512
select SPL_FIT_IMAGE_POST_PROCESS
help
All images loaded from FIT will be authenticated by Secure Device
diff --git a/lib/Kconfig b/lib/Kconfig
index c535147aea..48565a4169 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -375,14 +375,9 @@ config SHA256
The SHA256 algorithm produces a 256-bit (32-byte) hash value
(digest).
-config SHA512_ALGO
- bool "Enable SHA512 algorithm"
- help
- This option enables support of internal SHA512 algorithm.
config SHA512
bool "Enable SHA512 support"
- depends on SHA512_ALGO
help
This option enables support of hashing using SHA512 algorithm.
The hash is calculated in software.
@@ -391,10 +386,11 @@ config SHA512
config SHA384
bool "Enable SHA384 support"
- depends on SHA512_ALGO
+ select SHA512
help
This option enables support of hashing using SHA384 algorithm.
- The hash is calculated in software.
+ The hash is calculated in software. This is also selects SHA512,
+ because these implementations share the bulk of the code..
The SHA384 algorithm produces a 384-bit (48-byte) hash value
(digest).
@@ -409,7 +405,7 @@ if SHA_HW_ACCEL
config SHA512_HW_ACCEL
bool "Enable hardware acceleration for SHA512"
- depends on SHA512_ALGO
+ depends on SHA512
help
This option enables hardware acceleration for the SHA384 and SHA512
hashing algorithms. This affects the 'hash' command and also the
diff --git a/lib/Makefile b/lib/Makefile
index 8ba745faa0..6aa48ca3d5 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -65,7 +65,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
obj-$(CONFIG_HASH) += hash-checksum.o
obj-$(CONFIG_SHA1) += sha1.o
obj-$(CONFIG_SHA256) += sha256.o
-obj-$(CONFIG_SHA512_ALGO) += sha512.o
+obj-$(CONFIG_SHA512) += sha512.o
obj-$(CONFIG_CRYPT_PW) += crypt/
obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
diff --git a/lib/crypt/Kconfig b/lib/crypt/Kconfig
index 5495ae8d4c..6a50029642 100644
--- a/lib/crypt/Kconfig
+++ b/lib/crypt/Kconfig
@@ -20,7 +20,7 @@ config CRYPT_PW_SHA256
config CRYPT_PW_SHA512
bool "Provide sha512crypt"
select SHA512
- select SHA512_ALGO
+ select SHA512
help
Enables support for the sha512crypt password-hashing algorithm.
The prefix is "$6$".
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index dacc3b5881..08463251cd 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -323,7 +323,7 @@ config EFI_TCG2_PROTOCOL
depends on TPM_V2
select SHA1
select SHA256
- select SHA512_ALGO
+ select SHA512
select SHA384
select SHA512
select HASH
diff --git a/lib/sha512.c b/lib/sha512.c
index 35f31e3dc5..a421f249ba 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -320,7 +320,6 @@ void sha384_csum_wd(const unsigned char *input, unsigned int ilen,
#endif
-#if defined(CONFIG_SHA512)
void sha512_starts(sha512_context * ctx)
{
ctx->state[0] = SHA512_H0;
@@ -381,4 +380,3 @@ void sha512_csum_wd(const unsigned char *input, unsigned int ilen,
sha512_finish(&ctx, output);
}
-#endif
--
2.31.1
next prev parent reply other threads:[~2021-09-03 0:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 0:54 [PATCH v2 0/6] Fix FIT hash algos in SPL (Fixes v2021.10-rc3) Alexandru Gagniuc
2021-09-03 0:54 ` [PATCH v2 1/6] common: Remove unused CONFIG_FIT_SHAxxx selectors Alexandru Gagniuc
2021-09-09 1:25 ` Tom Rini
2021-09-03 0:54 ` Alexandru Gagniuc [this message]
2021-09-09 1:25 ` [PATCH v2 2/6] lib: Drop SHA512_ALGO in lieu of SHA512 Tom Rini
2021-09-09 13:58 ` Andreas Schwab
2021-09-03 0:54 ` [PATCH v2 3/6] common/spl: Drop [ST]PL_HASH_SUPPORT in favor of [ST]PL_HASH Alexandru Gagniuc
2021-09-09 1:25 ` Tom Rini
2021-09-03 0:54 ` [PATCH v2 4/6] common: Move MD5 hash to hash_algo[] array Alexandru Gagniuc
2021-09-09 1:25 ` Tom Rini
2021-09-03 0:54 ` [PATCH v2 5/6] image: Drop if/elseif hash selection in calculate_hash() Alexandru Gagniuc
2021-09-09 1:25 ` Tom Rini
2021-09-03 0:54 ` [PATCH v2 6/6] image: Drop IMAGE_ENABLE_{MD5, CRC32} #defines Alexandru Gagniuc
2021-09-09 1:25 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210903005422.1336362-3-mr.nuke.me@gmail.com \
--to=mr.nuke.me@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox