* [PATCH] crypto: eip93: Make read-only arrays static const
@ 2025-04-02 11:13 Colin Ian King
2025-04-03 8:00 ` Antoine Tenart
2025-04-07 5:25 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2025-04-02 11:13 UTC (permalink / raw)
To: Christian Marangi, Antoine Tenart, Herbert Xu, David S . Miller,
linux-crypto
Cc: kernel-janitors, linux-kernel
Don't populate the read-only arrays sha256_init, sha224_init, sha1_init
and md5_init on the stack at run time, instead make them static.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
.../crypto/inside-secure/eip93/eip93-hash.c | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/crypto/inside-secure/eip93/eip93-hash.c b/drivers/crypto/inside-secure/eip93/eip93-hash.c
index 5e9627467a42..528d5bd864c9 100644
--- a/drivers/crypto/inside-secure/eip93/eip93-hash.c
+++ b/drivers/crypto/inside-secure/eip93/eip93-hash.c
@@ -97,12 +97,20 @@ void eip93_hash_handle_result(struct crypto_async_request *async, int err)
static void eip93_hash_init_sa_state_digest(u32 hash, u8 *digest)
{
- u32 sha256_init[] = { SHA256_H0, SHA256_H1, SHA256_H2, SHA256_H3,
- SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7 };
- u32 sha224_init[] = { SHA224_H0, SHA224_H1, SHA224_H2, SHA224_H3,
- SHA224_H4, SHA224_H5, SHA224_H6, SHA224_H7 };
- u32 sha1_init[] = { SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
- u32 md5_init[] = { MD5_H0, MD5_H1, MD5_H2, MD5_H3 };
+ static const u32 sha256_init[] = {
+ SHA256_H0, SHA256_H1, SHA256_H2, SHA256_H3,
+ SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7
+ };
+ static const u32 sha224_init[] = {
+ SHA224_H0, SHA224_H1, SHA224_H2, SHA224_H3,
+ SHA224_H4, SHA224_H5, SHA224_H6, SHA224_H7
+ };
+ static const u32 sha1_init[] = {
+ SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4
+ };
+ static const u32 md5_init[] = {
+ MD5_H0, MD5_H1, MD5_H2, MD5_H3
+ };
/* Init HASH constant */
switch (hash) {
--
2.49.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: eip93: Make read-only arrays static const
2025-04-02 11:13 [PATCH] crypto: eip93: Make read-only arrays static const Colin Ian King
@ 2025-04-03 8:00 ` Antoine Tenart
2025-04-07 5:25 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Antoine Tenart @ 2025-04-03 8:00 UTC (permalink / raw)
To: Christian Marangi, Colin Ian King, David S . Miller, Herbert Xu,
linux-crypto
Cc: kernel-janitors, linux-kernel
Quoting Colin Ian King (2025-04-02 13:13:47)
> Don't populate the read-only arrays sha256_init, sha224_init, sha1_init
> and md5_init on the stack at run time, instead make them static.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Thanks!
> ---
> .../crypto/inside-secure/eip93/eip93-hash.c | 20 +++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/inside-secure/eip93/eip93-hash.c b/drivers/crypto/inside-secure/eip93/eip93-hash.c
> index 5e9627467a42..528d5bd864c9 100644
> --- a/drivers/crypto/inside-secure/eip93/eip93-hash.c
> +++ b/drivers/crypto/inside-secure/eip93/eip93-hash.c
> @@ -97,12 +97,20 @@ void eip93_hash_handle_result(struct crypto_async_request *async, int err)
>
> static void eip93_hash_init_sa_state_digest(u32 hash, u8 *digest)
> {
> - u32 sha256_init[] = { SHA256_H0, SHA256_H1, SHA256_H2, SHA256_H3,
> - SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7 };
> - u32 sha224_init[] = { SHA224_H0, SHA224_H1, SHA224_H2, SHA224_H3,
> - SHA224_H4, SHA224_H5, SHA224_H6, SHA224_H7 };
> - u32 sha1_init[] = { SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
> - u32 md5_init[] = { MD5_H0, MD5_H1, MD5_H2, MD5_H3 };
> + static const u32 sha256_init[] = {
> + SHA256_H0, SHA256_H1, SHA256_H2, SHA256_H3,
> + SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7
> + };
> + static const u32 sha224_init[] = {
> + SHA224_H0, SHA224_H1, SHA224_H2, SHA224_H3,
> + SHA224_H4, SHA224_H5, SHA224_H6, SHA224_H7
> + };
> + static const u32 sha1_init[] = {
> + SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4
> + };
> + static const u32 md5_init[] = {
> + MD5_H0, MD5_H1, MD5_H2, MD5_H3
> + };
>
> /* Init HASH constant */
> switch (hash) {
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: eip93: Make read-only arrays static const
2025-04-02 11:13 [PATCH] crypto: eip93: Make read-only arrays static const Colin Ian King
2025-04-03 8:00 ` Antoine Tenart
@ 2025-04-07 5:25 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2025-04-07 5:25 UTC (permalink / raw)
To: Colin Ian King
Cc: Christian Marangi, Antoine Tenart, David S . Miller,
linux-crypto, kernel-janitors, linux-kernel
On Wed, Apr 02, 2025 at 12:13:47PM +0100, Colin Ian King wrote:
> Don't populate the read-only arrays sha256_init, sha224_init, sha1_init
> and md5_init on the stack at run time, instead make them static.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> .../crypto/inside-secure/eip93/eip93-hash.c | 20 +++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-07 5:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-02 11:13 [PATCH] crypto: eip93: Make read-only arrays static const Colin Ian King
2025-04-03 8:00 ` Antoine Tenart
2025-04-07 5:25 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®