crypto: inside-secure - Zeroize temporary arrays on stack with sensitive data
Subsystems (2)
PATCH v2 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.
---
v2: Added "Fixes:" and "Reported-by:" tags
drivers/crypto/inside-secure/safexcel_hash.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/inside-secure/safexcel_hash.c +4 -0
@@ -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,9 @@ 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
Antoine Tenart
maintainerQuoted 31 lines · Thomas Huth
key_tmp[] in
safexcel_xcbcmac_setkey()and consts[] / _const[] insafexcel_cmac_setkey()contain crypto key material that should not get exposed to the outside once the function is done. Scrub the arrays withmemzero_explicit()to avoid that the data could leak via the stack.Reported-by Sashiko <[email protected]>Fixes 38f21b4bab11f ("crypto: inside-secure - Added support for the AES XCBC ahash")Fixes 7a627db9cafdb ("crypto: inside-secure - Added support for the AES-CMAC ahash")Acked-by Antoine Tenart <[email protected]>Signed-off-by Thomas Huth <[email protected]>---
v2: Added "Fixes:" and "Reported-by:" tagsdrivers/crypto/inside-secure/safexcel_hash.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/crypto/inside-secure/safexcel_hash.c +1
-0@@ -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;
drivers/crypto/inside-secure/safexcel_hash.c static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, · line 2108
Quoted 4 lines
drivers/crypto/inside-secure/safexcel_hash.c +1
-0@@ -2104,6 +2105,9 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, } ctx->cbcmac = false; +
Sorry, I just noticed there's an extra empty line here.
Quoted 8 lines
drivers/crypto/inside-secure/safexcel_hash.c +2
-0+memzero_explicit (consts,sizeof (consts)); +memzero_explicit (_const,sizeof (_const));return 0 ; }Signature · 1 line
2.55.0
Quoted 31 lines · Antoine Tenart
Quoted 30 lines · Thomas Huth
key_tmp[] in
safexcel_xcbcmac_setkey()and consts[] / _const[] insafexcel_cmac_setkey()contain crypto key material that should not get exposed to the outside once the function is done. Scrub the arrays withmemzero_explicit()to avoid that the data could leak via the stack.Reported-by Sashiko <[email protected]>Fixes 38f21b4bab11f ("crypto: inside-secure - Added support for the AES XCBC ahash")Fixes 7a627db9cafdb ("crypto: inside-secure - Added support for the AES-CMAC ahash")Acked-by Antoine Tenart <[email protected]>Signed-off-by Thomas Huth <[email protected]>---
v2: Added "Fixes:" and "Reported-by:" tagsdrivers/crypto/inside-secure/safexcel_hash.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/crypto/inside-secure/safexcel_hash.c +1
-0@@ -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;
Quoted 7 lines
drivers/crypto/inside-secure/safexcel_hash.c static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, · line 2108
Quoted 5 lines
drivers/crypto/inside-secure/safexcel_hash.c +1
-0@@ -2104,6 +2105,9 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, } ctx->cbcmac = false; +Sorry, I just noticed there's an extra empty line here.
Oops, that's embarrassing, not sure how I missed that looking at the patch multiple times already... Thanks for spotting it, I'll send a v3.
Thomas