Zero the state afetr AES decryption

This commit is contained in:
Frank Denis
2026-02-05 21:42:03 +01:00
parent 69435b04fe
commit e8492b1859
2 changed files with 10 additions and 2 deletions
@@ -970,6 +970,7 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
const unsigned char *k)
{
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
int ret;
PREFETCH_WRITE(m);
PREFETCH_READ(c);
@@ -977,8 +978,11 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
crypto_aead_aes256gcm_beforenm(&st, k);
return crypto_aead_aes256gcm_decrypt_detached_afternm(
ret = crypto_aead_aes256gcm_decrypt_detached_afternm(
m, nsec, c, clen, mac, ad, adlen, npub, (const crypto_aead_aes256gcm_state *) &st);
sodium_memzero(&st, sizeof st);
return ret;
}
int
@@ -988,6 +988,7 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
const unsigned char *k)
{
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
int ret;
PREFETCH_WRITE(m);
PREFETCH_READ(c);
@@ -995,8 +996,11 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
crypto_aead_aes256gcm_beforenm(&st, k);
return crypto_aead_aes256gcm_decrypt_detached_afternm(
ret = crypto_aead_aes256gcm_decrypt_detached_afternm(
m, nsec, c, clen, mac, ad, adlen, npub, (const crypto_aead_aes256gcm_state *) &st);
sodium_memzero(&st, sizeof st);
return ret;
}
int