diff --git a/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c b/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c index 6d3eacbd..b90827c0 100644 --- a/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +++ b/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c @@ -25,7 +25,7 @@ int crypto_stream( unsigned char in[16]; unsigned char block[64]; unsigned char kcopy[32]; - unsigned long long i; + unsigned int i; unsigned int u; if (!clen) return 0; @@ -50,7 +50,7 @@ int crypto_stream( if (clen) { crypto_core_salsa20(block,in,kcopy,sigma); - for (i = 0;i < clen;++i) c[i] = block[i]; + for (i = 0;i < (unsigned int) clen;++i) c[i] = block[i]; } sodium_memzero(block, sizeof block); sodium_memzero(kcopy, sizeof kcopy); diff --git a/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c b/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c index 19cd79e7..27cf1470 100644 --- a/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +++ b/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c @@ -28,7 +28,7 @@ int crypto_stream_salsa20_xor_ic( unsigned char in[16]; unsigned char block[64]; unsigned char kcopy[32]; - unsigned long long i; + unsigned int i; unsigned int u; if (!mlen) return 0; @@ -58,7 +58,7 @@ int crypto_stream_salsa20_xor_ic( if (mlen) { crypto_core_salsa20(block,in,kcopy,sigma); - for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; + for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; } sodium_memzero(block, sizeof block); sodium_memzero(kcopy, sizeof kcopy); diff --git a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c index 286d397b..ef121235 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c @@ -1,5 +1,5 @@ /* -version 20080913 +version 20140420 D. J. Bernstein Public domain. */ @@ -22,16 +22,18 @@ int crypto_stream( { unsigned char in[16]; unsigned char block[64]; - unsigned long long i; + unsigned char kcopy[32]; + unsigned int 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_salsa2012(c,in,k,sigma); + crypto_core_salsa2012(c,in,kcopy,sigma); u = 1; for (i = 8;i < 16;++i) { @@ -45,10 +47,11 @@ int crypto_stream( } if (clen) { - crypto_core_salsa2012(block,in,k,sigma); - for (i = 0;i < clen;++i) c[i] = block[i]; + crypto_core_salsa2012(block,in,kcopy,sigma); + for (i = 0;i < (unsigned int) clen;++i) c[i] = block[i]; } sodium_memzero(block, sizeof block); + sodium_memzero(kcopy, sizeof kcopy); return 0; } diff --git a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c index 6a506f1c..132a720a 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c @@ -1,5 +1,5 @@ /* -version 20080913 +version 20140420 D. J. Bernstein Public domain. */ @@ -23,16 +23,18 @@ int crypto_stream_xor( { unsigned char in[16]; unsigned char block[64]; - unsigned long long i; + unsigned char kcopy[32]; + unsigned int 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_salsa2012(block,in,k,sigma); + crypto_core_salsa2012(block,in,kcopy,sigma); for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; u = 1; @@ -48,10 +50,11 @@ int crypto_stream_xor( } if (mlen) { - crypto_core_salsa2012(block,in,k,sigma); - for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; + crypto_core_salsa2012(block,in,kcopy,sigma); + for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; } sodium_memzero(block, sizeof block); + sodium_memzero(kcopy, sizeof kcopy); return 0; } diff --git a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c index b7b86ec2..6a15ff15 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c @@ -1,5 +1,5 @@ /* -version 20080913 +version 20140420 D. J. Bernstein Public domain. */ @@ -22,16 +22,18 @@ int crypto_stream( { unsigned char in[16]; unsigned char block[64]; - unsigned long long i; + unsigned char kcopy[32]; + unsigned int 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_salsa208(c,in,k,sigma); + crypto_core_salsa208(c,in,kcopy,sigma); u = 1; for (i = 8;i < 16;++i) { @@ -45,10 +47,11 @@ int crypto_stream( } if (clen) { - crypto_core_salsa208(block,in,k,sigma); - for (i = 0;i < clen;++i) c[i] = block[i]; + crypto_core_salsa208(block,in,kcopy,sigma); + for (i = 0;i < (unsigned int) clen;++i) c[i] = block[i]; } sodium_memzero(block, sizeof block); + sodium_memzero(kcopy, sizeof kcopy); return 0; } diff --git a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c index cfe47ebe..de0eae9f 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c @@ -1,5 +1,5 @@ /* -version 20080913 +version 20140420 D. J. Bernstein Public domain. */ @@ -23,16 +23,18 @@ int crypto_stream_xor( { unsigned char in[16]; unsigned char block[64]; - unsigned long long i; + unsigned char kcopy[32]; + unsigned int 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_salsa208(block,in,k,sigma); + crypto_core_salsa208(block,in,kcopy,sigma); for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; u = 1; @@ -48,10 +50,11 @@ int crypto_stream_xor( } if (mlen) { - crypto_core_salsa208(block,in,k,sigma); - for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; + crypto_core_salsa208(block,in,kcopy,sigma); + for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; } sodium_memzero(block, sizeof block); + sodium_memzero(kcopy, sizeof kcopy); return 0; }