rbnacl-libsodium 1.0.0 → 1.0.1
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 +10 -0
- data/vendor/libsodium/LICENSE +1 -1
- data/vendor/libsodium/Makefile.in +10 -2
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +52 -17
- data/vendor/libsodium/autom4te.cache/output.3 +52 -17
- data/vendor/libsodium/autom4te.cache/requests +558 -558
- data/vendor/libsodium/autom4te.cache/traces.1 +543 -542
- data/vendor/libsodium/autom4te.cache/traces.3 +320 -319
- data/vendor/libsodium/build-aux/compile +347 -0
- data/vendor/libsodium/build-aux/config.guess +1568 -0
- data/vendor/libsodium/build-aux/config.sub +1793 -0
- data/vendor/libsodium/build-aux/depcomp +791 -0
- data/vendor/libsodium/build-aux/install-sh +527 -0
- data/vendor/libsodium/build-aux/ltmain.sh +9655 -0
- data/vendor/libsodium/build-aux/missing +215 -0
- data/vendor/libsodium/build-aux/test-driver +139 -0
- data/vendor/libsodium/builds/msvc/properties/Common.props +1 -3
- data/vendor/libsodium/builds/msvc/properties/Release.props +3 -1
- data/vendor/libsodium/builds/msvc/resource.rc +0 -0
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +12 -6
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +11 -5
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +12 -6
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +11 -5
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +12 -6
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +11 -5
- data/vendor/libsodium/configure +52 -17
- data/vendor/libsodium/configure.ac +7 -4
- data/vendor/libsodium/dist-build/ios.sh +4 -3
- data/vendor/libsodium/libsodium.vcxproj +4 -4
- 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/Makefile.in +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +8 -8
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +6 -6
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +38 -38
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +8 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +10 -10
- data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/core.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/export.h +3 -3
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +4 -4
- data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +2 -2
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +9 -9
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +9 -9
- data/vendor/libsodium/src/libsodium/sodium/utils.c +17 -15
- data/vendor/libsodium/test/default/Makefile.in +5 -4
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +25 -0
- data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +4 -0
- data/vendor/libsodium/test/default/box_easy2.c +23 -8
- data/vendor/libsodium/test/default/box_easy2.exp +2 -0
- data/vendor/libsodium/test/default/generichash.c +23 -15
- data/vendor/libsodium/test/default/generichash3.c +24 -20
- data/vendor/libsodium/test/default/pwhash.c +27 -28
- data/vendor/libsodium/test/default/scalarmult6.c +19 -3
- data/vendor/libsodium/test/default/secretbox_easy2.c +27 -11
- data/vendor/libsodium/test/default/secretbox_easy2.exp +3 -0
- data/vendor/libsodium/test/default/shorthash.c +15 -10
- data/vendor/libsodium/test/default/sign.c +23 -0
- data/vendor/libsodium/test/default/sodium_utils2.c +4 -0
- data/vendor/libsodium/test/default/sodium_utils3.c +4 -0
- metadata +10 -2
@@ -29,6 +29,10 @@ crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
|
|
29
29
|
|
30
30
|
crypto_core_hsalsa20(subkey, n, k, sigma);
|
31
31
|
|
32
|
+
if (c - m < mlen || c - m > -mlen) {
|
33
|
+
memmove(c, m, mlen);
|
34
|
+
m = c;
|
35
|
+
}
|
32
36
|
memset(block0, 0U, crypto_secretbox_ZEROBYTES);
|
33
37
|
(void) sizeof(int[64U >= crypto_secretbox_ZEROBYTES ? 1 : -1]);
|
34
38
|
mlen0 = mlen;
|
@@ -91,6 +95,10 @@ crypto_secretbox_open_detached(unsigned char *m, const unsigned char *c,
|
|
91
95
|
sodium_memzero(subkey, sizeof subkey);
|
92
96
|
return -1;
|
93
97
|
}
|
98
|
+
if (m - c < clen || m - c > -clen) {
|
99
|
+
memmove(m, c, clen);
|
100
|
+
c = m;
|
101
|
+
}
|
94
102
|
mlen0 = clen;
|
95
103
|
if (mlen0 > 64U - crypto_secretbox_ZEROBYTES) {
|
96
104
|
mlen0 = 64U - crypto_secretbox_ZEROBYTES;
|
@@ -60,14 +60,14 @@ void fe_frombytes(fe h,const unsigned char *s)
|
|
60
60
|
carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
|
61
61
|
carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
|
62
62
|
|
63
|
-
h[0] = h0;
|
64
|
-
h[1] = h1;
|
65
|
-
h[2] = h2;
|
66
|
-
h[3] = h3;
|
67
|
-
h[4] = h4;
|
68
|
-
h[5] = h5;
|
69
|
-
h[6] = h6;
|
70
|
-
h[7] = h7;
|
71
|
-
h[8] = h8;
|
72
|
-
h[9] = h9;
|
63
|
+
h[0] = (crypto_int32) h0;
|
64
|
+
h[1] = (crypto_int32) h1;
|
65
|
+
h[2] = (crypto_int32) h2;
|
66
|
+
h[3] = (crypto_int32) h3;
|
67
|
+
h[4] = (crypto_int32) h4;
|
68
|
+
h[5] = (crypto_int32) h5;
|
69
|
+
h[6] = (crypto_int32) h6;
|
70
|
+
h[7] = (crypto_int32) h7;
|
71
|
+
h[8] = (crypto_int32) h8;
|
72
|
+
h[9] = (crypto_int32) h9;
|
73
73
|
}
|
@@ -240,14 +240,14 @@ void fe_mul(fe h,const fe f,const fe g)
|
|
240
240
|
/* |h0| <= 2^25; from now on fits into int32 unchanged */
|
241
241
|
/* |h1| <= 1.01*2^24 */
|
242
242
|
|
243
|
-
h[0] = h0;
|
244
|
-
h[1] = h1;
|
245
|
-
h[2] = h2;
|
246
|
-
h[3] = h3;
|
247
|
-
h[4] = h4;
|
248
|
-
h[5] = h5;
|
249
|
-
h[6] = h6;
|
250
|
-
h[7] = h7;
|
251
|
-
h[8] = h8;
|
252
|
-
h[9] = h9;
|
243
|
+
h[0] = (crypto_int32) h0;
|
244
|
+
h[1] = (crypto_int32) h1;
|
245
|
+
h[2] = (crypto_int32) h2;
|
246
|
+
h[3] = (crypto_int32) h3;
|
247
|
+
h[4] = (crypto_int32) h4;
|
248
|
+
h[5] = (crypto_int32) h5;
|
249
|
+
h[6] = (crypto_int32) h6;
|
250
|
+
h[7] = (crypto_int32) h7;
|
251
|
+
h[8] = (crypto_int32) h8;
|
252
|
+
h[9] = (crypto_int32) h9;
|
253
253
|
}
|
@@ -136,14 +136,14 @@ void fe_sq(fe h,const fe f)
|
|
136
136
|
|
137
137
|
carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
|
138
138
|
|
139
|
-
h[0] = h0;
|
140
|
-
h[1] = h1;
|
141
|
-
h[2] = h2;
|
142
|
-
h[3] = h3;
|
143
|
-
h[4] = h4;
|
144
|
-
h[5] = h5;
|
145
|
-
h[6] = h6;
|
146
|
-
h[7] = h7;
|
147
|
-
h[8] = h8;
|
148
|
-
h[9] = h9;
|
139
|
+
h[0] = (crypto_int32) h0;
|
140
|
+
h[1] = (crypto_int32) h1;
|
141
|
+
h[2] = (crypto_int32) h2;
|
142
|
+
h[3] = (crypto_int32) h3;
|
143
|
+
h[4] = (crypto_int32) h4;
|
144
|
+
h[5] = (crypto_int32) h5;
|
145
|
+
h[6] = (crypto_int32) h6;
|
146
|
+
h[7] = (crypto_int32) h7;
|
147
|
+
h[8] = (crypto_int32) h8;
|
148
|
+
h[9] = (crypto_int32) h9;
|
149
149
|
}
|
@@ -147,14 +147,14 @@ void fe_sq2(fe h,const fe f)
|
|
147
147
|
|
148
148
|
carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
|
149
149
|
|
150
|
-
h[0] = h0;
|
151
|
-
h[1] = h1;
|
152
|
-
h[2] = h2;
|
153
|
-
h[3] = h3;
|
154
|
-
h[4] = h4;
|
155
|
-
h[5] = h5;
|
156
|
-
h[6] = h6;
|
157
|
-
h[7] = h7;
|
158
|
-
h[8] = h8;
|
159
|
-
h[9] = h9;
|
150
|
+
h[0] = (crypto_int32) h0;
|
151
|
+
h[1] = (crypto_int32) h1;
|
152
|
+
h[2] = (crypto_int32) h2;
|
153
|
+
h[3] = (crypto_int32) h3;
|
154
|
+
h[4] = (crypto_int32) h4;
|
155
|
+
h[5] = (crypto_int32) h5;
|
156
|
+
h[6] = (crypto_int32) h6;
|
157
|
+
h[7] = (crypto_int32) h7;
|
158
|
+
h[8] = (crypto_int32) h8;
|
159
|
+
h[9] = (crypto_int32) h9;
|
160
160
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
#ifndef
|
3
|
-
#define
|
2
|
+
#ifndef sodium_export_H
|
3
|
+
#define sodium_export_H
|
4
4
|
|
5
5
|
#ifndef __GNUC__
|
6
6
|
# ifdef __attribute__
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# define SODIUM_EXPORT
|
14
14
|
#else
|
15
15
|
# if defined(_MSC_VER)
|
16
|
-
# ifdef
|
16
|
+
# ifdef SODIUM_DLL_EXPORT
|
17
17
|
# define SODIUM_EXPORT __declspec(dllexport)
|
18
18
|
# else
|
19
19
|
# define SODIUM_EXPORT __declspec(dllimport)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
#ifndef
|
3
|
-
#define
|
2
|
+
#ifndef sodium_utils_H
|
3
|
+
#define sodium_utils_H
|
4
4
|
|
5
5
|
#include <stddef.h>
|
6
6
|
|
@@ -11,9 +11,9 @@ extern "C" {
|
|
11
11
|
#endif
|
12
12
|
|
13
13
|
#if defined(__cplusplus) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
14
|
-
# define
|
14
|
+
# define SODIUM_C99(X)
|
15
15
|
#else
|
16
|
-
# define
|
16
|
+
# define SODIUM_C99(X) X
|
17
17
|
#endif
|
18
18
|
|
19
19
|
SODIUM_EXPORT
|
@@ -52,9 +52,9 @@ typedef struct Salsa20Random_ {
|
|
52
52
|
} Salsa20Random;
|
53
53
|
|
54
54
|
static Salsa20Random stream = {
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
SODIUM_C99(.random_data_source_fd =) -1,
|
56
|
+
SODIUM_C99(.rnd32_outleft =) (size_t) 0U,
|
57
|
+
SODIUM_C99(.initialized =) 0
|
58
58
|
};
|
59
59
|
|
60
60
|
static uint64_t
|
@@ -335,10 +335,10 @@ randombytes_salsa20_implementation_name(void)
|
|
335
335
|
}
|
336
336
|
|
337
337
|
struct randombytes_implementation randombytes_salsa20_implementation = {
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
338
|
+
SODIUM_C99(.implementation_name =) randombytes_salsa20_implementation_name,
|
339
|
+
SODIUM_C99(.random =) randombytes_salsa20_random,
|
340
|
+
SODIUM_C99(.stir =) randombytes_salsa20_random_stir,
|
341
|
+
SODIUM_C99(.uniform =) randombytes_salsa20_random_uniform,
|
342
|
+
SODIUM_C99(.buf =) randombytes_salsa20_random_buf,
|
343
|
+
SODIUM_C99(.close =) randombytes_salsa20_random_close
|
344
344
|
};
|
@@ -69,8 +69,8 @@ typedef struct SysRandom_ {
|
|
69
69
|
} SysRandom;
|
70
70
|
|
71
71
|
static SysRandom stream = {
|
72
|
-
|
73
|
-
|
72
|
+
SODIUM_C99(.random_data_source_fd =) -1,
|
73
|
+
SODIUM_C99(.initialized =) 0
|
74
74
|
};
|
75
75
|
|
76
76
|
#ifndef _WIN32
|
@@ -208,7 +208,7 @@ randombytes_sysrandom_buf(void * const buf, const size_t size)
|
|
208
208
|
abort(); /* LCOV_EXCL_LINE */
|
209
209
|
}
|
210
210
|
#else
|
211
|
-
if (size > 0xffffffff) {
|
211
|
+
if (size > (size_t) 0xffffffff) {
|
212
212
|
abort(); /* LCOV_EXCL_LINE */
|
213
213
|
}
|
214
214
|
if (! RtlGenRandom((PVOID) buf, (ULONG) size)) {
|
@@ -250,10 +250,10 @@ randombytes_sysrandom_implementation_name(void)
|
|
250
250
|
}
|
251
251
|
|
252
252
|
struct randombytes_implementation randombytes_sysrandom_implementation = {
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
253
|
+
SODIUM_C99(.implementation_name =) randombytes_sysrandom_implementation_name,
|
254
|
+
SODIUM_C99(.random =) randombytes_sysrandom,
|
255
|
+
SODIUM_C99(.stir =) randombytes_sysrandom_stir,
|
256
|
+
SODIUM_C99(.uniform =) randombytes_sysrandom_uniform,
|
257
|
+
SODIUM_C99(.buf =) randombytes_sysrandom_buf,
|
258
|
+
SODIUM_C99(.close =) randombytes_sysrandom_close
|
259
259
|
};
|
@@ -47,7 +47,7 @@ static unsigned char canary[CANARY_SIZE];
|
|
47
47
|
|
48
48
|
#ifdef HAVE_WEAK_SYMBOLS
|
49
49
|
__attribute__((weak)) void
|
50
|
-
|
50
|
+
_sodium_dummy_symbol_to_prevent_lto(void * const pnt, const size_t len)
|
51
51
|
{
|
52
52
|
(void) pnt;
|
53
53
|
(void) len;
|
@@ -67,7 +67,7 @@ sodium_memzero(void * const pnt, const size_t len)
|
|
67
67
|
explicit_bzero(pnt, len);
|
68
68
|
#elif HAVE_WEAK_SYMBOLS
|
69
69
|
memset(pnt, 0, len);
|
70
|
-
|
70
|
+
_sodium_dummy_symbol_to_prevent_lto(pnt, len);
|
71
71
|
#else
|
72
72
|
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
|
73
73
|
size_t i = (size_t) 0U;
|
@@ -92,26 +92,30 @@ sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
|
92
92
|
return (int) ((1 & ((d - 1) >> 8)) - 1);
|
93
93
|
}
|
94
94
|
|
95
|
+
/* Derived from original code by CodesInChaos */
|
95
96
|
char *
|
96
97
|
sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
97
98
|
const unsigned char * const bin, const size_t bin_len)
|
98
99
|
{
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
size_t i = (size_t) 0U;
|
104
|
-
size_t j = (size_t) 0U;
|
100
|
+
size_t i = (size_t) 0U;
|
101
|
+
unsigned int x;
|
102
|
+
int b;
|
103
|
+
int c;
|
105
104
|
|
106
105
|
if (bin_len >= SIZE_MAX / 2 || hex_maxlen < bin_len * 2U) {
|
107
106
|
abort(); /* LCOV_EXCL_LINE */
|
108
107
|
}
|
109
108
|
while (i < bin_len) {
|
110
|
-
|
111
|
-
|
109
|
+
c = bin[i] & 0xf;
|
110
|
+
b = bin[i] >> 4;
|
111
|
+
x = (unsigned char) (87 + c + (((c - 10) >> 31) & -39)) << 8 |
|
112
|
+
(unsigned char) (87 + b + (((b - 10) >> 31) & -39));
|
113
|
+
hex[i * 2U] = (char) x;
|
114
|
+
x >>= 8;
|
115
|
+
hex[i * 2U + 1U] = (char) x;
|
112
116
|
i++;
|
113
117
|
}
|
114
|
-
hex[
|
118
|
+
hex[i * 2U] = 0;
|
115
119
|
|
116
120
|
return hex;
|
117
121
|
}
|
@@ -350,12 +354,11 @@ _sodium_malloc(const size_t size)
|
|
350
354
|
unsigned char *base_ptr;
|
351
355
|
unsigned char *canary_ptr;
|
352
356
|
unsigned char *unprotected_ptr;
|
353
|
-
size_t page_mask;
|
354
357
|
size_t size_with_canary;
|
355
358
|
size_t total_size;
|
356
359
|
size_t unprotected_size;
|
357
360
|
|
358
|
-
if (size >= SIZE_MAX - page_size * 4U) {
|
361
|
+
if (size >= (size_t) SIZE_MAX - page_size * 4U) {
|
359
362
|
errno = ENOMEM;
|
360
363
|
return NULL;
|
361
364
|
}
|
@@ -375,7 +378,6 @@ _sodium_malloc(const size_t size)
|
|
375
378
|
#endif
|
376
379
|
_mprotect_noaccess(unprotected_ptr + unprotected_size, page_size);
|
377
380
|
sodium_mlock(unprotected_ptr, unprotected_size);
|
378
|
-
page_mask = page_size - 1U;
|
379
381
|
canary_ptr = unprotected_ptr + _page_round(size_with_canary) -
|
380
382
|
size_with_canary;
|
381
383
|
user_ptr = canary_ptr + sizeof canary;
|
@@ -405,7 +407,7 @@ sodium_allocarray(size_t count, size_t size)
|
|
405
407
|
{
|
406
408
|
size_t total_size;
|
407
409
|
|
408
|
-
if (size >= SIZE_MAX / count) {
|
410
|
+
if (size >= (size_t) SIZE_MAX / count) {
|
409
411
|
errno = ENOMEM;
|
410
412
|
return NULL;
|
411
413
|
}
|
@@ -81,7 +81,8 @@ check_PROGRAMS = $(am__EXEEXT_1)
|
|
81
81
|
TESTS = $(am__EXEEXT_1)
|
82
82
|
subdir = test/default
|
83
83
|
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
84
|
-
$(top_srcdir)/depcomp
|
84
|
+
$(top_srcdir)/build-aux/depcomp \
|
85
|
+
$(top_srcdir)/build-aux/test-driver
|
85
86
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
86
87
|
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
|
87
88
|
$(top_srcdir)/m4/ax_check_link_flag.m4 \
|
@@ -299,7 +300,7 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
|
299
300
|
am__v_at_0 = @
|
300
301
|
am__v_at_1 =
|
301
302
|
DEFAULT_INCLUDES = -I.@am__isrc@
|
302
|
-
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
303
|
+
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
|
303
304
|
am__depfiles_maybe = depfiles
|
304
305
|
am__mv = mv -f
|
305
306
|
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
@@ -554,7 +555,7 @@ RECHECK_LOGS = $(TEST_LOGS)
|
|
554
555
|
AM_RECURSIVE_TARGETS = check recheck
|
555
556
|
TEST_SUITE_LOG = test-suite.log
|
556
557
|
TEST_EXTENSIONS = @EXEEXT@ .test
|
557
|
-
LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
|
558
|
+
LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
|
558
559
|
LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
|
559
560
|
am__set_b = \
|
560
561
|
case '$@' in \
|
@@ -569,7 +570,7 @@ am__set_b = \
|
|
569
570
|
am__test_logs1 = $(TESTS:=.log)
|
570
571
|
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
|
571
572
|
TEST_LOGS = $(am__test_logs2:.test.log=.log)
|
572
|
-
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
|
573
|
+
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
|
573
574
|
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
|
574
575
|
$(TEST_LOG_FLAGS)
|
575
576
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
@@ -95,6 +95,31 @@ int main(void)
|
|
95
95
|
"ciphertext\n");
|
96
96
|
}
|
97
97
|
|
98
|
+
memcpy(c, m, sizeof m);
|
99
|
+
crypto_aead_chacha20poly1305_encrypt(c, &clen, c, sizeof m, NULL, 0U, NULL,
|
100
|
+
nonce, firstkey);
|
101
|
+
if (clen != sizeof m + crypto_aead_chacha20poly1305_abytes()) {
|
102
|
+
printf("clen is not properly set (adlen=0)\n");
|
103
|
+
}
|
104
|
+
for (i = 0U; i < sizeof c; ++i) {
|
105
|
+
printf(",0x%02x", (unsigned int)c[i]);
|
106
|
+
if (i % 8 == 7) {
|
107
|
+
printf("\n");
|
108
|
+
}
|
109
|
+
}
|
110
|
+
printf("\n");
|
111
|
+
|
112
|
+
if (crypto_aead_chacha20poly1305_decrypt(c, &m2len, NULL, c, sizeof c,
|
113
|
+
NULL, 0U, nonce, firstkey) != 0) {
|
114
|
+
printf("crypto_aead_chacha20poly1305_decrypt() failed (adlen=0)\n");
|
115
|
+
}
|
116
|
+
if (m2len != sizeof c - crypto_aead_chacha20poly1305_abytes()) {
|
117
|
+
printf("m2len is not properly set (adlen=0)\n");
|
118
|
+
}
|
119
|
+
if (memcmp(m, c, sizeof m) != 0) {
|
120
|
+
printf("m != c (adlen=0)\n");
|
121
|
+
}
|
122
|
+
|
98
123
|
assert(crypto_aead_chacha20poly1305_keybytes() > 0U);
|
99
124
|
assert(crypto_aead_chacha20poly1305_npubbytes() > 0U);
|
100
125
|
assert(crypto_aead_chacha20poly1305_nsecbytes() == 0U);
|
@@ -14,30 +14,45 @@ unsigned char mac[crypto_box_MACBYTES];
|
|
14
14
|
|
15
15
|
int main(void)
|
16
16
|
{
|
17
|
-
|
18
|
-
|
17
|
+
size_t mlen;
|
18
|
+
size_t i;
|
19
19
|
|
20
20
|
crypto_box_keypair(alicepk, alicesk);
|
21
21
|
crypto_box_keypair(bobpk, bobsk);
|
22
|
-
mlen = (
|
22
|
+
mlen = (size_t) randombytes_uniform((uint32_t)sizeof m);
|
23
23
|
randombytes_buf(m, mlen);
|
24
24
|
randombytes_buf(nonce, sizeof nonce);
|
25
25
|
crypto_box_easy(c, m, mlen, nonce, bobpk, alicesk);
|
26
|
-
if (crypto_box_open_easy(m2, c,
|
27
|
-
|
26
|
+
if (crypto_box_open_easy(m2, c,
|
27
|
+
(unsigned long long) mlen + crypto_box_MACBYTES,
|
28
|
+
nonce, alicepk, bobsk) != 0) {
|
28
29
|
printf("open() failed");
|
29
30
|
return 1;
|
30
31
|
}
|
31
32
|
printf("%d\n", memcmp(m, m2, mlen));
|
32
33
|
|
33
34
|
for (i = 0; i < mlen + crypto_box_MACBYTES - 1; i++) {
|
34
|
-
if (crypto_box_open_easy(m2, c,
|
35
|
+
if (crypto_box_open_easy(m2, c, (unsigned long long) i,
|
36
|
+
nonce, alicepk, bobsk) == 0) {
|
35
37
|
printf("short open() should have failed");
|
36
38
|
return 1;
|
37
39
|
}
|
38
40
|
}
|
39
|
-
|
40
|
-
|
41
|
+
|
42
|
+
memcpy(c, m, mlen);
|
43
|
+
crypto_box_easy(c, c, (unsigned long long) mlen, nonce, bobpk, alicesk);
|
44
|
+
printf("%d\n", memcmp(m, c, mlen) == 0);
|
45
|
+
printf("%d\n", memcmp(m, c + crypto_box_MACBYTES, mlen) == 0);
|
46
|
+
if (crypto_box_open_easy(c, c,
|
47
|
+
(unsigned long long) mlen + crypto_box_MACBYTES,
|
48
|
+
nonce, alicepk, bobsk) != 0) {
|
49
|
+
printf("crypto_box_open_easy() failed\n");
|
50
|
+
}
|
51
|
+
|
52
|
+
crypto_box_detached(c, mac, m, (unsigned long long) mlen,
|
53
|
+
nonce, bobsk, alicepk);
|
54
|
+
crypto_box_open_detached(m2, c, mac, (unsigned long long) mlen,
|
55
|
+
nonce, alicepk, bobsk);
|
41
56
|
printf("%d\n", memcmp(m, m2, mlen));
|
42
57
|
|
43
58
|
return 0;
|