Wipe the shared key in crypto_box() and crypto_secretbox()

The _easy and _detached interfaces already did this.
This commit is contained in:
Frank Denis
2015-01-04 18:29:17 +01:00
parent cbc1b89181
commit 16f32cf1a5
@@ -9,8 +9,13 @@ int crypto_box(
)
{
unsigned char k[crypto_box_BEFORENMBYTES];
int ret;
crypto_box_beforenm(k,pk,sk);
return crypto_box_afternm(c,m,mlen,n,k);
ret = crypto_box_afternm(c,m,mlen,n,k);
sodium_memzero(k, sizeof k);
return ret;
}
int crypto_box_open(
@@ -22,6 +27,11 @@ int crypto_box_open(
)
{
unsigned char k[crypto_box_BEFORENMBYTES];
int ret;
crypto_box_beforenm(k,pk,sk);
return crypto_box_open_afternm(m,c,clen,n,k);
ret = crypto_box_open_afternm(m,c,clen,n,k);
sodium_memzero(k, sizeof k);
return ret;
}