diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 861d8d2e..7027cc7a 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -20,7 +20,6 @@ libsodium_la_SOURCES = \ crypto_core/salsa20/core_salsa20.c \ crypto_generichash/crypto_generichash.c \ crypto_generichash/blake2b/generichash_blake2.c \ - crypto_generichash/blake2b/ref/blake2-impl.h \ crypto_generichash/blake2b/ref/blake2.h \ crypto_generichash/blake2b/ref/blake2b-compress-ref.c \ crypto_generichash/blake2b/ref/blake2b-load-sse2.h \ diff --git a/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c b/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c index 48f6ec2e..1d1220fe 100644 --- a/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c +++ b/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c @@ -13,12 +13,6 @@ Public domain. #define ROUNDS 20 #define U32C(v) (v##U) -static uint32_t -rotate(uint32_t u, int c) -{ - return (u << c) | (u >> (32 - c)); -} - int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, @@ -54,38 +48,38 @@ crypto_core_hsalsa20(unsigned char *out, x9 = LOAD32_LE(in + 12); for (i = ROUNDS; i > 0; i -= 2) { - x4 ^= rotate(x0 + x12, 7); - x8 ^= rotate(x4 + x0, 9); - x12 ^= rotate(x8 + x4, 13); - x0 ^= rotate(x12 + x8, 18); - x9 ^= rotate(x5 + x1, 7); - x13 ^= rotate(x9 + x5, 9); - x1 ^= rotate(x13 + x9, 13); - x5 ^= rotate(x1 + x13, 18); - x14 ^= rotate(x10 + x6, 7); - x2 ^= rotate(x14 + x10, 9); - x6 ^= rotate(x2 + x14, 13); - x10 ^= rotate(x6 + x2, 18); - x3 ^= rotate(x15 + x11, 7); - x7 ^= rotate(x3 + x15, 9); - x11 ^= rotate(x7 + x3, 13); - x15 ^= rotate(x11 + x7, 18); - x1 ^= rotate(x0 + x3, 7); - x2 ^= rotate(x1 + x0, 9); - x3 ^= rotate(x2 + x1, 13); - x0 ^= rotate(x3 + x2, 18); - x6 ^= rotate(x5 + x4, 7); - x7 ^= rotate(x6 + x5, 9); - x4 ^= rotate(x7 + x6, 13); - x5 ^= rotate(x4 + x7, 18); - x11 ^= rotate(x10 + x9, 7); - x8 ^= rotate(x11 + x10, 9); - x9 ^= rotate(x8 + x11, 13); - x10 ^= rotate(x9 + x8, 18); - x12 ^= rotate(x15 + x14, 7); - x13 ^= rotate(x12 + x15, 9); - x14 ^= rotate(x13 + x12, 13); - x15 ^= rotate(x14 + x13, 18); + x4 ^= ROTL32(x0 + x12, 7); + x8 ^= ROTL32(x4 + x0, 9); + x12 ^= ROTL32(x8 + x4, 13); + x0 ^= ROTL32(x12 + x8, 18); + x9 ^= ROTL32(x5 + x1, 7); + x13 ^= ROTL32(x9 + x5, 9); + x1 ^= ROTL32(x13 + x9, 13); + x5 ^= ROTL32(x1 + x13, 18); + x14 ^= ROTL32(x10 + x6, 7); + x2 ^= ROTL32(x14 + x10, 9); + x6 ^= ROTL32(x2 + x14, 13); + x10 ^= ROTL32(x6 + x2, 18); + x3 ^= ROTL32(x15 + x11, 7); + x7 ^= ROTL32(x3 + x15, 9); + x11 ^= ROTL32(x7 + x3, 13); + x15 ^= ROTL32(x11 + x7, 18); + x1 ^= ROTL32(x0 + x3, 7); + x2 ^= ROTL32(x1 + x0, 9); + x3 ^= ROTL32(x2 + x1, 13); + x0 ^= ROTL32(x3 + x2, 18); + x6 ^= ROTL32(x5 + x4, 7); + x7 ^= ROTL32(x6 + x5, 9); + x4 ^= ROTL32(x7 + x6, 13); + x5 ^= ROTL32(x4 + x7, 18); + x11 ^= ROTL32(x10 + x9, 7); + x8 ^= ROTL32(x11 + x10, 9); + x9 ^= ROTL32(x8 + x11, 13); + x10 ^= ROTL32(x9 + x8, 18); + x12 ^= ROTL32(x15 + x14, 7); + x13 ^= ROTL32(x12 + x15, 9); + x14 ^= ROTL32(x13 + x12, 13); + x15 ^= ROTL32(x14 + x13, 18); } STORE32_LE(out + 0, x0); diff --git a/src/libsodium/crypto_core/salsa20/ref/core_salsa20_ref.c b/src/libsodium/crypto_core/salsa20/ref/core_salsa20_ref.c index 65a4f482..378b6dac 100644 --- a/src/libsodium/crypto_core/salsa20/ref/core_salsa20_ref.c +++ b/src/libsodium/crypto_core/salsa20/ref/core_salsa20_ref.c @@ -13,12 +13,6 @@ Public domain. #define ROUNDS 20 #define U32C(v) (v##U) -static uint32_t -rotate(uint32_t u, int c) -{ - return (u << c) | (u >> (32 - c)); -} - int crypto_core_salsa20(unsigned char *out, const unsigned char *in, @@ -56,38 +50,38 @@ crypto_core_salsa20(unsigned char *out, j14 = x14 = LOAD32_LE(k + 28); for (i = ROUNDS; i > 0; i -= 2) { - x4 ^= rotate(x0 + x12, 7); - x8 ^= rotate(x4 + x0, 9); - x12 ^= rotate(x8 + x4, 13); - x0 ^= rotate(x12 + x8, 18); - x9 ^= rotate(x5 + x1, 7); - x13 ^= rotate(x9 + x5, 9); - x1 ^= rotate(x13 + x9, 13); - x5 ^= rotate(x1 + x13, 18); - x14 ^= rotate(x10 + x6, 7); - x2 ^= rotate(x14 + x10, 9); - x6 ^= rotate(x2 + x14, 13); - x10 ^= rotate(x6 + x2, 18); - x3 ^= rotate(x15 + x11, 7); - x7 ^= rotate(x3 + x15, 9); - x11 ^= rotate(x7 + x3, 13); - x15 ^= rotate(x11 + x7, 18); - x1 ^= rotate(x0 + x3, 7); - x2 ^= rotate(x1 + x0, 9); - x3 ^= rotate(x2 + x1, 13); - x0 ^= rotate(x3 + x2, 18); - x6 ^= rotate(x5 + x4, 7); - x7 ^= rotate(x6 + x5, 9); - x4 ^= rotate(x7 + x6, 13); - x5 ^= rotate(x4 + x7, 18); - x11 ^= rotate(x10 + x9, 7); - x8 ^= rotate(x11 + x10, 9); - x9 ^= rotate(x8 + x11, 13); - x10 ^= rotate(x9 + x8, 18); - x12 ^= rotate(x15 + x14, 7); - x13 ^= rotate(x12 + x15, 9); - x14 ^= rotate(x13 + x12, 13); - x15 ^= rotate(x14 + x13, 18); + x4 ^= ROTL32(x0 + x12, 7); + x8 ^= ROTL32(x4 + x0, 9); + x12 ^= ROTL32(x8 + x4, 13); + x0 ^= ROTL32(x12 + x8, 18); + x9 ^= ROTL32(x5 + x1, 7); + x13 ^= ROTL32(x9 + x5, 9); + x1 ^= ROTL32(x13 + x9, 13); + x5 ^= ROTL32(x1 + x13, 18); + x14 ^= ROTL32(x10 + x6, 7); + x2 ^= ROTL32(x14 + x10, 9); + x6 ^= ROTL32(x2 + x14, 13); + x10 ^= ROTL32(x6 + x2, 18); + x3 ^= ROTL32(x15 + x11, 7); + x7 ^= ROTL32(x3 + x15, 9); + x11 ^= ROTL32(x7 + x3, 13); + x15 ^= ROTL32(x11 + x7, 18); + x1 ^= ROTL32(x0 + x3, 7); + x2 ^= ROTL32(x1 + x0, 9); + x3 ^= ROTL32(x2 + x1, 13); + x0 ^= ROTL32(x3 + x2, 18); + x6 ^= ROTL32(x5 + x4, 7); + x7 ^= ROTL32(x6 + x5, 9); + x4 ^= ROTL32(x7 + x6, 13); + x5 ^= ROTL32(x4 + x7, 18); + x11 ^= ROTL32(x10 + x9, 7); + x8 ^= ROTL32(x11 + x10, 9); + x9 ^= ROTL32(x8 + x11, 13); + x10 ^= ROTL32(x9 + x8, 18); + x12 ^= ROTL32(x15 + x14, 7); + x13 ^= ROTL32(x12 + x15, 9); + x14 ^= ROTL32(x13 + x12, 13); + x15 ^= ROTL32(x14 + x13, 18); } x0 += j0; diff --git a/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012_ref.c b/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012_ref.c index 4c625715..9c66a066 100644 --- a/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012_ref.c +++ b/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012_ref.c @@ -13,12 +13,6 @@ Public domain. #define ROUNDS 12 #define U32C(v) (v##U) -static uint32_t -rotate(uint32_t u, int c) -{ - return (u << c) | (u >> (32 - c)); -} - int crypto_core_salsa2012(unsigned char *out, const unsigned char *in, @@ -56,38 +50,38 @@ crypto_core_salsa2012(unsigned char *out, j14 = x14 = LOAD32_LE(k + 28); for (i = ROUNDS; i > 0; i -= 2) { - x4 ^= rotate(x0 + x12, 7); - x8 ^= rotate(x4 + x0, 9); - x12 ^= rotate(x8 + x4, 13); - x0 ^= rotate(x12 + x8, 18); - x9 ^= rotate(x5 + x1, 7); - x13 ^= rotate(x9 + x5, 9); - x1 ^= rotate(x13 + x9, 13); - x5 ^= rotate(x1 + x13, 18); - x14 ^= rotate(x10 + x6, 7); - x2 ^= rotate(x14 + x10, 9); - x6 ^= rotate(x2 + x14, 13); - x10 ^= rotate(x6 + x2, 18); - x3 ^= rotate(x15 + x11, 7); - x7 ^= rotate(x3 + x15, 9); - x11 ^= rotate(x7 + x3, 13); - x15 ^= rotate(x11 + x7, 18); - x1 ^= rotate(x0 + x3, 7); - x2 ^= rotate(x1 + x0, 9); - x3 ^= rotate(x2 + x1, 13); - x0 ^= rotate(x3 + x2, 18); - x6 ^= rotate(x5 + x4, 7); - x7 ^= rotate(x6 + x5, 9); - x4 ^= rotate(x7 + x6, 13); - x5 ^= rotate(x4 + x7, 18); - x11 ^= rotate(x10 + x9, 7); - x8 ^= rotate(x11 + x10, 9); - x9 ^= rotate(x8 + x11, 13); - x10 ^= rotate(x9 + x8, 18); - x12 ^= rotate(x15 + x14, 7); - x13 ^= rotate(x12 + x15, 9); - x14 ^= rotate(x13 + x12, 13); - x15 ^= rotate(x14 + x13, 18); + x4 ^= ROTL32(x0 + x12, 7); + x8 ^= ROTL32(x4 + x0, 9); + x12 ^= ROTL32(x8 + x4, 13); + x0 ^= ROTL32(x12 + x8, 18); + x9 ^= ROTL32(x5 + x1, 7); + x13 ^= ROTL32(x9 + x5, 9); + x1 ^= ROTL32(x13 + x9, 13); + x5 ^= ROTL32(x1 + x13, 18); + x14 ^= ROTL32(x10 + x6, 7); + x2 ^= ROTL32(x14 + x10, 9); + x6 ^= ROTL32(x2 + x14, 13); + x10 ^= ROTL32(x6 + x2, 18); + x3 ^= ROTL32(x15 + x11, 7); + x7 ^= ROTL32(x3 + x15, 9); + x11 ^= ROTL32(x7 + x3, 13); + x15 ^= ROTL32(x11 + x7, 18); + x1 ^= ROTL32(x0 + x3, 7); + x2 ^= ROTL32(x1 + x0, 9); + x3 ^= ROTL32(x2 + x1, 13); + x0 ^= ROTL32(x3 + x2, 18); + x6 ^= ROTL32(x5 + x4, 7); + x7 ^= ROTL32(x6 + x5, 9); + x4 ^= ROTL32(x7 + x6, 13); + x5 ^= ROTL32(x4 + x7, 18); + x11 ^= ROTL32(x10 + x9, 7); + x8 ^= ROTL32(x11 + x10, 9); + x9 ^= ROTL32(x8 + x11, 13); + x10 ^= ROTL32(x9 + x8, 18); + x12 ^= ROTL32(x15 + x14, 7); + x13 ^= ROTL32(x12 + x15, 9); + x14 ^= ROTL32(x13 + x12, 13); + x15 ^= ROTL32(x14 + x13, 18); } x0 += j0; diff --git a/src/libsodium/crypto_core/salsa208/ref/core_salsa208_ref.c b/src/libsodium/crypto_core/salsa208/ref/core_salsa208_ref.c index 8c234afd..e2c2ee34 100644 --- a/src/libsodium/crypto_core/salsa208/ref/core_salsa208_ref.c +++ b/src/libsodium/crypto_core/salsa208/ref/core_salsa208_ref.c @@ -13,12 +13,6 @@ Public domain. #define ROUNDS 8 #define U32C(v) (v##U) -static uint32_t -rotate(uint32_t u, int c) -{ - return (u << c) | (u >> (32 - c)); -} - int crypto_core_salsa208(unsigned char *out, const unsigned char *in, @@ -56,38 +50,38 @@ crypto_core_salsa208(unsigned char *out, j14 = x14 = LOAD32_LE(k + 28); for (i = ROUNDS; i > 0; i -= 2) { - x4 ^= rotate(x0 + x12, 7); - x8 ^= rotate(x4 + x0, 9); - x12 ^= rotate(x8 + x4, 13); - x0 ^= rotate(x12 + x8, 18); - x9 ^= rotate(x5 + x1, 7); - x13 ^= rotate(x9 + x5, 9); - x1 ^= rotate(x13 + x9, 13); - x5 ^= rotate(x1 + x13, 18); - x14 ^= rotate(x10 + x6, 7); - x2 ^= rotate(x14 + x10, 9); - x6 ^= rotate(x2 + x14, 13); - x10 ^= rotate(x6 + x2, 18); - x3 ^= rotate(x15 + x11, 7); - x7 ^= rotate(x3 + x15, 9); - x11 ^= rotate(x7 + x3, 13); - x15 ^= rotate(x11 + x7, 18); - x1 ^= rotate(x0 + x3, 7); - x2 ^= rotate(x1 + x0, 9); - x3 ^= rotate(x2 + x1, 13); - x0 ^= rotate(x3 + x2, 18); - x6 ^= rotate(x5 + x4, 7); - x7 ^= rotate(x6 + x5, 9); - x4 ^= rotate(x7 + x6, 13); - x5 ^= rotate(x4 + x7, 18); - x11 ^= rotate(x10 + x9, 7); - x8 ^= rotate(x11 + x10, 9); - x9 ^= rotate(x8 + x11, 13); - x10 ^= rotate(x9 + x8, 18); - x12 ^= rotate(x15 + x14, 7); - x13 ^= rotate(x12 + x15, 9); - x14 ^= rotate(x13 + x12, 13); - x15 ^= rotate(x14 + x13, 18); + x4 ^= ROTL32(x0 + x12, 7); + x8 ^= ROTL32(x4 + x0, 9); + x12 ^= ROTL32(x8 + x4, 13); + x0 ^= ROTL32(x12 + x8, 18); + x9 ^= ROTL32(x5 + x1, 7); + x13 ^= ROTL32(x9 + x5, 9); + x1 ^= ROTL32(x13 + x9, 13); + x5 ^= ROTL32(x1 + x13, 18); + x14 ^= ROTL32(x10 + x6, 7); + x2 ^= ROTL32(x14 + x10, 9); + x6 ^= ROTL32(x2 + x14, 13); + x10 ^= ROTL32(x6 + x2, 18); + x3 ^= ROTL32(x15 + x11, 7); + x7 ^= ROTL32(x3 + x15, 9); + x11 ^= ROTL32(x7 + x3, 13); + x15 ^= ROTL32(x11 + x7, 18); + x1 ^= ROTL32(x0 + x3, 7); + x2 ^= ROTL32(x1 + x0, 9); + x3 ^= ROTL32(x2 + x1, 13); + x0 ^= ROTL32(x3 + x2, 18); + x6 ^= ROTL32(x5 + x4, 7); + x7 ^= ROTL32(x6 + x5, 9); + x4 ^= ROTL32(x7 + x6, 13); + x5 ^= ROTL32(x4 + x7, 18); + x11 ^= ROTL32(x10 + x9, 7); + x8 ^= ROTL32(x11 + x10, 9); + x9 ^= ROTL32(x8 + x11, 13); + x10 ^= ROTL32(x9 + x8, 18); + x12 ^= ROTL32(x15 + x14, 7); + x13 ^= ROTL32(x12 + x15, 9); + x14 ^= ROTL32(x13 + x12, 13); + x15 ^= ROTL32(x14 + x13, 18); } x0 += j0; diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2-impl.h b/src/libsodium/crypto_generichash/blake2b/ref/blake2-impl.h deleted file mode 100644 index 9515f408..00000000 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2-impl.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ - -#ifndef blake2_impl_H -#define blake2_impl_H - -#include -#include - -#include "utils.h" - -static inline uint32_t rotl32( const uint32_t w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 32 - c ) ); -} - -static inline uint64_t rotl64( const uint64_t w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 64 - c ) ); -} - -static inline uint32_t rotr32( const uint32_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 32 - c ) ); -} - -static inline uint64_t rotr64( const uint64_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 64 - c ) ); -} - -/* prevents compiler optimizing out memset() */ -static inline void secure_zero_memory( void *v, size_t n ) -{ - sodium_memzero(v, n); -} - -#endif diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c index b3f56e46..8927b1e3 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c @@ -20,8 +20,8 @@ #include #include "blake2.h" -#include "blake2-impl.h" #include "blake2b-compress-avx2.h" +#include "private/common.h" CRYPTO_ALIGN(64) static const uint64_t blake2b_IV[8] = { diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c index 8af04dd8..67f020b4 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c @@ -3,7 +3,6 @@ #include #include "blake2.h" -#include "blake2-impl.h" #include "private/common.h" CRYPTO_ALIGN(64) static const uint64_t blake2b_IV[8] = @@ -53,13 +52,13 @@ int blake2b_compress_ref( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYT #define G(r,i,a,b,c,d) \ do { \ a = a + b + m[blake2b_sigma[r][2*i+0]]; \ - d = rotr64(d ^ a, 32); \ + d = ROTR64(d ^ a, 32); \ c = c + d; \ - b = rotr64(b ^ c, 24); \ + b = ROTR64(b ^ c, 24); \ a = a + b + m[blake2b_sigma[r][2*i+1]]; \ - d = rotr64(d ^ a, 16); \ + d = ROTR64(d ^ a, 16); \ c = c + d; \ - b = rotr64(b ^ c, 63); \ + b = ROTR64(b ^ c, 63); \ } while(0) #define ROUND(r) \ do { \ diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c index ea064c26..7fae9c63 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c @@ -17,8 +17,8 @@ #include #include "blake2.h" -#include "blake2-impl.h" #include "blake2b-compress-sse41.h" +#include "private/common.h" CRYPTO_ALIGN(64) static const uint64_t blake2b_IV[8] = { diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c index 882351e2..3afd6a44 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c @@ -15,8 +15,8 @@ #include #include "blake2.h" -#include "blake2-impl.h" #include "blake2b-compress-ssse3.h" +#include "private/common.h" CRYPTO_ALIGN(64) static const uint64_t blake2b_IV[8] = { diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c index d8a76461..7bbbc7bb 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c @@ -17,8 +17,8 @@ #include #include "blake2.h" -#include "blake2-impl.h" #include "runtime.h" +#include "utils.h" #include "private/common.h" #ifdef HAVE_TI_MODE @@ -250,7 +250,7 @@ int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, c memset( block, 0, BLAKE2B_BLOCKBYTES ); memcpy( block, key, keylen ); blake2b_update( S, block, BLAKE2B_BLOCKBYTES ); - secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ + sodium_memzero( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ } return 0; } @@ -291,7 +291,7 @@ int blake2b_init_key_salt_personal( blake2b_state *S, const uint8_t outlen, cons memset( block, 0, BLAKE2B_BLOCKBYTES ); memcpy( block, key, keylen ); blake2b_update( S, block, BLAKE2B_BLOCKBYTES ); - secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ + sodium_memzero( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ } return 0; } diff --git a/src/libsodium/include/sodium/private/common.h b/src/libsodium/include/sodium/private/common.h index ff93062a..d3ab8dd6 100644 --- a/src/libsodium/include/sodium/private/common.h +++ b/src/libsodium/include/sodium/private/common.h @@ -154,4 +154,19 @@ store32_be(uint8_t dst[4], uint32_t w) #endif } +#ifndef __GNUC__ +# ifdef __attribute__ +# undef __attribute__ +# endif +# define __attribute__(a) +#endif + +#ifndef CRYPTO_ALIGN +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) +# define CRYPTO_ALIGN(x) __declspec(align(x)) +# else +# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) +# endif +#endif + #endif