From: Thorsten Blum <blum@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Thorsten Blum <blum@kernel.org>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] crypto: cast6 - use memcpy_and_pad() in __cast6_setkey()
Date: Mon, 21 Sep 2026 08:11:21 +0200 [thread overview]
Message-ID: <20260921061120.29694-7-blum@kernel.org> (raw)
In-Reply-To: <20260921061120.29694-6-blum@kernel.org>
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 */
next prev parent reply other threads:[~2026-09-21 6:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20260921061120.29694-7-blum@kernel.org \
--to=blum@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®