Sync salsa20/ref with supercop-20140425

But these changes may be reverted unless there is a solid reason for
adding these copies to the stack.
This commit is contained in:
Frank Denis 2014-05-07 21:39:43 -07:00
parent c81c5c1010
commit dcf8869229
2 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
version 20080913
version 20140420
D. J. Bernstein
Public domain.
*/
@ -23,16 +23,18 @@ int crypto_stream(
{
unsigned char in[16];
unsigned char block[64];
unsigned char kcopy[32];
unsigned long long i;
unsigned int u;
if (!clen) return 0;
for (i = 0;i < 32;++i) kcopy[i] = k[i];
for (i = 0;i < 8;++i) in[i] = n[i];
for (i = 8;i < 16;++i) in[i] = 0;
while (clen >= 64) {
crypto_core_salsa20(c,in,k,sigma);
crypto_core_salsa20(c,in,kcopy,sigma);
u = 1;
for (i = 8;i < 16;++i) {
@ -46,7 +48,7 @@ int crypto_stream(
}
if (clen) {
crypto_core_salsa20(block,in,k,sigma);
crypto_core_salsa20(block,in,kcopy,sigma);
for (i = 0;i < clen;++i) c[i] = block[i];
}
return 0;

View File

@ -1,5 +1,5 @@
/*
version 20080913
version 20140420
D. J. Bernstein
Public domain.
*/
@ -24,16 +24,18 @@ int crypto_stream_xor(
{
unsigned char in[16];
unsigned char block[64];
unsigned char kcopy[32];
unsigned long long i;
unsigned int u;
if (!mlen) return 0;
for (i = 0;i < 32;++i) kcopy[i] = k[i];
for (i = 0;i < 8;++i) in[i] = n[i];
for (i = 8;i < 16;++i) in[i] = 0;
while (mlen >= 64) {
crypto_core_salsa20(block,in,k,sigma);
crypto_core_salsa20(block,in,kcopy,sigma);
for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i];
u = 1;
@ -49,7 +51,7 @@ int crypto_stream_xor(
}
if (mlen) {
crypto_core_salsa20(block,in,k,sigma);
crypto_core_salsa20(block,in,kcopy,sigma);
for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i];
}
return 0;