Skip to contentSkip to conversation

crypto: bcm - use memcpy_and_pad in ahash_hmac_setkey

PATCH In review Thorsten Blum 2 participants 2 messages Jul 20 – Jul 30 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: bcm - use memcpy_and_pad in ahash_hmac_setkey

Use memcpy_and_pad() instead of memcpy() followed by memset() to simplify ahash_hmac_setkey().

---
 drivers/crypto/bcm/cipher.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/crypto/bcm/cipher.c +1 -3
index 240b40ae9cd6..e9d9ca7441b6 100644
@@ -2387,9 +2387,7 @@ static int ahash_hmac_setkey(struct crypto_ahash *ahash, const u8 *key,
 	 * outer hashing in software.
 	 */
 	if (iproc_priv.spu.spu_type == SPU_TYPE_SPUM) {
-		memcpy(ctx->ipad, ctx->authkey, ctx->authkeylen);
-		memset(ctx->ipad + ctx->authkeylen, 0,
-		       blocksize - ctx->authkeylen);
+		memcpy_and_pad(ctx->ipad, blocksize, ctx->authkey, ctx->authkeylen, 0);
 		ctx->authkeylen = 0;
 		unsafe_memcpy(ctx->opad, ctx->ipad, blocksize,
 			      "fortified memcpy causes -Wrestrict warning");
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

Use memcpy_and_pad() instead of memcpy() followed by memset() to simplify ahash_hmac_setkey().

---
 drivers/crypto/bcm/cipher.c | 4 +---
 1 file changed, 1 insertion(+), 3 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