From b146c5150a4b237ebf93d4f707bf341cfd9693f2 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 22 Apr 2013 12:35:59 -0700 Subject: [PATCH] Improve Visual C++ compat. --- .../ref/before_curve25519xsalsa20poly1305.c | 2 +- src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c | 2 +- src/libsodium/crypto_stream/salsa20/ref/stream_salsa20.c | 4 +++- src/libsodium/crypto_stream/salsa20/ref/xor_salsa20.c | 4 +++- src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c | 4 +++- src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c | 4 +++- src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c | 4 +++- src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c | 4 +++- src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c | 4 +++- src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c | 4 +++- src/libsodium/include/sodium/utils.h | 4 ++-- .../randombytes/salsa20/randombytes_salsa20_random.c | 2 +- src/libsodium/sodium/core.c | 4 +++- src/libsodium/sodium/utils.c | 4 ++-- 14 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c index 6925673f..40d4300e 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c @@ -3,7 +3,7 @@ #include "crypto_scalarmult_curve25519.h" static const unsigned char sigma[16] = { - 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', 'k' + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' }; static const unsigned char n[16] = {0}; diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c index 47568001..db29c254 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c @@ -9,7 +9,7 @@ Preconditions: |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. */ -static const unsigned char zero[32]; +static unsigned char zero[32]; int fe_isnonzero(const fe f) { diff --git a/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20.c b/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20.c index d47e8bb4..e8dc4300 100644 --- a/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20.c +++ b/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream( unsigned char *c,unsigned long long clen, diff --git a/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20.c b/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20.c index bc6baf1b..814f0fb0 100644 --- a/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20.c +++ b/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream_xor( unsigned char *c, diff --git a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c index 42340f88..70c498ce 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream( unsigned char *c,unsigned long long clen, diff --git a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c index fafe1f9b..c8193742 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream_xor( unsigned char *c, diff --git a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c index 0f88aa36..28e3de71 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream( unsigned char *c,unsigned long long clen, diff --git a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c index f2b63723..706a3604 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c @@ -9,7 +9,9 @@ Public domain. typedef unsigned int uint32; -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream_xor( unsigned char *c, diff --git a/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c b/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c index d276e126..50f87887 100644 --- a/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +++ b/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c @@ -8,7 +8,9 @@ Public domain. #include "crypto_core_hsalsa20.h" #include "crypto_stream_salsa20.h" -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream( unsigned char *c,unsigned long long clen, diff --git a/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c b/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c index 1014d6d2..14cce18a 100644 --- a/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +++ b/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c @@ -8,7 +8,9 @@ Public domain. #include "crypto_core_hsalsa20.h" #include "crypto_stream_salsa20.h" -static const unsigned char sigma[16] = "expand 32-byte k"; +static const unsigned char sigma[16] = { + 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' +}; int crypto_stream_xor( unsigned char *c, diff --git a/src/libsodium/include/sodium/utils.h b/src/libsodium/include/sodium/utils.h index fae1805c..ff6cdf9d 100644 --- a/src/libsodium/include/sodium/utils.h +++ b/src/libsodium/include/sodium/utils.h @@ -10,8 +10,8 @@ extern "C" { #endif -void *_sodium_alignedcalloc(unsigned char ** const unaligned_p, - const size_t len); +unsigned char *_sodium_alignedcalloc(unsigned char ** const unaligned_p, + const size_t len); SODIUM_EXPORT void sodium_memzero(void * const pnt, const size_t len); diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index 2a440d6d..3a80e49b 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -262,7 +262,7 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size) #ifdef ULONG_LONG_MAX assert(size <= ULONG_LONG_MAX); #endif - ret = crypto_stream_salsa20(buf, (unsigned long long) size, + ret = crypto_stream_salsa20((unsigned char *) buf, (unsigned long long) size, (unsigned char *) &stream.nonce, stream.key); assert(ret == 0); diff --git a/src/libsodium/sodium/core.c b/src/libsodium/sodium/core.c index 765b2937..e3d105f2 100644 --- a/src/libsodium/sodium/core.c +++ b/src/libsodium/sodium/core.c @@ -1,8 +1,10 @@ +#include + #include "core.h" #include "crypto_onetimeauth.h" -static _Bool initialized; +static bool initialized; int sodium_init(void) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 08d65237..b24039b4 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -27,7 +27,7 @@ sodium_memzero(void * const pnt, const size_t len) #endif } -void * +unsigned char * _sodium_alignedcalloc(unsigned char ** const unaligned_p, const size_t len) { unsigned char *aligned; @@ -35,7 +35,7 @@ _sodium_alignedcalloc(unsigned char ** const unaligned_p, const size_t len) size_t i; if (SIZE_MAX - (size_t) 256U < len || - (unaligned = malloc(len + (size_t) 256U)) == NULL) { + (unaligned = (unsigned char *) malloc(len + (size_t) 256U)) == NULL) { *unaligned_p = NULL; return NULL; }