Skip to contentSkip to conversation

crypto: qce - use memcpy_and_pad in qce_aead_setkey

PATCH In review Thorsten Blum 3 participants 3 messages Mar 21 – Mar 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qce - use memcpy_and_pad in qce_aead_setkey

Replace memset() followed by memcpy() with memcpy_and_pad() to simplify the code and to write to ->auth_key only once.

---
 drivers/crypto/qce/aead.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qce/aead.c +2 -2
index 846e1d42775d..425ee6703e3e 100644
@@ -642,8 +642,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);
 }
maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

Replace memset() followed by memcpy() with memcpy_and_pad() to simplify the code and to write to ->auth_key only once.

---
 drivers/crypto/qce/aead.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt