Skip to contentSkip to conversation

crypto: inside-secure - Zeroize temporary arrays on stack with sensitive data

PATCH In review Thomas Huth 2 participants 2 messages Aug 19 – Sep 11

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

PATCH v3 1/1 crypto: inside-secure - Zeroize temporary arrays on stack with sensitive data

key_tmp[] in safexcel_xcbcmac_setkey() and consts[] / _const[] in safexcel_cmac_setkey() contain crypto key material that should not get exposed to the outside once the function is done. Scrub the arrays with memzero_explicit() to avoid that the data could leak via the stack.

Fixes 38f21b4bab11f ("crypto: inside-secure - Added support for the AES XCBC ahash")
Fixes 7a627db9cafdb ("crypto: inside-secure - Added support for the AES-CMAC ahash")

---
v3: Fixed white space damage

 drivers/crypto/inside-secure/safexcel_hash.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/crypto/inside-secure/safexcel_hash.c +3 -0
index 3402e570d045c..7c68118fbb05c 100644
@@ -1993,6 +1993,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahash *tfm, const u8 *key,
 	ret = aes_prepareenckey(ctx->aes,
 				(u8 *)key_tmp + 2 * AES_BLOCK_SIZE,
 				AES_MIN_KEY_SIZE);
+	memzero_explicit(key_tmp, sizeof(key_tmp));
 	if (ret)
 		return ret;
 
@@ -2104,6 +2105,8 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key,
 	}
 	ctx->cbcmac = false;
 
+	memzero_explicit(consts, sizeof(consts));
+	memzero_explicit(_const, sizeof(_const));
 	return 0;
 }
 
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 12 lines · Thomas Huth

key_tmp[] in safexcel_xcbcmac_setkey() and consts[] / _const[] in safexcel_cmac_setkey() contain crypto key material that should not get exposed to the outside once the function is done. Scrub the arrays with memzero_explicit() to avoid that the data could leak via the stack.

Fixes 38f21b4bab11f ("crypto: inside-secure - Added support for the AES XCBC ahash")
Fixes 7a627db9cafdb ("crypto: inside-secure - Added support for the AES-CMAC ahash")
Quoted 5 lines

---
v3: Fixed white space damage

 drivers/crypto/inside-secure/safexcel_hash.c | 3 +++
 1 file changed, 3 insertions(+)

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