]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: qce - use memcpy_and_pad in qce_aead_setkey
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 21 Mar 2026 13:14:39 +0000 (14:14 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Mar 2026 09:52:44 +0000 (18:52 +0900)
Replace memset() followed by memcpy() with memcpy_and_pad() to simplify
the code and to write to ->auth_key only once.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qce/aead.c

index 79e92bc3f7d33eb8b24493972f27ad766332d7c9..9cb11fada2c4ddecebcb5c48416245f402389bb1 100644 (file)
@@ -637,8 +637,8 @@ static int qce_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int
 
        memcpy(ctx->enc_key, authenc_keys.enckey, authenc_keys.enckeylen);
 
-       memset(ctx->auth_key, 0, sizeof(ctx->auth_key));
-       memcpy(ctx->auth_key, authenc_keys.authkey, authenc_keys.authkeylen);
+       memcpy_and_pad(ctx->auth_key, sizeof(ctx->auth_key),
+                      authenc_keys.authkey, authenc_keys.authkeylen, 0);
 
        return crypto_aead_setkey(ctx->fallback, key, keylen);
 }