salsa20/ref: zero sensitive data before returning

This commit is contained in:
Frank Denis 2014-05-08 11:12:04 -07:00
parent 4722990ec3
commit fda08703fc
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Public domain.
#include "api.h"
#include "crypto_core_salsa20.h"
#include "utils.h"
#ifndef HAVE_AMD64_ASM
@ -51,6 +52,9 @@ int crypto_stream(
crypto_core_salsa20(block,in,kcopy,sigma);
for (i = 0;i < clen;++i) c[i] = block[i];
}
sodium_memzero(block, sizeof block);
sodium_memzero(kcopy, sizeof kcopy);
return 0;
}

View File

@ -6,6 +6,7 @@ Public domain.
#include "api.h"
#include "crypto_core_salsa20.h"
#include "utils.h"
#ifndef HAVE_AMD64_ASM
@ -54,6 +55,9 @@ int crypto_stream_xor(
crypto_core_salsa20(block,in,kcopy,sigma);
for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i];
}
sodium_memzero(block, sizeof block);
sodium_memzero(kcopy, sizeof kcopy);
return 0;
}