* [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey()
@ 2026-09-21 6:11 Thorsten Blum
2026-09-21 6:11 ` [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey() Thorsten Blum
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-09-21 6:11 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
simplify cast5_setkey().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
crypto/cast5_generic.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/crypto/cast5_generic.c b/crypto/cast5_generic.c
index f68330793e0c..1de0dc966a03 100644
--- a/crypto/cast5_generic.c
+++ b/crypto/cast5_generic.c
@@ -483,9 +483,7 @@ int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len)
c->rr = key_len <= 10 ? 1 : 0;
- memset(p_key, 0, 16);
- memcpy(p_key, key, key_len);
-
+ memcpy_and_pad(p_key, sizeof(p_key), key, key_len, 0);
x[0] = be32_to_cpu(p_key[0]);
x[1] = be32_to_cpu(p_key[1]);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey()
2026-09-21 6:11 [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey() Thorsten Blum
@ 2026-09-21 6:11 ` Thorsten Blum
2026-09-21 6:11 ` [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var() Thorsten Blum
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-09-21 6:11 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
simplify __cast6_setkey().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
crypto/cast6_generic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c
index 4c08c42646f0..9b6bdd2aa511 100644
--- a/crypto/cast6_generic.c
+++ b/crypto/cast6_generic.c
@@ -112,8 +112,7 @@ int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, unsigned int key_len)
if (key_len % 4 != 0)
return -EINVAL;
- memset(p_key, 0, 32);
- memcpy(p_key, in_key, key_len);
+ memcpy_and_pad(p_key, sizeof(p_key), in_key, key_len, 0);
key[0] = be32_to_cpu(p_key[0]); /* A */
key[1] = be32_to_cpu(p_key[1]); /* B */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var()
2026-09-21 6:11 [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey() Thorsten Blum
2026-09-21 6:11 ` [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey() Thorsten Blum
@ 2026-09-21 6:11 ` Thorsten Blum
2026-09-21 8:56 ` Linus Walleij
2026-09-21 6:11 ` [PATCH 4/5] crypto: octeontx - use memcpy_and_pad() in aead_hmac_init() Thorsten Blum
2026-09-21 6:11 ` [PATCH 5/5] crypto: octeontx2 " Thorsten Blum
3 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2026-09-21 6:11 UTC (permalink / raw)
To: Linus Walleij, Imre Kaloz, Corentin Labbe, Herbert Xu, David S. Miller
Cc: Thorsten Blum, linux-crypto, linux-arm-kernel, linux-kernel
Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
simplify register_chain_var().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c b/drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c
index fdda04672454..33e8e887a415 100644
--- a/drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c
+++ b/drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c
@@ -707,8 +707,7 @@ static int register_chain_var(struct crypto_tfm *tfm, u8 xpad, u32 target,
return -EAGAIN;
}
- memcpy(pad, key, key_len);
- memset(pad + key_len, 0, HMAC_PAD_BLOCKLEN - key_len);
+ memcpy_and_pad(pad, HMAC_PAD_BLOCKLEN, key, key_len, 0);
for (i = 0; i < HMAC_PAD_BLOCKLEN; i++)
pad[i] ^= xpad;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] crypto: octeontx - use memcpy_and_pad() in aead_hmac_init()
2026-09-21 6:11 [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey() Thorsten Blum
2026-09-21 6:11 ` [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey() Thorsten Blum
2026-09-21 6:11 ` [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var() Thorsten Blum
@ 2026-09-21 6:11 ` Thorsten Blum
2026-09-21 6:11 ` [PATCH 5/5] crypto: octeontx2 " Thorsten Blum
3 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-09-21 6:11 UTC (permalink / raw)
To: Srujana Challa, Bharat Bhushan, Herbert Xu, David S. Miller,
David C.C.M. Gall
Cc: Thorsten Blum, linux-crypto, linux-kernel
Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
simplify aead_hmac_init().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
index 096be42e9d03..1becaf77b10c 100644
--- a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
@@ -792,8 +792,7 @@ static int aead_hmac_init(struct crypto_aead *cipher,
ipad = ctx->ipad;
opad = ctx->opad;
- memcpy(ipad, ctx->key, authkeylen);
- memset(ipad + authkeylen, 0, bs - authkeylen);
+ memcpy_and_pad(ipad, bs, ctx->key, authkeylen, 0);
memcpy(opad, ipad, bs);
for (icount = 0; icount < bs; icount++) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] crypto: octeontx2 - use memcpy_and_pad() in aead_hmac_init()
2026-09-21 6:11 [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey() Thorsten Blum
` (2 preceding siblings ...)
2026-09-21 6:11 ` [PATCH 4/5] crypto: octeontx - use memcpy_and_pad() in aead_hmac_init() Thorsten Blum
@ 2026-09-21 6:11 ` Thorsten Blum
3 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-09-21 6:11 UTC (permalink / raw)
To: Srujana Challa, Bharat Bhushan, Herbert Xu, David S. Miller,
David C.C.M. Gall
Cc: Thorsten Blum, linux-crypto, linux-kernel
Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
simplify aead_hmac_init().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
index 8d9f394d6b50..65ad29f1e47c 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
@@ -882,8 +882,7 @@ static int aead_hmac_init(struct crypto_aead *cipher,
ipad = ctx->ipad;
opad = ctx->opad;
- memcpy(ipad, ctx->key, authkeylen);
- memset(ipad + authkeylen, 0, bs - authkeylen);
+ memcpy_and_pad(ipad, bs, ctx->key, authkeylen, 0);
memcpy(opad, ipad, bs);
for (icount = 0; icount < bs; icount++) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var()
2026-09-21 6:11 ` [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var() Thorsten Blum
@ 2026-09-21 8:56 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2026-09-21 8:56 UTC (permalink / raw)
To: Thorsten Blum
Cc: Imre Kaloz, Corentin Labbe, Herbert Xu, David S. Miller,
linux-crypto, linux-arm-kernel, linux-kernel
On Mon, Sep 21, 2026 at 8:12 AM Thorsten Blum <blum@kernel.org> wrote:
> Use memcpy_and_pad() instead of separate memcpy() and memset() calls to
> simplify register_chain_var().
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
This makes sense.
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-21 8:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 6:11 [PATCH 1/5] crypto: cast5 - use memcpy_and_pad() in cast5_setkey() Thorsten Blum
2026-09-21 6:11 ` [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey() Thorsten Blum
2026-09-21 6:11 ` [PATCH 3/5] crypto: ixp4xx - use memcpy_and_pad() in register_chain_var() Thorsten Blum
2026-09-21 8:56 ` Linus Walleij
2026-09-21 6:11 ` [PATCH 4/5] crypto: octeontx - use memcpy_and_pad() in aead_hmac_init() Thorsten Blum
2026-09-21 6:11 ` [PATCH 5/5] crypto: octeontx2 " Thorsten Blum
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®