mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
crypto: aspeed - clear the crypto_aes_ctx when done
Declare the gen_aes_key with __cleanup(aes_zeroize_ctx) to avoid that its contents could be leaking via the stack when the function returns. And since it is only required in one branch of the if-statement there, move it to that block, too. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
8b74759f49
commit
26b845b7e1
|
|
@ -576,7 +576,6 @@ static int aspeed_aes_setkey(struct crypto_skcipher *cipher, const u8 *key,
|
|||
{
|
||||
struct aspeed_cipher_ctx *ctx = crypto_skcipher_ctx(cipher);
|
||||
struct aspeed_hace_dev *hace_dev = ctx->hace_dev;
|
||||
struct crypto_aes_ctx gen_aes_key;
|
||||
|
||||
CIPHER_DBG(hace_dev, "keylen: %d bits\n", (keylen * 8));
|
||||
|
||||
|
|
@ -585,9 +584,9 @@ static int aspeed_aes_setkey(struct crypto_skcipher *cipher, const u8 *key,
|
|||
return -EINVAL;
|
||||
|
||||
if (ctx->hace_dev->version == AST2500_VERSION) {
|
||||
struct crypto_aes_ctx gen_aes_key __cleanup(aes_zeroize_ctx);
|
||||
aes_expandkey(&gen_aes_key, key, keylen);
|
||||
memcpy(ctx->key, gen_aes_key.key_enc, AES_MAX_KEYLENGTH);
|
||||
|
||||
} else {
|
||||
memcpy(ctx->key, key, keylen);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user