mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Zero the state afetr AES decryption
This commit is contained in:
@@ -970,6 +970,7 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
|
|||||||
const unsigned char *k)
|
const unsigned char *k)
|
||||||
{
|
{
|
||||||
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
|
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
|
||||||
|
int ret;
|
||||||
|
|
||||||
PREFETCH_WRITE(m);
|
PREFETCH_WRITE(m);
|
||||||
PREFETCH_READ(c);
|
PREFETCH_READ(c);
|
||||||
@@ -977,8 +978,11 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
|
|||||||
|
|
||||||
crypto_aead_aes256gcm_beforenm(&st, k);
|
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);
|
m, nsec, c, clen, mac, ad, adlen, npub, (const crypto_aead_aes256gcm_state *) &st);
|
||||||
|
sodium_memzero(&st, sizeof st);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -988,6 +988,7 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
|
|||||||
const unsigned char *k)
|
const unsigned char *k)
|
||||||
{
|
{
|
||||||
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
|
CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state st;
|
||||||
|
int ret;
|
||||||
|
|
||||||
PREFETCH_WRITE(m);
|
PREFETCH_WRITE(m);
|
||||||
PREFETCH_READ(c);
|
PREFETCH_READ(c);
|
||||||
@@ -995,8 +996,11 @@ crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, unsigned char *nsec,
|
|||||||
|
|
||||||
crypto_aead_aes256gcm_beforenm(&st, k);
|
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);
|
m, nsec, c, clen, mac, ad, adlen, npub, (const crypto_aead_aes256gcm_state *) &st);
|
||||||
|
sodium_memzero(&st, sizeof st);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
Reference in New Issue
Block a user