rbnacl-libsodium 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +3 -0
- data/vendor/libsodium/ChangeLog +21 -0
- data/vendor/libsodium/Makefile.in +9 -0
- data/vendor/libsodium/THANKS +3 -0
- data/vendor/libsodium/aclocal.m4 +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +919 -85
- data/vendor/libsodium/autom4te.cache/output.5 +18351 -0
- data/vendor/libsodium/autom4te.cache/requests +960 -725
- data/vendor/libsodium/autom4te.cache/traces.1 +289 -247
- data/vendor/libsodium/autom4te.cache/traces.5 +3032 -0
- data/vendor/libsodium/build-aux/ltmain.sh +70 -11
- data/vendor/libsodium/builds/msvc/properties/ARM.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseDEXE.props +1 -1
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +3 -1
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +13 -1
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +244 -241
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +192 -189
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +2 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +13 -1
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +244 -241
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +192 -189
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +3 -1
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +13 -1
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +244 -241
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +192 -189
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +3 -1
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +13 -1
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +244 -241
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +192 -189
- data/vendor/libsodium/configure +918 -84
- data/vendor/libsodium/configure.ac +89 -15
- data/vendor/libsodium/dist-build/Makefile.am +6 -2
- data/vendor/libsodium/dist-build/Makefile.in +15 -2
- data/vendor/libsodium/dist-build/android-armv8-a.sh +4 -0
- data/vendor/libsodium/dist-build/android-build.sh +9 -9
- data/vendor/libsodium/dist-build/android-mips64.sh +4 -0
- data/vendor/libsodium/dist-build/android-x86-64.sh +4 -0
- data/vendor/libsodium/dist-build/emscripten.sh +3 -3
- data/vendor/libsodium/dist-build/ios.sh +5 -5
- data/vendor/libsodium/dist-build/nativeclient.sh +28 -0
- data/vendor/libsodium/examples/Makefile +21 -0
- data/vendor/libsodium/examples/auth.c +68 -0
- data/vendor/libsodium/examples/box.c +133 -0
- data/vendor/libsodium/examples/box_detached.c +132 -0
- data/vendor/libsodium/examples/generichash.c +80 -0
- data/vendor/libsodium/examples/generichash_stream.c +58 -0
- data/vendor/libsodium/examples/shorthash.c +58 -0
- data/vendor/libsodium/examples/sign.c +78 -0
- data/vendor/libsodium/examples/utils.h +106 -0
- data/vendor/libsodium/libsodium-uninstalled.pc.in +1 -1
- data/vendor/libsodium/libsodium.vcxproj +2 -0
- data/vendor/libsodium/libsodium.vcxproj.filters +6 -0
- data/vendor/libsodium/m4/ax_check_compile_flag.m4 +2 -2
- data/vendor/libsodium/m4/ax_check_define.m4 +92 -0
- data/vendor/libsodium/m4/ax_check_link_flag.m4 +3 -2
- data/vendor/libsodium/m4/libtool.m4 +111 -60
- data/vendor/libsodium/m4/ltoptions.m4 +1 -1
- data/vendor/libsodium/m4/ltsugar.m4 +1 -1
- data/vendor/libsodium/m4/ltversion.m4 +6 -6
- data/vendor/libsodium/m4/lt~obsolete.m4 +1 -1
- data/vendor/libsodium/msvc-scripts/Makefile.in +9 -0
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/Makefile.in +9 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +27 -3
- data/vendor/libsodium/src/libsodium/Makefile.in +170 -63
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +852 -0
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +137 -17
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +10 -6
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +29 -23
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +9 -10
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +4 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +4 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +3 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/api.h +10 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +51 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c +29 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.am +6 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.in +67 -40
- data/vendor/libsodium/src/libsodium/include/sodium.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +88 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +28 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +0 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +1 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +23 -0
- data/vendor/libsodium/src/libsodium/include/sodium/export.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h +37 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +3 -2
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +6 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +15 -1
- data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +49 -0
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +11 -1
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +71 -45
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +12 -2
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +26 -3
- data/vendor/libsodium/src/libsodium/sodium/utils.c +86 -13
- data/vendor/libsodium/test/Makefile.in +9 -0
- data/vendor/libsodium/test/default/Makefile.am +130 -0
- data/vendor/libsodium/test/default/Makefile.in +197 -50
- data/vendor/libsodium/test/default/aead_aes256gcm.c +3197 -0
- data/vendor/libsodium/test/default/aead_aes256gcm.exp +1 -0
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +150 -17
- data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +51 -0
- data/vendor/libsodium/test/default/chacha20.c +80 -5
- data/vendor/libsodium/test/default/chacha20.exp +11 -0
- data/vendor/libsodium/test/default/generichash.c +1332 -1
- data/vendor/libsodium/test/default/generichash.exp +1 -1
- data/vendor/libsodium/test/default/generichash2.c +3 -2
- data/vendor/libsodium/test/default/generichash3.c +2 -1
- data/vendor/libsodium/test/default/nacl-test-wrapper.sh +26 -0
- data/vendor/libsodium/test/default/randombytes.c +4 -0
- data/vendor/libsodium/test/default/scalarmult.c +33 -14
- data/vendor/libsodium/test/default/scalarmult.exp +4 -4
- data/vendor/libsodium/test/default/secretbox.c +9 -0
- data/vendor/libsodium/test/default/secretbox.exp +19 -0
- data/vendor/libsodium/test/default/secretbox_easy.c +40 -4
- data/vendor/libsodium/test/default/secretbox_easy.exp +58 -1
- data/vendor/libsodium/test/default/sodium_core.c +2 -0
- data/vendor/libsodium/test/default/sodium_utils.c +46 -7
- data/vendor/libsodium/test/default/sodium_utils.exp +5 -0
- data/vendor/libsodium/test/default/stream.c +1 -0
- metadata +28 -3
@@ -33,7 +33,11 @@ BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
|
|
33
33
|
# pragma comment(lib, "advapi32.lib")
|
34
34
|
#endif
|
35
35
|
|
36
|
-
#
|
36
|
+
#if defined(__OpenBSD__) || defined(__CloudABI__)
|
37
|
+
# define HAVE_SAFE_ARC4RANDOM 1
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#ifdef HAVE_SAFE_ARC4RANDOM
|
37
41
|
|
38
42
|
uint32_t
|
39
43
|
randombytes_sysrandom(void)
|
@@ -115,7 +119,13 @@ randombytes_sysrandom_random_dev_open(void)
|
|
115
119
|
do {
|
116
120
|
fd = open(*device, O_RDONLY);
|
117
121
|
if (fd != -1) {
|
118
|
-
if (fstat(fd, &st) == 0 &&
|
122
|
+
if (fstat(fd, &st) == 0 &&
|
123
|
+
# ifdef S_ISNAM
|
124
|
+
(S_ISNAM(st.st_mode) || S_ISCHR(st.st_mode))
|
125
|
+
# else
|
126
|
+
S_ISCHR(st.st_mode)
|
127
|
+
# endif
|
128
|
+
) {
|
119
129
|
# if defined(F_SETFD) && defined(FD_CLOEXEC)
|
120
130
|
(void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
|
121
131
|
# endif
|
@@ -10,12 +10,16 @@ typedef struct CPUFeatures_ {
|
|
10
10
|
int has_neon;
|
11
11
|
int has_sse2;
|
12
12
|
int has_sse3;
|
13
|
+
int has_pclmul;
|
14
|
+
int has_aesni;
|
13
15
|
} CPUFeatures;
|
14
16
|
|
15
17
|
static CPUFeatures _cpu_features;
|
16
18
|
|
17
|
-
#define CPUID_SSE2
|
18
|
-
#define CPUIDECX_SSE3
|
19
|
+
#define CPUID_SSE2 0x04000000
|
20
|
+
#define CPUIDECX_SSE3 0x00000001
|
21
|
+
#define CPUIDECX_PCLMUL 0x00000002
|
22
|
+
#define CPUIDECX_AESNI 0x02000000
|
19
23
|
|
20
24
|
static int
|
21
25
|
_sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features)
|
@@ -43,7 +47,8 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features)
|
|
43
47
|
static void
|
44
48
|
_cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type)
|
45
49
|
{
|
46
|
-
#
|
50
|
+
#if defined(_MSC_VER) && \
|
51
|
+
(defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))
|
47
52
|
__cpuid((int *) cpu_info, cpu_info_type);
|
48
53
|
#elif defined(HAVE_CPUID)
|
49
54
|
cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
|
@@ -103,6 +108,14 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
|
103
108
|
cpu_features->has_sse3 = ((cpu_info[2] & CPUIDECX_SSE3) != 0x0);
|
104
109
|
#endif
|
105
110
|
|
111
|
+
#ifndef HAVE_WMMINTRIN_H
|
112
|
+
cpu_features->has_pclmul = 0;
|
113
|
+
cpu_features->has_aesni = 0;
|
114
|
+
#else
|
115
|
+
cpu_features->has_pclmul = ((cpu_info[2] & CPUIDECX_PCLMUL) != 0x0);
|
116
|
+
cpu_features->has_aesni = ((cpu_info[2] & CPUIDECX_AESNI) != 0x0);
|
117
|
+
#endif
|
118
|
+
|
106
119
|
return 0;
|
107
120
|
}
|
108
121
|
|
@@ -132,3 +145,13 @@ int
|
|
132
145
|
sodium_runtime_has_sse3(void) {
|
133
146
|
return _cpu_features.has_sse3;
|
134
147
|
}
|
148
|
+
|
149
|
+
int
|
150
|
+
sodium_runtime_has_pclmul(void) {
|
151
|
+
return _cpu_features.has_pclmul;
|
152
|
+
}
|
153
|
+
|
154
|
+
int
|
155
|
+
sodium_runtime_has_aesni(void) {
|
156
|
+
return _cpu_features.has_aesni;
|
157
|
+
}
|
@@ -23,6 +23,10 @@
|
|
23
23
|
# include <unistd.h>
|
24
24
|
#endif
|
25
25
|
|
26
|
+
#if defined(_WIN32) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
|
27
|
+
# define WINAPI_DESKTOP
|
28
|
+
#endif
|
29
|
+
|
26
30
|
#define CANARY_SIZE 16U
|
27
31
|
#define GARBAGE_VALUE 0xd0
|
28
32
|
|
@@ -32,13 +36,13 @@
|
|
32
36
|
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
|
33
37
|
# define MAP_ANON MAP_ANONYMOUS
|
34
38
|
#endif
|
35
|
-
#if defined(
|
39
|
+
#if defined(WINAPI_DESKTOP) || (defined(MAP_ANON) && defined(HAVE_MMAP)) || defined(HAVE_POSIX_MEMALIGN)
|
36
40
|
# define HAVE_ALIGNED_MALLOC
|
37
41
|
#endif
|
38
42
|
#if defined(HAVE_MPROTECT) && !(defined(PROT_NONE) && defined(PROT_READ) && defined(PROT_WRITE))
|
39
43
|
# undef HAVE_MPROTECT
|
40
44
|
#endif
|
41
|
-
#if defined(HAVE_ALIGNED_MALLOC) && (defined(
|
45
|
+
#if defined(HAVE_ALIGNED_MALLOC) && (defined(WINAPI_DESKTOP) || defined(HAVE_MPROTECT))
|
42
46
|
# define HAVE_PAGE_PROTECTION
|
43
47
|
#endif
|
44
48
|
|
@@ -47,7 +51,7 @@ static unsigned char canary[CANARY_SIZE];
|
|
47
51
|
|
48
52
|
#ifdef HAVE_WEAK_SYMBOLS
|
49
53
|
__attribute__((weak)) void
|
50
|
-
|
54
|
+
_sodium_dummy_symbol_to_prevent_memzero_lto(void * const pnt, const size_t len)
|
51
55
|
{
|
52
56
|
(void) pnt;
|
53
57
|
(void) len;
|
@@ -67,7 +71,7 @@ sodium_memzero(void * const pnt, const size_t len)
|
|
67
71
|
explicit_bzero(pnt, len);
|
68
72
|
#elif HAVE_WEAK_SYMBOLS
|
69
73
|
memset(pnt, 0, len);
|
70
|
-
|
74
|
+
_sodium_dummy_symbol_to_prevent_memzero_lto(pnt, len);
|
71
75
|
#else
|
72
76
|
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
|
73
77
|
size_t i = (size_t) 0U;
|
@@ -78,20 +82,76 @@ sodium_memzero(void * const pnt, const size_t len)
|
|
78
82
|
#endif
|
79
83
|
}
|
80
84
|
|
85
|
+
#ifdef HAVE_WEAK_SYMBOLS
|
86
|
+
__attribute__((weak)) void
|
87
|
+
_sodium_dummy_symbol_to_prevent_memcmp_lto(const unsigned char *b1,
|
88
|
+
const unsigned char *b2,
|
89
|
+
const size_t len)
|
90
|
+
{
|
91
|
+
(void) b1;
|
92
|
+
(void) b2;
|
93
|
+
(void) len;
|
94
|
+
}
|
95
|
+
#endif
|
96
|
+
|
81
97
|
int
|
82
98
|
sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
83
99
|
{
|
100
|
+
#ifdef HAVE_WEAK_SYMBOLS
|
84
101
|
const unsigned char *b1 = (const unsigned char *) b1_;
|
85
102
|
const unsigned char *b2 = (const unsigned char *) b2_;
|
103
|
+
#else
|
104
|
+
const volatile unsigned char *b1 = (const volatile unsigned char *) b1_;
|
105
|
+
const volatile unsigned char *b2 = (const volatile unsigned char *) b2_;
|
106
|
+
#endif
|
86
107
|
size_t i;
|
87
108
|
unsigned char d = (unsigned char) 0U;
|
88
109
|
|
110
|
+
#if HAVE_WEAK_SYMBOLS
|
111
|
+
_sodium_dummy_symbol_to_prevent_memcmp_lto(b1, b2, len);
|
112
|
+
#endif
|
89
113
|
for (i = 0U; i < len; i++) {
|
90
114
|
d |= b1[i] ^ b2[i];
|
91
115
|
}
|
92
116
|
return (int) ((1 & ((d - 1) >> 8)) - 1);
|
93
117
|
}
|
94
118
|
|
119
|
+
#ifdef HAVE_WEAK_SYMBOLS
|
120
|
+
__attribute__((weak)) void
|
121
|
+
_sodium_dummy_symbol_to_prevent_compare_lto(const unsigned char *b1,
|
122
|
+
const unsigned char *b2,
|
123
|
+
const size_t len)
|
124
|
+
{
|
125
|
+
(void) b1;
|
126
|
+
(void) b2;
|
127
|
+
(void) len;
|
128
|
+
}
|
129
|
+
#endif
|
130
|
+
|
131
|
+
int
|
132
|
+
sodium_compare(const unsigned char *b1_, const unsigned char *b2_, size_t len)
|
133
|
+
{
|
134
|
+
#ifdef HAVE_WEAK_SYMBOLS
|
135
|
+
const unsigned char *b1 = b1_;
|
136
|
+
const unsigned char *b2 = b2_;
|
137
|
+
#else
|
138
|
+
const volatile unsigned char *b1 = (const volatile unsigned char *) b1_;
|
139
|
+
const volatile unsigned char *b2 = (const volatile unsigned char *) b2_;
|
140
|
+
#endif
|
141
|
+
unsigned char gt = 0U;
|
142
|
+
unsigned char eq = 1U;
|
143
|
+
size_t i;
|
144
|
+
|
145
|
+
#if HAVE_WEAK_SYMBOLS
|
146
|
+
_sodium_dummy_symbol_to_prevent_compare_lto(b1, b2, len);
|
147
|
+
#endif
|
148
|
+
for (i = (size_t) 0U; i < len; i++) {
|
149
|
+
gt |= ((b2[i] - b1[i]) >> 8) & eq;
|
150
|
+
eq &= ((b2[i] ^ b1[i]) - 1) >> 8;
|
151
|
+
}
|
152
|
+
return (int) (gt + gt + eq) - 1;
|
153
|
+
}
|
154
|
+
|
95
155
|
/* Derived from original code by CodesInChaos */
|
96
156
|
char *
|
97
157
|
sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
@@ -102,7 +162,7 @@ sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
|
102
162
|
int b;
|
103
163
|
int c;
|
104
164
|
|
105
|
-
if (bin_len >= SIZE_MAX / 2 || hex_maxlen
|
165
|
+
if (bin_len >= SIZE_MAX / 2 || hex_maxlen <= bin_len * 2U) {
|
106
166
|
abort(); /* LCOV_EXCL_LINE */
|
107
167
|
}
|
108
168
|
while (i < bin_len) {
|
@@ -184,7 +244,7 @@ _sodium_alloc_init(void)
|
|
184
244
|
if (page_size_ > 0L) {
|
185
245
|
page_size = (size_t) page_size_;
|
186
246
|
}
|
187
|
-
# elif defined(
|
247
|
+
# elif defined(WINAPI_DESKTOP)
|
188
248
|
SYSTEM_INFO si;
|
189
249
|
GetSystemInfo(&si);
|
190
250
|
page_size = (size_t) si.dwPageSize;
|
@@ -206,7 +266,7 @@ sodium_mlock(void * const addr, const size_t len)
|
|
206
266
|
#endif
|
207
267
|
#ifdef HAVE_MLOCK
|
208
268
|
return mlock(addr, len);
|
209
|
-
#elif defined(
|
269
|
+
#elif defined(WINAPI_DESKTOP)
|
210
270
|
return -(VirtualLock(addr, len) == 0);
|
211
271
|
#else
|
212
272
|
errno = ENOSYS;
|
@@ -223,7 +283,7 @@ sodium_munlock(void * const addr, const size_t len)
|
|
223
283
|
#endif
|
224
284
|
#ifdef HAVE_MLOCK
|
225
285
|
return munlock(addr, len);
|
226
|
-
#elif defined(
|
286
|
+
#elif defined(WINAPI_DESKTOP)
|
227
287
|
return -(VirtualUnlock(addr, len) == 0);
|
228
288
|
#else
|
229
289
|
errno = ENOSYS;
|
@@ -236,7 +296,7 @@ _mprotect_noaccess(void *ptr, size_t size)
|
|
236
296
|
{
|
237
297
|
#ifdef HAVE_MPROTECT
|
238
298
|
return mprotect(ptr, size, PROT_NONE);
|
239
|
-
#elif defined(
|
299
|
+
#elif defined(WINAPI_DESKTOP)
|
240
300
|
DWORD old;
|
241
301
|
return -(VirtualProtect(ptr, size, PAGE_NOACCESS, &old) == 0);
|
242
302
|
#else
|
@@ -250,7 +310,7 @@ _mprotect_readonly(void *ptr, size_t size)
|
|
250
310
|
{
|
251
311
|
#ifdef HAVE_MPROTECT
|
252
312
|
return mprotect(ptr, size, PROT_READ);
|
253
|
-
#elif defined(
|
313
|
+
#elif defined(WINAPI_DESKTOP)
|
254
314
|
DWORD old;
|
255
315
|
return -(VirtualProtect(ptr, size, PAGE_READONLY, &old) == 0);
|
256
316
|
#else
|
@@ -264,7 +324,7 @@ _mprotect_readwrite(void *ptr, size_t size)
|
|
264
324
|
{
|
265
325
|
#ifdef HAVE_MPROTECT
|
266
326
|
return mprotect(ptr, size, PROT_READ | PROT_WRITE);
|
267
|
-
#elif defined(
|
327
|
+
#elif defined(WINAPI_DESKTOP)
|
268
328
|
DWORD old;
|
269
329
|
return -(VirtualProtect(ptr, size, PAGE_READWRITE, &old) == 0);
|
270
330
|
#else
|
@@ -308,7 +368,7 @@ _alloc_aligned(const size_t size)
|
|
308
368
|
if (posix_memalign(&ptr, page_size, size) != 0) {
|
309
369
|
ptr = NULL; /* LCOV_EXCL_LINE */
|
310
370
|
} /* LCOV_EXCL_LINE */
|
311
|
-
# elif defined(
|
371
|
+
# elif defined(WINAPI_DESKTOP)
|
312
372
|
ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
313
373
|
# else
|
314
374
|
# error Bug
|
@@ -323,7 +383,7 @@ _free_aligned(unsigned char * const ptr, const size_t size)
|
|
323
383
|
(void) munmap(ptr, size);
|
324
384
|
# elif defined(HAVE_POSIX_MEMALIGN)
|
325
385
|
free(ptr);
|
326
|
-
# elif defined(
|
386
|
+
# elif defined(WINAPI_DESKTOP)
|
327
387
|
VirtualFree(ptr, 0U, MEM_RELEASE);
|
328
388
|
# else
|
329
389
|
# error Bug
|
@@ -506,3 +566,16 @@ sodium_mprotect_readwrite(void *ptr)
|
|
506
566
|
{
|
507
567
|
return _sodium_mprotect(ptr, _mprotect_readwrite);
|
508
568
|
}
|
569
|
+
|
570
|
+
void
|
571
|
+
sodium_increment(unsigned char *n, const size_t nlen)
|
572
|
+
{
|
573
|
+
size_t i;
|
574
|
+
unsigned int c = 1U << 8;
|
575
|
+
|
576
|
+
for (i = (size_t) 0U; i < nlen; i++) {
|
577
|
+
c >>= 8;
|
578
|
+
c += n[i];
|
579
|
+
n[i] = (unsigned char) c;
|
580
|
+
}
|
581
|
+
}
|
@@ -90,6 +90,7 @@ host_triplet = @host@
|
|
90
90
|
subdir = test
|
91
91
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
92
92
|
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
|
93
|
+
$(top_srcdir)/m4/ax_check_define.m4 \
|
93
94
|
$(top_srcdir)/m4/ax_check_link_flag.m4 \
|
94
95
|
$(top_srcdir)/m4/ld-output-def.m4 $(top_srcdir)/m4/libtool.m4 \
|
95
96
|
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
@@ -198,6 +199,13 @@ CCASDEPMODE = @CCASDEPMODE@
|
|
198
199
|
CCASFLAGS = @CCASFLAGS@
|
199
200
|
CCDEPMODE = @CCDEPMODE@
|
200
201
|
CFLAGS = @CFLAGS@
|
202
|
+
CFLAGS_AESNI = @CFLAGS_AESNI@
|
203
|
+
CFLAGS_MMX = @CFLAGS_MMX@
|
204
|
+
CFLAGS_PCLMUL = @CFLAGS_PCLMUL@
|
205
|
+
CFLAGS_SSE2 = @CFLAGS_SSE2@
|
206
|
+
CFLAGS_SSE3 = @CFLAGS_SSE3@
|
207
|
+
CFLAGS_SSE4_1 = @CFLAGS_SSE4_1@
|
208
|
+
CFLAGS_SSSE3 = @CFLAGS_SSSE3@
|
201
209
|
CPP = @CPP@
|
202
210
|
CPPFLAGS = @CPPFLAGS@
|
203
211
|
CWFLAGS = @CWFLAGS@
|
@@ -234,6 +242,7 @@ LIBTOOL_EXTRA_FLAGS = @LIBTOOL_EXTRA_FLAGS@
|
|
234
242
|
LIPO = @LIPO@
|
235
243
|
LN_S = @LN_S@
|
236
244
|
LTLIBOBJS = @LTLIBOBJS@
|
245
|
+
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
237
246
|
MAINT = @MAINT@
|
238
247
|
MAKEINFO = @MAKEINFO@
|
239
248
|
MANIFEST_TOOL = @MANIFEST_TOOL@
|
@@ -3,6 +3,7 @@ EXTRA_DIST = \
|
|
3
3
|
cmptest.h \
|
4
4
|
wintest.bat \
|
5
5
|
pre.js.inc \
|
6
|
+
aead_aes256gcm.exp \
|
6
7
|
aead_chacha20poly1305.exp \
|
7
8
|
auth.exp \
|
8
9
|
auth2.exp \
|
@@ -63,6 +64,7 @@ EXTRA_DIST = \
|
|
63
64
|
verify1.exp
|
64
65
|
|
65
66
|
DISTCLEANFILES = \
|
67
|
+
aead_aes256gcm.res \
|
66
68
|
aead_chacha20poly1305.res \
|
67
69
|
auth.res \
|
68
70
|
auth2.res \
|
@@ -122,6 +124,124 @@ DISTCLEANFILES = \
|
|
122
124
|
stream4.res \
|
123
125
|
verify1.res
|
124
126
|
|
127
|
+
if NATIVECLIENT
|
128
|
+
CLEANFILES = \
|
129
|
+
aead_aes256gcm.final \
|
130
|
+
aead_chacha20poly1305.final \
|
131
|
+
auth.final \
|
132
|
+
auth2.final \
|
133
|
+
auth3.final \
|
134
|
+
auth5.final \
|
135
|
+
auth6.final \
|
136
|
+
auth7.final \
|
137
|
+
box.final \
|
138
|
+
box2.final \
|
139
|
+
box7.final \
|
140
|
+
box8.final \
|
141
|
+
box_easy.final \
|
142
|
+
box_easy2.final \
|
143
|
+
box_seal.final \
|
144
|
+
box_seed.final \
|
145
|
+
chacha20.final \
|
146
|
+
core1.final \
|
147
|
+
core2.final \
|
148
|
+
core3.final \
|
149
|
+
core4.final \
|
150
|
+
core5.final \
|
151
|
+
core6.final \
|
152
|
+
ed25519_convert.final \
|
153
|
+
generichash.final \
|
154
|
+
generichash2.final \
|
155
|
+
generichash3.final \
|
156
|
+
hash.final \
|
157
|
+
hash2.final \
|
158
|
+
hash3.final \
|
159
|
+
onetimeauth.final \
|
160
|
+
onetimeauth2.final \
|
161
|
+
onetimeauth7.final \
|
162
|
+
pwhash.final \
|
163
|
+
pwhash_scrypt_ll.final \
|
164
|
+
randombytes.final \
|
165
|
+
scalarmult.final \
|
166
|
+
scalarmult2.final \
|
167
|
+
scalarmult5.final \
|
168
|
+
scalarmult6.final \
|
169
|
+
scalarmult7.final \
|
170
|
+
secretbox.final \
|
171
|
+
secretbox2.final \
|
172
|
+
secretbox7.final \
|
173
|
+
secretbox8.final \
|
174
|
+
secretbox_easy.final \
|
175
|
+
secretbox_easy2.final \
|
176
|
+
shorthash.final \
|
177
|
+
sign.final \
|
178
|
+
sodium_core.final \
|
179
|
+
sodium_utils.final \
|
180
|
+
sodium_version.final \
|
181
|
+
stream.final \
|
182
|
+
stream2.final \
|
183
|
+
stream3.final \
|
184
|
+
stream4.final \
|
185
|
+
verify1.final \
|
186
|
+
aead_aes256gcm.nexe \
|
187
|
+
aead_chacha20poly1305.nexe \
|
188
|
+
auth.nexe \
|
189
|
+
auth2.nexe \
|
190
|
+
auth3.nexe \
|
191
|
+
auth5.nexe \
|
192
|
+
auth6.nexe \
|
193
|
+
auth7.nexe \
|
194
|
+
box.nexe \
|
195
|
+
box2.nexe \
|
196
|
+
box7.nexe \
|
197
|
+
box8.nexe \
|
198
|
+
box_easy.nexe \
|
199
|
+
box_easy2.nexe \
|
200
|
+
box_seal.nexe \
|
201
|
+
box_seed.nexe \
|
202
|
+
chacha20.nexe \
|
203
|
+
core1.nexe \
|
204
|
+
core2.nexe \
|
205
|
+
core3.nexe \
|
206
|
+
core4.nexe \
|
207
|
+
core5.nexe \
|
208
|
+
core6.nexe \
|
209
|
+
ed25519_convert.nexe \
|
210
|
+
generichash.nexe \
|
211
|
+
generichash2.nexe \
|
212
|
+
generichash3.nexe \
|
213
|
+
hash.nexe \
|
214
|
+
hash2.nexe \
|
215
|
+
hash3.nexe \
|
216
|
+
onetimeauth.nexe \
|
217
|
+
onetimeauth2.nexe \
|
218
|
+
onetimeauth7.nexe \
|
219
|
+
pwhash.nexe \
|
220
|
+
pwhash_scrypt_ll.nexe \
|
221
|
+
randombytes.nexe \
|
222
|
+
scalarmult.nexe \
|
223
|
+
scalarmult2.nexe \
|
224
|
+
scalarmult5.nexe \
|
225
|
+
scalarmult6.nexe \
|
226
|
+
scalarmult7.nexe \
|
227
|
+
secretbox.nexe \
|
228
|
+
secretbox2.nexe \
|
229
|
+
secretbox7.nexe \
|
230
|
+
secretbox8.nexe \
|
231
|
+
secretbox_easy.nexe \
|
232
|
+
secretbox_easy2.nexe \
|
233
|
+
shorthash.nexe \
|
234
|
+
sign.nexe \
|
235
|
+
sodium_core.nexe \
|
236
|
+
sodium_utils.nexe \
|
237
|
+
sodium_version.nexe \
|
238
|
+
stream.nexe \
|
239
|
+
stream2.nexe \
|
240
|
+
stream3.nexe \
|
241
|
+
stream4.nexe \
|
242
|
+
verify1.nexe
|
243
|
+
endif
|
244
|
+
|
125
245
|
AM_CPPFLAGS = \
|
126
246
|
-DTEST_SRCDIR=\"@srcdir@\" \
|
127
247
|
-I$(top_srcdir)/src/libsodium/include \
|
@@ -133,6 +253,7 @@ AM_CPPFLAGS = \
|
|
133
253
|
AM_LDFLAGS = @TEST_LDFLAGS@
|
134
254
|
|
135
255
|
TESTS_TARGETS = \
|
256
|
+
aead_aes256gcm \
|
136
257
|
aead_chacha20poly1305 \
|
137
258
|
auth \
|
138
259
|
auth2 \
|
@@ -190,10 +311,12 @@ TESTS_TARGETS = \
|
|
190
311
|
verify1
|
191
312
|
|
192
313
|
if !EMSCRIPTEN
|
314
|
+
if !NATIVECLIENT
|
193
315
|
TESTS_TARGETS += \
|
194
316
|
sodium_utils2 \
|
195
317
|
sodium_utils3
|
196
318
|
endif
|
319
|
+
endif
|
197
320
|
|
198
321
|
check_PROGRAMS = $(TESTS_TARGETS)
|
199
322
|
|
@@ -202,6 +325,9 @@ TESTS = $(TESTS_TARGETS)
|
|
202
325
|
TESTS_LDADD = \
|
203
326
|
${top_builddir}/src/libsodium/libsodium.la
|
204
327
|
|
328
|
+
aead_aes256gcm_SOURCE = cmptest.h aead_aes256gcm.c
|
329
|
+
aead_aes256gcm_LDADD = $(TESTS_LDADD)
|
330
|
+
|
205
331
|
aead_chacha20poly1305_SOURCE = cmptest.h aead_chacha20poly1305.c
|
206
332
|
aead_chacha20poly1305_LDADD = $(TESTS_LDADD)
|
207
333
|
|
@@ -373,4 +499,8 @@ stream4_LDADD = $(TESTS_LDADD)
|
|
373
499
|
verify1_SOURCE = cmptest.h verify1.c
|
374
500
|
verify1_LDADD = $(TESTS_LDADD)
|
375
501
|
|
502
|
+
if NATIVECLIENT
|
503
|
+
LOG_COMPILER = ./nacl-test-wrapper.sh
|
504
|
+
endif
|
505
|
+
|
376
506
|
verify: check
|