mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
crypto: safexcel - Simplify the check for a valid AES key
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 <atenart@kernel.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Acked-by: Antoine Tenart <atenart@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
8f2b1310ac
commit
41d39d6f2b
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user