Re: [PATCH v5 08/10] crypto: safexcel - Simplify the check for a valid AES key
Antoine Tenart <[email protected]>
| Newsgroups | org.kernel.vger.linux-crypto,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <annZlgf4ygaT0pZg@kwain> |
On Mon, Aug 10, 2026 at 11:30:03AM +0200, Thomas Huth wrote: > From: Thomas Huth <[email protected]> > > safexcel_aead_setkey() currently uses aes_expandkey() to check for a valid > AES key, but then does not use the crypto_aes_ctx afterwards anymore, > i.e. this is just a wasteful way of checking the key length, and thus > aes_check_keylen() should be used instead. > This also fixes a potential leak of sensitive data via the stack, since > this function forgot to zeroize crypto_aes_ctx before returning to the > caller. > > Suggested-by: Antoine Tenart <[email protected]> > Signed-off-by: Thomas Huth <[email protected]> Acked-by: Antoine Tenart <[email protected]> Thanks! > --- > drivers/crypto/inside-secure/safexcel_cipher.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c > index a8349b684693e..f07d043c67d45 100644 > --- a/drivers/crypto/inside-secure/safexcel_cipher.c > +++ b/drivers/crypto/inside-secure/safexcel_cipher.c > @@ -407,7 +407,6 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key, > struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); > struct safexcel_crypto_priv *priv = ctx->base.priv; > struct crypto_authenc_keys keys; > - struct crypto_aes_ctx aes; > int err = -EINVAL, i; > const char *alg; > > @@ -438,7 +437,7 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key, > goto badkey; > break; > case SAFEXCEL_AES: > - err = aes_expandkey(&aes, keys.enckey, keys.enckeylen); > + err = aes_check_keylen(keys.enckeylen); > if (unlikely(err)) > goto badkey; > break; > -- > 2.55.0 >