rbnacl-libsodium 0.7.0 → 1.0.0
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/ChangeLog +13 -0
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +14 -90
- data/vendor/libsodium/autom4te.cache/output.3 +14 -90
- data/vendor/libsodium/autom4te.cache/requests +127 -127
- data/vendor/libsodium/autom4te.cache/traces.1 +224 -224
- data/vendor/libsodium/autom4te.cache/traces.3 +137 -144
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/configure +14 -90
- data/vendor/libsodium/configure.ac +5 -12
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/packaging/nuget/package.nuspec +25 -25
- data/vendor/libsodium/packaging/nuget/package.targets +20 -20
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +9 -4
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +13 -13
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +28 -27
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +16 -12
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +7 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +3 -2
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +10 -8
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +13 -8
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -8
- data/vendor/libsodium/src/libsodium/sodium/core.c +1 -1
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +3 -3
- data/vendor/libsodium/src/libsodium/sodium/utils.c +12 -12
- data/vendor/libsodium/test/default/Makefile.am +9 -1
- data/vendor/libsodium/test/default/Makefile.in +35 -13
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +37 -31
- data/vendor/libsodium/test/default/auth.c +48 -9
- data/vendor/libsodium/test/default/auth.exp +18 -0
- data/vendor/libsodium/test/default/auth2.c +19 -24
- data/vendor/libsodium/test/default/auth3.c +17 -25
- data/vendor/libsodium/test/default/auth5.c +24 -24
- data/vendor/libsodium/test/default/auth6.c +9 -8
- data/vendor/libsodium/test/default/auth7.c +24 -24
- data/vendor/libsodium/test/default/box.c +74 -51
- data/vendor/libsodium/test/default/box.exp +19 -0
- data/vendor/libsodium/test/default/box2.c +48 -51
- data/vendor/libsodium/test/default/box2.exp +17 -0
- data/vendor/libsodium/test/default/box7.c +20 -18
- data/vendor/libsodium/test/default/box8.c +27 -25
- data/vendor/libsodium/test/default/box_easy.c +32 -42
- data/vendor/libsodium/test/default/box_easy2.c +3 -5
- data/vendor/libsodium/test/default/box_seed.c +20 -20
- data/vendor/libsodium/test/default/chacha20.c +41 -21
- data/vendor/libsodium/test/default/chacha20.exp +8 -5
- data/vendor/libsodium/test/default/cmptest.h +4 -0
- data/vendor/libsodium/test/default/core1.c +26 -19
- data/vendor/libsodium/test/default/core2.c +24 -23
- data/vendor/libsodium/test/default/core3.c +30 -26
- data/vendor/libsodium/test/default/core4.c +22 -23
- data/vendor/libsodium/test/default/core5.c +18 -22
- data/vendor/libsodium/test/default/core6.c +33 -34
- data/vendor/libsodium/test/default/ed25519_convert.c +16 -20
- data/vendor/libsodium/test/default/generichash.c +59 -15
- data/vendor/libsodium/test/default/generichash.exp +2 -0
- data/vendor/libsodium/test/default/generichash2.c +30 -13
- data/vendor/libsodium/test/default/generichash3.c +156 -22
- data/vendor/libsodium/test/default/generichash3.exp +11 -0
- data/vendor/libsodium/test/default/hash.c +31 -6
- data/vendor/libsodium/test/default/hash.exp +3 -0
- data/vendor/libsodium/test/default/hash3.c +10 -7
- data/vendor/libsodium/test/default/onetimeauth.c +46 -34
- data/vendor/libsodium/test/default/onetimeauth.exp +2 -0
- data/vendor/libsodium/test/default/onetimeauth2.c +20 -32
- data/vendor/libsodium/test/default/onetimeauth7.c +24 -24
- data/vendor/libsodium/test/default/pwhash.c +276 -68
- data/vendor/libsodium/test/default/pwhash.exp +20 -0
- data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +31 -37
- data/vendor/libsodium/test/default/randombytes.c +85 -8
- data/vendor/libsodium/test/default/randombytes.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult.c +28 -15
- data/vendor/libsodium/test/default/scalarmult2.c +20 -15
- data/vendor/libsodium/test/default/scalarmult5.c +24 -21
- data/vendor/libsodium/test/default/scalarmult6.c +24 -21
- data/vendor/libsodium/test/default/scalarmult7.c +31 -0
- data/vendor/libsodium/test/default/scalarmult7.exp +1 -0
- data/vendor/libsodium/test/default/secretbox.c +50 -45
- data/vendor/libsodium/test/default/secretbox2.c +32 -45
- data/vendor/libsodium/test/default/secretbox7.c +19 -17
- data/vendor/libsodium/test/default/secretbox8.c +26 -24
- data/vendor/libsodium/test/default/secretbox_easy.c +46 -52
- data/vendor/libsodium/test/default/secretbox_easy2.c +3 -5
- data/vendor/libsodium/test/default/shorthash.c +17 -10
- data/vendor/libsodium/test/default/sign.c +74 -39
- data/vendor/libsodium/test/default/sodium_core.c +6 -3
- data/vendor/libsodium/test/default/sodium_utils.c +57 -28
- data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
- data/vendor/libsodium/test/default/sodium_utils2.c +13 -11
- data/vendor/libsodium/test/default/sodium_utils3.c +5 -10
- data/vendor/libsodium/test/default/sodium_version.c +4 -5
- data/vendor/libsodium/test/default/stream.c +23 -17
- data/vendor/libsodium/test/default/stream2.c +17 -15
- data/vendor/libsodium/test/default/stream3.c +17 -19
- data/vendor/libsodium/test/default/stream4.c +36 -45
- data/vendor/libsodium/test/default/verify1.c +20 -18
- metadata +5 -3
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +0 -356
@@ -83,12 +83,12 @@ safe_read(const int fd, void * const buf_, size_t count)
|
|
83
83
|
assert(count > (size_t) 0U);
|
84
84
|
do {
|
85
85
|
while ((readnb = read(fd, buf, count)) < (ssize_t) 0 &&
|
86
|
-
errno == EINTR);
|
86
|
+
errno == EINTR); /* LCOV_EXCL_LINE */
|
87
87
|
if (readnb < (ssize_t) 0) {
|
88
|
-
return readnb;
|
88
|
+
return readnb; /* LCOV_EXCL_LINE */
|
89
89
|
}
|
90
90
|
if (readnb == (ssize_t) 0) {
|
91
|
-
break;
|
91
|
+
break; /* LCOV_EXCL_LINE */
|
92
92
|
}
|
93
93
|
count -= (size_t) readnb;
|
94
94
|
buf += readnb;
|
@@ -102,6 +102,7 @@ safe_read(const int fd, void * const buf_, size_t count)
|
|
102
102
|
static int
|
103
103
|
randombytes_sysrandom_random_dev_open(void)
|
104
104
|
{
|
105
|
+
/* LCOV_EXCL_START */
|
105
106
|
struct stat st;
|
106
107
|
static const char *devices[] = {
|
107
108
|
# ifndef USE_BLOCKING_RANDOM
|
@@ -123,6 +124,7 @@ randombytes_sysrandom_random_dev_open(void)
|
|
123
124
|
} while (*device != NULL);
|
124
125
|
|
125
126
|
return -1;
|
127
|
+
/* LCOV_EXCL_STOP */
|
126
128
|
}
|
127
129
|
|
128
130
|
static void
|
@@ -132,7 +134,7 @@ randombytes_sysrandom_init(void)
|
|
132
134
|
|
133
135
|
if ((stream.random_data_source_fd =
|
134
136
|
randombytes_sysrandom_random_dev_open()) == -1) {
|
135
|
-
abort();
|
137
|
+
abort(); /* LCOV_EXCL_LINE */
|
136
138
|
}
|
137
139
|
errno = errno_save;
|
138
140
|
}
|
@@ -203,14 +205,14 @@ randombytes_sysrandom_buf(void * const buf, const size_t size)
|
|
203
205
|
#endif
|
204
206
|
#ifndef _WIN32
|
205
207
|
if (safe_read(stream.random_data_source_fd, buf, size) != (ssize_t) size) {
|
206
|
-
abort();
|
208
|
+
abort(); /* LCOV_EXCL_LINE */
|
207
209
|
}
|
208
210
|
#else
|
209
211
|
if (size > 0xffffffff) {
|
210
|
-
abort();
|
212
|
+
abort(); /* LCOV_EXCL_LINE */
|
211
213
|
}
|
212
214
|
if (! RtlGenRandom((PVOID) buf, (ULONG) size)) {
|
213
|
-
abort();
|
215
|
+
abort(); /* LCOV_EXCL_LINE */
|
214
216
|
}
|
215
217
|
#endif
|
216
218
|
}
|
@@ -235,7 +237,7 @@ randombytes_sysrandom_uniform(const uint32_t upper_bound)
|
|
235
237
|
if (r >= min) {
|
236
238
|
break;
|
237
239
|
}
|
238
|
-
}
|
240
|
+
} /* LCOV_EXCL_LINE */
|
239
241
|
return r % upper_bound;
|
240
242
|
}
|
241
243
|
|
@@ -44,7 +44,7 @@ static void
|
|
44
44
|
_cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type)
|
45
45
|
{
|
46
46
|
#ifdef _MSC_VER
|
47
|
-
|
47
|
+
__cpuid((int *) cpu_info, cpu_info_type);
|
48
48
|
#elif defined(HAVE_CPUID)
|
49
49
|
cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
|
50
50
|
# ifdef __i386__
|
@@ -56,7 +56,7 @@ _cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type)
|
|
56
56
|
"=&r" (cpu_info[0]), "=&r" (cpu_info[1]) :
|
57
57
|
"i" (0x200000));
|
58
58
|
if (((cpu_info[0] ^ cpu_info[1]) & 0x200000) == 0x0) {
|
59
|
-
return;
|
59
|
+
return; /* LCOV_EXCL_LINE */
|
60
60
|
}
|
61
61
|
# endif
|
62
62
|
# ifdef __i386__
|
@@ -88,7 +88,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
|
88
88
|
|
89
89
|
_cpuid(cpu_info, 0x0);
|
90
90
|
if ((id = cpu_info[0]) == 0U) {
|
91
|
-
return -1;
|
91
|
+
return -1; /* LCOV_EXCL_LINE */
|
92
92
|
}
|
93
93
|
_cpuid(cpu_info, 0x00000001);
|
94
94
|
#ifndef HAVE_EMMINTRIN_H
|
@@ -61,7 +61,7 @@ sodium_memzero(void * const pnt, const size_t len)
|
|
61
61
|
SecureZeroMemory(pnt, len);
|
62
62
|
#elif defined(HAVE_MEMSET_S)
|
63
63
|
if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
|
64
|
-
abort();
|
64
|
+
abort(); /* LCOV_EXCL_LINE */
|
65
65
|
}
|
66
66
|
#elif defined(HAVE_EXPLICIT_BZERO)
|
67
67
|
explicit_bzero(pnt, len);
|
@@ -104,7 +104,7 @@ sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
|
104
104
|
size_t j = (size_t) 0U;
|
105
105
|
|
106
106
|
if (bin_len >= SIZE_MAX / 2 || hex_maxlen < bin_len * 2U) {
|
107
|
-
abort();
|
107
|
+
abort(); /* LCOV_EXCL_LINE */
|
108
108
|
}
|
109
109
|
while (i < bin_len) {
|
110
110
|
hex[j++] = hexdigits[bin[i] >> 4];
|
@@ -215,7 +215,7 @@ _sodium_alloc_init(void)
|
|
215
215
|
page_size = (size_t) si.dwPageSize;
|
216
216
|
#endif
|
217
217
|
if (page_size < CANARY_SIZE) {
|
218
|
-
abort();
|
218
|
+
abort(); /* LCOV_EXCL_LINE */
|
219
219
|
}
|
220
220
|
randombytes_buf(canary, sizeof canary);
|
221
221
|
|
@@ -287,7 +287,7 @@ _out_of_bounds(void)
|
|
287
287
|
raise(SIGKILL);
|
288
288
|
#endif
|
289
289
|
abort();
|
290
|
-
}
|
290
|
+
} /* LCOV_EXCL_LINE */
|
291
291
|
|
292
292
|
static __attribute__((malloc)) unsigned char *
|
293
293
|
_alloc_aligned(const size_t size)
|
@@ -297,12 +297,12 @@ _alloc_aligned(const size_t size)
|
|
297
297
|
#ifdef MAP_ANON
|
298
298
|
if ((ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
|
299
299
|
MAP_ANON | MAP_PRIVATE | MAP_NOCORE, -1, 0)) == MAP_FAILED) {
|
300
|
-
ptr = NULL;
|
301
|
-
}
|
300
|
+
ptr = NULL; /* LCOV_EXCL_LINE */
|
301
|
+
} /* LCOV_EXCL_LINE */
|
302
302
|
#elif defined(HAVE_POSIX_MEMALIGN)
|
303
303
|
if (posix_memalign(&ptr, page_size, size) != 0) {
|
304
|
-
ptr = NULL;
|
305
|
-
}
|
304
|
+
ptr = NULL; /* LCOV_EXCL_LINE */
|
305
|
+
} /* LCOV_EXCL_LINE */
|
306
306
|
#elif defined(_WIN32)
|
307
307
|
ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
308
308
|
#elif !defined(HAVE_ALIGNED_MALLOC)
|
@@ -338,7 +338,7 @@ _unprotected_ptr_from_user_ptr(const void *ptr)
|
|
338
338
|
page_mask = page_size - 1U;
|
339
339
|
unprotected_ptr_u = ((uintptr_t) canary_ptr & (uintptr_t) ~page_mask);
|
340
340
|
if (unprotected_ptr_u <= page_size * 2U) {
|
341
|
-
abort();
|
341
|
+
abort(); /* LCOV_EXCL_LINE */
|
342
342
|
}
|
343
343
|
return (unsigned char *) unprotected_ptr_u;
|
344
344
|
}
|
@@ -360,13 +360,13 @@ _sodium_malloc(const size_t size)
|
|
360
360
|
return NULL;
|
361
361
|
}
|
362
362
|
if (page_size <= sizeof canary || page_size < sizeof unprotected_size) {
|
363
|
-
abort();
|
363
|
+
abort(); /* LCOV_EXCL_LINE */
|
364
364
|
}
|
365
365
|
size_with_canary = (sizeof canary) + size;
|
366
366
|
unprotected_size = _page_round(size_with_canary);
|
367
367
|
total_size = page_size + page_size + unprotected_size + page_size;
|
368
368
|
if ((base_ptr = _alloc_aligned(total_size)) == NULL) {
|
369
|
-
return NULL;
|
369
|
+
return NULL; /* LCOV_EXCL_LINE */
|
370
370
|
}
|
371
371
|
unprotected_ptr = base_ptr + page_size * 2U;
|
372
372
|
_mprotect_noaccess(base_ptr + page_size, page_size);
|
@@ -393,7 +393,7 @@ sodium_malloc(const size_t size)
|
|
393
393
|
void *ptr;
|
394
394
|
|
395
395
|
if ((ptr = _sodium_malloc(size)) == NULL) {
|
396
|
-
return NULL;
|
396
|
+
return NULL; /* LCOV_EXCL_LINE */
|
397
397
|
}
|
398
398
|
memset(ptr, (int) GARBAGE_VALUE, size);
|
399
399
|
|
@@ -35,10 +35,12 @@ EXTRA_DIST = \
|
|
35
35
|
onetimeauth7.exp \
|
36
36
|
pwhash.exp \
|
37
37
|
pwhash_scrypt_ll.exp \
|
38
|
+
randombytes.exp \
|
38
39
|
scalarmult.exp \
|
39
40
|
scalarmult2.exp \
|
40
41
|
scalarmult5.exp \
|
41
42
|
scalarmult6.exp \
|
43
|
+
scalarmult7.exp \
|
42
44
|
secretbox.exp \
|
43
45
|
secretbox2.exp \
|
44
46
|
secretbox7.exp \
|
@@ -92,10 +94,12 @@ DISTCLEANFILES = \
|
|
92
94
|
onetimeauth7.res \
|
93
95
|
pwhash.res \
|
94
96
|
pwhash_scrypt_ll.res \
|
97
|
+
randombytes.res \
|
95
98
|
scalarmult.res \
|
96
99
|
scalarmult2.res \
|
97
100
|
scalarmult5.res \
|
98
101
|
scalarmult6.res \
|
102
|
+
scalarmult7.res \
|
99
103
|
secretbox.res \
|
100
104
|
secretbox2.res \
|
101
105
|
secretbox7.res \
|
@@ -161,6 +165,7 @@ TESTS_TARGETS = \
|
|
161
165
|
scalarmult2 \
|
162
166
|
scalarmult5 \
|
163
167
|
scalarmult6 \
|
168
|
+
scalarmult7 \
|
164
169
|
secretbox \
|
165
170
|
secretbox2 \
|
166
171
|
secretbox7 \
|
@@ -283,7 +288,7 @@ pwhash_LDADD = $(TESTS_LDADD)
|
|
283
288
|
pwhash_scrypt_ll_SOURCE = cmptest.h pwhash_scrypt_ll.c
|
284
289
|
pwhash_scrypt_ll_LDADD = $(TESTS_LDADD)
|
285
290
|
|
286
|
-
randombytes_SOURCE = randombytes.c
|
291
|
+
randombytes_SOURCE = cmptest.h randombytes.c
|
287
292
|
randombytes_LDADD = $(TESTS_LDADD)
|
288
293
|
|
289
294
|
scalarmult_SOURCE = cmptest.h scalarmult.c
|
@@ -298,6 +303,9 @@ scalarmult5_LDADD = $(TESTS_LDADD)
|
|
298
303
|
scalarmult6_SOURCE = cmptest.h scalarmult6.c
|
299
304
|
scalarmult6_LDADD = $(TESTS_LDADD)
|
300
305
|
|
306
|
+
scalarmult7_SOURCE = cmptest.h scalarmult7.c
|
307
|
+
scalarmult7_LDADD = $(TESTS_LDADD)
|
308
|
+
|
301
309
|
secretbox_SOURCE = cmptest.h secretbox.c
|
302
310
|
secretbox_LDADD = $(TESTS_LDADD)
|
303
311
|
|
@@ -106,8 +106,8 @@ am__EXEEXT_1 = aead_chacha20poly1305$(EXEEXT) auth$(EXEEXT) \
|
|
106
106
|
onetimeauth7$(EXEEXT) pwhash$(EXEEXT) \
|
107
107
|
pwhash_scrypt_ll$(EXEEXT) randombytes$(EXEEXT) \
|
108
108
|
scalarmult$(EXEEXT) scalarmult2$(EXEEXT) scalarmult5$(EXEEXT) \
|
109
|
-
scalarmult6$(EXEEXT)
|
110
|
-
secretbox7$(EXEEXT) secretbox8$(EXEEXT) \
|
109
|
+
scalarmult6$(EXEEXT) scalarmult7$(EXEEXT) secretbox$(EXEEXT) \
|
110
|
+
secretbox2$(EXEEXT) secretbox7$(EXEEXT) secretbox8$(EXEEXT) \
|
111
111
|
secretbox_easy$(EXEEXT) secretbox_easy2$(EXEEXT) \
|
112
112
|
shorthash$(EXEEXT) sign$(EXEEXT) sodium_core$(EXEEXT) \
|
113
113
|
sodium_utils$(EXEEXT) sodium_utils2$(EXEEXT) \
|
@@ -229,6 +229,9 @@ scalarmult5_DEPENDENCIES = $(TESTS_LDADD)
|
|
229
229
|
scalarmult6_SOURCES = scalarmult6.c
|
230
230
|
scalarmult6_OBJECTS = scalarmult6.$(OBJEXT)
|
231
231
|
scalarmult6_DEPENDENCIES = $(TESTS_LDADD)
|
232
|
+
scalarmult7_SOURCES = scalarmult7.c
|
233
|
+
scalarmult7_OBJECTS = scalarmult7.$(OBJEXT)
|
234
|
+
scalarmult7_DEPENDENCIES = $(TESTS_LDADD)
|
232
235
|
secretbox_SOURCES = secretbox.c
|
233
236
|
secretbox_OBJECTS = secretbox.$(OBJEXT)
|
234
237
|
secretbox_DEPENDENCIES = $(TESTS_LDADD)
|
@@ -324,11 +327,11 @@ SOURCES = aead_chacha20poly1305.c auth.c auth2.c auth3.c auth5.c \
|
|
324
327
|
generichash2.c generichash3.c hash.c hash3.c onetimeauth.c \
|
325
328
|
onetimeauth2.c onetimeauth7.c pwhash.c pwhash_scrypt_ll.c \
|
326
329
|
randombytes.c scalarmult.c scalarmult2.c scalarmult5.c \
|
327
|
-
scalarmult6.c
|
328
|
-
secretbox8.c secretbox_easy.c secretbox_easy2.c
|
329
|
-
sign.c sodium_core.c sodium_utils.c
|
330
|
-
sodium_utils3.c sodium_version.c stream.c
|
331
|
-
stream4.c verify1.c
|
330
|
+
scalarmult6.c scalarmult7.c secretbox.c secretbox2.c \
|
331
|
+
secretbox7.c secretbox8.c secretbox_easy.c secretbox_easy2.c \
|
332
|
+
shorthash.c sign.c sodium_core.c sodium_utils.c \
|
333
|
+
sodium_utils2.c sodium_utils3.c sodium_version.c stream.c \
|
334
|
+
stream2.c stream3.c stream4.c verify1.c
|
332
335
|
DIST_SOURCES = aead_chacha20poly1305.c auth.c auth2.c auth3.c auth5.c \
|
333
336
|
auth6.c auth7.c box.c box2.c box7.c box8.c box_easy.c \
|
334
337
|
box_easy2.c box_seed.c chacha20.c core1.c core2.c core3.c \
|
@@ -336,11 +339,11 @@ DIST_SOURCES = aead_chacha20poly1305.c auth.c auth2.c auth3.c auth5.c \
|
|
336
339
|
generichash2.c generichash3.c hash.c hash3.c onetimeauth.c \
|
337
340
|
onetimeauth2.c onetimeauth7.c pwhash.c pwhash_scrypt_ll.c \
|
338
341
|
randombytes.c scalarmult.c scalarmult2.c scalarmult5.c \
|
339
|
-
scalarmult6.c
|
340
|
-
secretbox8.c secretbox_easy.c secretbox_easy2.c
|
341
|
-
sign.c sodium_core.c sodium_utils.c
|
342
|
-
sodium_utils3.c sodium_version.c stream.c
|
343
|
-
stream4.c verify1.c
|
342
|
+
scalarmult6.c scalarmult7.c secretbox.c secretbox2.c \
|
343
|
+
secretbox7.c secretbox8.c secretbox_easy.c secretbox_easy2.c \
|
344
|
+
shorthash.c sign.c sodium_core.c sodium_utils.c \
|
345
|
+
sodium_utils2.c sodium_utils3.c sodium_version.c stream.c \
|
346
|
+
stream2.c stream3.c stream4.c verify1.c
|
344
347
|
am__can_run_installinfo = \
|
345
348
|
case $$AM_UPDATE_INFO_DIR in \
|
346
349
|
n|no|NO) false;; \
|
@@ -737,10 +740,12 @@ EXTRA_DIST = \
|
|
737
740
|
onetimeauth7.exp \
|
738
741
|
pwhash.exp \
|
739
742
|
pwhash_scrypt_ll.exp \
|
743
|
+
randombytes.exp \
|
740
744
|
scalarmult.exp \
|
741
745
|
scalarmult2.exp \
|
742
746
|
scalarmult5.exp \
|
743
747
|
scalarmult6.exp \
|
748
|
+
scalarmult7.exp \
|
744
749
|
secretbox.exp \
|
745
750
|
secretbox2.exp \
|
746
751
|
secretbox7.exp \
|
@@ -794,10 +799,12 @@ DISTCLEANFILES = \
|
|
794
799
|
onetimeauth7.res \
|
795
800
|
pwhash.res \
|
796
801
|
pwhash_scrypt_ll.res \
|
802
|
+
randombytes.res \
|
797
803
|
scalarmult.res \
|
798
804
|
scalarmult2.res \
|
799
805
|
scalarmult5.res \
|
800
806
|
scalarmult6.res \
|
807
|
+
scalarmult7.res \
|
801
808
|
secretbox.res \
|
802
809
|
secretbox2.res \
|
803
810
|
secretbox7.res \
|
@@ -863,6 +870,7 @@ TESTS_TARGETS = \
|
|
863
870
|
scalarmult2 \
|
864
871
|
scalarmult5 \
|
865
872
|
scalarmult6 \
|
873
|
+
scalarmult7 \
|
866
874
|
secretbox \
|
867
875
|
secretbox2 \
|
868
876
|
secretbox7 \
|
@@ -949,7 +957,7 @@ pwhash_SOURCE = cmptest.h pwhash.c
|
|
949
957
|
pwhash_LDADD = $(TESTS_LDADD)
|
950
958
|
pwhash_scrypt_ll_SOURCE = cmptest.h pwhash_scrypt_ll.c
|
951
959
|
pwhash_scrypt_ll_LDADD = $(TESTS_LDADD)
|
952
|
-
randombytes_SOURCE = randombytes.c
|
960
|
+
randombytes_SOURCE = cmptest.h randombytes.c
|
953
961
|
randombytes_LDADD = $(TESTS_LDADD)
|
954
962
|
scalarmult_SOURCE = cmptest.h scalarmult.c
|
955
963
|
scalarmult_LDADD = $(TESTS_LDADD)
|
@@ -959,6 +967,8 @@ scalarmult5_SOURCE = cmptest.h scalarmult5.c
|
|
959
967
|
scalarmult5_LDADD = $(TESTS_LDADD)
|
960
968
|
scalarmult6_SOURCE = cmptest.h scalarmult6.c
|
961
969
|
scalarmult6_LDADD = $(TESTS_LDADD)
|
970
|
+
scalarmult7_SOURCE = cmptest.h scalarmult7.c
|
971
|
+
scalarmult7_LDADD = $(TESTS_LDADD)
|
962
972
|
secretbox_SOURCE = cmptest.h secretbox.c
|
963
973
|
secretbox_LDADD = $(TESTS_LDADD)
|
964
974
|
secretbox2_SOURCE = cmptest.h secretbox2.c
|
@@ -1187,6 +1197,10 @@ scalarmult6$(EXEEXT): $(scalarmult6_OBJECTS) $(scalarmult6_DEPENDENCIES) $(EXTRA
|
|
1187
1197
|
@rm -f scalarmult6$(EXEEXT)
|
1188
1198
|
$(AM_V_CCLD)$(LINK) $(scalarmult6_OBJECTS) $(scalarmult6_LDADD) $(LIBS)
|
1189
1199
|
|
1200
|
+
scalarmult7$(EXEEXT): $(scalarmult7_OBJECTS) $(scalarmult7_DEPENDENCIES) $(EXTRA_scalarmult7_DEPENDENCIES)
|
1201
|
+
@rm -f scalarmult7$(EXEEXT)
|
1202
|
+
$(AM_V_CCLD)$(LINK) $(scalarmult7_OBJECTS) $(scalarmult7_LDADD) $(LIBS)
|
1203
|
+
|
1190
1204
|
secretbox$(EXEEXT): $(secretbox_OBJECTS) $(secretbox_DEPENDENCIES) $(EXTRA_secretbox_DEPENDENCIES)
|
1191
1205
|
@rm -f secretbox$(EXEEXT)
|
1192
1206
|
$(AM_V_CCLD)$(LINK) $(secretbox_OBJECTS) $(secretbox_LDADD) $(LIBS)
|
@@ -1302,6 +1316,7 @@ distclean-compile:
|
|
1302
1316
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarmult2.Po@am__quote@
|
1303
1317
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarmult5.Po@am__quote@
|
1304
1318
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarmult6.Po@am__quote@
|
1319
|
+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarmult7.Po@am__quote@
|
1305
1320
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secretbox.Po@am__quote@
|
1306
1321
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secretbox2.Po@am__quote@
|
1307
1322
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secretbox7.Po@am__quote@
|
@@ -1803,6 +1818,13 @@ scalarmult6.log: scalarmult6$(EXEEXT)
|
|
1803
1818
|
--log-file $$b.log --trs-file $$b.trs \
|
1804
1819
|
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
|
1805
1820
|
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
1821
|
+
scalarmult7.log: scalarmult7$(EXEEXT)
|
1822
|
+
@p='scalarmult7$(EXEEXT)'; \
|
1823
|
+
b='scalarmult7'; \
|
1824
|
+
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
|
1825
|
+
--log-file $$b.log --trs-file $$b.trs \
|
1826
|
+
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
|
1827
|
+
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
1806
1828
|
secretbox.log: secretbox$(EXEEXT)
|
1807
1829
|
@p='secretbox$(EXEEXT)'; \
|
1808
1830
|
b='secretbox'; \
|
@@ -1,36 +1,29 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <string.h>
|
3
1
|
|
4
2
|
#define TEST_NAME "aead_chacha20poly1305"
|
5
3
|
#include "cmptest.h"
|
6
4
|
|
7
|
-
static unsigned char firstkey[crypto_aead_chacha20poly1305_KEYBYTES]
|
8
|
-
0x42, 0x90, 0xbc, 0xb1, 0x54, 0x17, 0x35, 0x31,
|
9
|
-
|
10
|
-
|
11
|
-
0x1b, 0x5d, 0xbd, 0xd1, 0x10, 0x0a, 0x10, 0x07
|
12
|
-
};
|
5
|
+
static unsigned char firstkey[crypto_aead_chacha20poly1305_KEYBYTES]
|
6
|
+
= { 0x42, 0x90, 0xbc, 0xb1, 0x54, 0x17, 0x35, 0x31, 0xf3, 0x14, 0xaf,
|
7
|
+
0x57, 0xf3, 0xbe, 0x3b, 0x50, 0x06, 0xda, 0x37, 0x1e, 0xce, 0x27,
|
8
|
+
0x2a, 0xfa, 0x1b, 0x5d, 0xbd, 0xd1, 0x10, 0x0a, 0x10, 0x07 };
|
13
9
|
|
14
|
-
static unsigned char m[10U]
|
15
|
-
0x86, 0xd0, 0x99, 0x74, 0x84, 0x0b, 0xde, 0xd2, 0xa5, 0xca
|
16
|
-
};
|
10
|
+
static unsigned char m[10U]
|
11
|
+
= { 0x86, 0xd0, 0x99, 0x74, 0x84, 0x0b, 0xde, 0xd2, 0xa5, 0xca };
|
17
12
|
|
18
|
-
static unsigned char nonce[crypto_aead_chacha20poly1305_NPUBBYTES]
|
19
|
-
0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a
|
20
|
-
};
|
13
|
+
static unsigned char nonce[crypto_aead_chacha20poly1305_NPUBBYTES]
|
14
|
+
= { 0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a };
|
21
15
|
|
22
|
-
static unsigned char ad[10U]
|
23
|
-
0x87, 0xe2, 0x29, 0xd4, 0x50, 0x08, 0x45, 0xa0, 0x79, 0xc0
|
24
|
-
};
|
16
|
+
static unsigned char ad[10U]
|
17
|
+
= { 0x87, 0xe2, 0x29, 0xd4, 0x50, 0x08, 0x45, 0xa0, 0x79, 0xc0 };
|
25
18
|
|
26
19
|
static unsigned char c[10U + crypto_aead_chacha20poly1305_ABYTES];
|
27
20
|
|
28
21
|
int main(void)
|
29
22
|
{
|
30
|
-
unsigned char
|
23
|
+
unsigned char m2[10U];
|
31
24
|
unsigned long long clen;
|
32
25
|
unsigned long long m2len;
|
33
|
-
size_t
|
26
|
+
size_t i;
|
34
27
|
|
35
28
|
crypto_aead_chacha20poly1305_encrypt(c, &clen, m, sizeof m, ad, sizeof ad,
|
36
29
|
NULL, nonce, firstkey);
|
@@ -38,16 +31,15 @@ int main(void)
|
|
38
31
|
printf("clen is not properly set\n");
|
39
32
|
}
|
40
33
|
for (i = 0U; i < sizeof c; ++i) {
|
41
|
-
printf(",0x%02x", (unsigned int)
|
34
|
+
printf(",0x%02x", (unsigned int)c[i]);
|
42
35
|
if (i % 8 == 7) {
|
43
36
|
printf("\n");
|
44
37
|
}
|
45
38
|
}
|
46
39
|
printf("\n");
|
47
40
|
|
48
|
-
if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, sizeof c,
|
49
|
-
ad,
|
50
|
-
nonce, firstkey) != 0) {
|
41
|
+
if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, sizeof c, ad,
|
42
|
+
sizeof ad, nonce, firstkey) != 0) {
|
51
43
|
printf("crypto_aead_chacha20poly1305_decrypt() failed\n");
|
52
44
|
}
|
53
45
|
if (m2len != sizeof c - crypto_aead_chacha20poly1305_abytes()) {
|
@@ -60,21 +52,20 @@ int main(void)
|
|
60
52
|
for (i = 0U; i < sizeof c; i++) {
|
61
53
|
c[i] ^= (i + 1U);
|
62
54
|
if (crypto_aead_chacha20poly1305_decrypt(m2, NULL, NULL, c, sizeof c,
|
63
|
-
ad, sizeof ad,
|
64
|
-
|
65
|
-
memcmp(m, m2, sizeof m) == 0) {
|
55
|
+
ad, sizeof ad, nonce, firstkey)
|
56
|
+
== 0 || memcmp(m, m2, sizeof m) == 0) {
|
66
57
|
printf("message can be forged\n");
|
67
58
|
}
|
68
59
|
c[i] ^= (i + 1U);
|
69
60
|
}
|
70
61
|
|
71
|
-
crypto_aead_chacha20poly1305_encrypt(c, &clen, m, sizeof m, NULL, 0U,
|
72
|
-
|
62
|
+
crypto_aead_chacha20poly1305_encrypt(c, &clen, m, sizeof m, NULL, 0U, NULL,
|
63
|
+
nonce, firstkey);
|
73
64
|
if (clen != sizeof m + crypto_aead_chacha20poly1305_abytes()) {
|
74
65
|
printf("clen is not properly set (adlen=0)\n");
|
75
66
|
}
|
76
67
|
for (i = 0U; i < sizeof c; ++i) {
|
77
|
-
printf(",0x%02x", (unsigned int)
|
68
|
+
printf(",0x%02x", (unsigned int)c[i]);
|
78
69
|
if (i % 8 == 7) {
|
79
70
|
printf("\n");
|
80
71
|
}
|
@@ -82,8 +73,7 @@ int main(void)
|
|
82
73
|
printf("\n");
|
83
74
|
|
84
75
|
if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, sizeof c,
|
85
|
-
NULL, 0U,
|
86
|
-
nonce, firstkey) != 0) {
|
76
|
+
NULL, 0U, nonce, firstkey) != 0) {
|
87
77
|
printf("crypto_aead_chacha20poly1305_decrypt() failed (adlen=0)\n");
|
88
78
|
}
|
89
79
|
if (m2len != sizeof c - crypto_aead_chacha20poly1305_abytes()) {
|
@@ -93,5 +83,21 @@ int main(void)
|
|
93
83
|
printf("m != m2 (adlen=0)\n");
|
94
84
|
}
|
95
85
|
|
86
|
+
if (crypto_aead_chacha20poly1305_decrypt(
|
87
|
+
m2, &m2len, NULL, c, crypto_aead_chacha20poly1305_ABYTES / 2, NULL,
|
88
|
+
0U, nonce, firstkey) != -1) {
|
89
|
+
printf("crypto_aead_chacha20poly1305_decrypt() worked with a short "
|
90
|
+
"ciphertext\n");
|
91
|
+
}
|
92
|
+
if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, 0U, NULL, 0U,
|
93
|
+
nonce, firstkey) != -1) {
|
94
|
+
printf("crypto_aead_chacha20poly1305_decrypt() worked with an empty "
|
95
|
+
"ciphertext\n");
|
96
|
+
}
|
97
|
+
|
98
|
+
assert(crypto_aead_chacha20poly1305_keybytes() > 0U);
|
99
|
+
assert(crypto_aead_chacha20poly1305_npubbytes() > 0U);
|
100
|
+
assert(crypto_aead_chacha20poly1305_nsecbytes() == 0U);
|
101
|
+
|
96
102
|
return 0;
|
97
103
|
}
|