Zero the subkey in {stream,xor}_xsalsa20

Spotted by Michael Rogers.
This commit is contained in:
Frank Denis
2014-11-23 23:42:07 -08:00
parent db5b51042a
commit 60610da39d
2 changed files with 10 additions and 2 deletions
@@ -7,6 +7,7 @@ Public domain.
#include "api.h"
#include "crypto_core_hsalsa20.h"
#include "crypto_stream_salsa20.h"
#include "utils.h"
static const unsigned char sigma[16] = {
'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
@@ -19,6 +20,9 @@ int crypto_stream(
)
{
unsigned char subkey[32];
int ret;
crypto_core_hsalsa20(subkey,n,k,sigma);
return crypto_stream_salsa20(c,clen,n + 16,subkey);
ret = crypto_stream_salsa20(c,clen,n + 16,subkey);
sodium_memzero(subkey, sizeof subkey);
return ret;
}
@@ -7,6 +7,7 @@ Public domain.
#include "api.h"
#include "crypto_core_hsalsa20.h"
#include "crypto_stream_salsa20.h"
#include "utils.h"
static const unsigned char sigma[16] = {
'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
@@ -20,6 +21,9 @@ int crypto_stream_xor(
)
{
unsigned char subkey[32];
int ret;
crypto_core_hsalsa20(subkey,n,k,sigma);
return crypto_stream_salsa20_xor(c,m,mlen,n + 16,subkey);
ret = crypto_stream_salsa20_xor(c,m,mlen,n + 16,subkey);
sodium_memzero(subkey, sizeof subkey);
return ret;
}