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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +4 -0
  3. data/lib/rbnacl/libsodium/version.rb +1 -1
  4. data/vendor/libsodium/ChangeLog +10 -0
  5. data/vendor/libsodium/LICENSE +1 -1
  6. data/vendor/libsodium/Makefile.in +10 -2
  7. data/vendor/libsodium/THANKS +1 -0
  8. data/vendor/libsodium/autom4te.cache/output.1 +52 -17
  9. data/vendor/libsodium/autom4te.cache/output.3 +52 -17
  10. data/vendor/libsodium/autom4te.cache/requests +558 -558
  11. data/vendor/libsodium/autom4te.cache/traces.1 +543 -542
  12. data/vendor/libsodium/autom4te.cache/traces.3 +320 -319
  13. data/vendor/libsodium/build-aux/compile +347 -0
  14. data/vendor/libsodium/build-aux/config.guess +1568 -0
  15. data/vendor/libsodium/build-aux/config.sub +1793 -0
  16. data/vendor/libsodium/build-aux/depcomp +791 -0
  17. data/vendor/libsodium/build-aux/install-sh +527 -0
  18. data/vendor/libsodium/build-aux/ltmain.sh +9655 -0
  19. data/vendor/libsodium/build-aux/missing +215 -0
  20. data/vendor/libsodium/build-aux/test-driver +139 -0
  21. data/vendor/libsodium/builds/msvc/properties/Common.props +1 -3
  22. data/vendor/libsodium/builds/msvc/properties/Release.props +3 -1
  23. data/vendor/libsodium/builds/msvc/resource.rc +0 -0
  24. data/vendor/libsodium/builds/msvc/version.h +2 -2
  25. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +1 -1
  26. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +12 -6
  27. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +11 -5
  28. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +1 -1
  29. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +12 -6
  30. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +11 -5
  31. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +1 -1
  32. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +12 -6
  33. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +11 -5
  34. data/vendor/libsodium/configure +52 -17
  35. data/vendor/libsodium/configure.ac +7 -4
  36. data/vendor/libsodium/dist-build/ios.sh +4 -3
  37. data/vendor/libsodium/libsodium.vcxproj +4 -4
  38. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  39. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  40. data/vendor/libsodium/packaging/nuget/package.nuspec +25 -25
  41. data/vendor/libsodium/packaging/nuget/package.targets +20 -20
  42. data/vendor/libsodium/src/libsodium/Makefile.in +2 -2
  43. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +2 -2
  44. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +8 -8
  45. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +6 -6
  46. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +2 -2
  47. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
  48. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +2 -2
  49. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h +2 -2
  50. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +1 -1
  51. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +1 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +2 -2
  53. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +38 -38
  54. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +8 -0
  55. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +10 -10
  56. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +10 -10
  57. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +10 -10
  58. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +10 -10
  59. data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
  60. data/vendor/libsodium/src/libsodium/include/sodium/core.h +2 -2
  61. data/vendor/libsodium/src/libsodium/include/sodium/export.h +3 -3
  62. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +2 -2
  63. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +4 -4
  64. data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +2 -2
  65. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +9 -9
  66. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +9 -9
  67. data/vendor/libsodium/src/libsodium/sodium/utils.c +17 -15
  68. data/vendor/libsodium/test/default/Makefile.in +5 -4
  69. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +25 -0
  70. data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +4 -0
  71. data/vendor/libsodium/test/default/box_easy2.c +23 -8
  72. data/vendor/libsodium/test/default/box_easy2.exp +2 -0
  73. data/vendor/libsodium/test/default/generichash.c +23 -15
  74. data/vendor/libsodium/test/default/generichash3.c +24 -20
  75. data/vendor/libsodium/test/default/pwhash.c +27 -28
  76. data/vendor/libsodium/test/default/scalarmult6.c +19 -3
  77. data/vendor/libsodium/test/default/secretbox_easy2.c +27 -11
  78. data/vendor/libsodium/test/default/secretbox_easy2.exp +3 -0
  79. data/vendor/libsodium/test/default/shorthash.c +15 -10
  80. data/vendor/libsodium/test/default/sign.c +23 -0
  81. data/vendor/libsodium/test/default/sodium_utils2.c +4 -0
  82. data/vendor/libsodium/test/default/sodium_utils3.c +4 -0
  83. 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 __SODIUM_H__
3
- #define __SODIUM_H__
2
+ #ifndef sodium_H
3
+ #define sodium_H
4
4
 
5
5
  #include <sodium/core.h>
6
6
  #include <sodium/crypto_aead_chacha20poly1305.h>
@@ -1,6 +1,6 @@
1
1
 
2
- #ifndef __SODIUM_CORE_H__
3
- #define __SODIUM_CORE_H__
2
+ #ifndef sodium_core_H
3
+ #define sodium_core_H
4
4
 
5
5
  #include "export.h"
6
6
 
@@ -1,6 +1,6 @@
1
1
 
2
- #ifndef __SODIUM_EXPORT_H__
3
- #define __SODIUM_EXPORT_H__
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 DLL_EXPORT
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 __SODIUM_RUNTIME_H__
3
- #define __SODIUM_RUNTIME_H__ 1
2
+ #ifndef sodium_runtime_H
3
+ #define sodium_runtime_H
4
4
 
5
5
  #include "export.h"
6
6
 
@@ -1,6 +1,6 @@
1
1
 
2
- #ifndef __SODIUM_UTILS_H__
3
- #define __SODIUM_UTILS_H__
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 _SODIUM_C99(X)
14
+ # define SODIUM_C99(X)
15
15
  #else
16
- # define _SODIUM_C99(X) X
16
+ # define SODIUM_C99(X) X
17
17
  #endif
18
18
 
19
19
  SODIUM_EXPORT
@@ -1,6 +1,6 @@
1
1
 
2
- #ifndef __SODIUM_VERSION_H__
3
- #define __SODIUM_VERSION_H__
2
+ #ifndef sodium_version_H
3
+ #define sodium_version_H
4
4
 
5
5
  #include "export.h"
6
6
 
@@ -52,9 +52,9 @@ typedef struct Salsa20Random_ {
52
52
  } Salsa20Random;
53
53
 
54
54
  static Salsa20Random stream = {
55
- _SODIUM_C99(.random_data_source_fd =) -1,
56
- _SODIUM_C99(.rnd32_outleft =) (size_t) 0U,
57
- _SODIUM_C99(.initialized =) 0
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
- _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
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
- _SODIUM_C99(.random_data_source_fd =) -1,
73
- _SODIUM_C99(.initialized =) 0
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
- _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
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
- __sodium_dummy_symbol_to_prevent_lto(void * const pnt, const size_t len)
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
- __sodium_dummy_symbol_to_prevent_lto(pnt, len);
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
- static const char hexdigits[16] = {
100
- '0', '1', '2', '3', '4', '5', '6', '7',
101
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
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
- hex[j++] = hexdigits[bin[i] >> 4];
111
- hex[j++] = hexdigits[bin[i] & 0xf];
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[j] = 0;
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 $(top_srcdir)/test-driver
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);
@@ -6,3 +6,7 @@
6
6
  ,0x62,0xa4,0x69,0xe7,0x78,0x9b,0xcd,0x95
7
7
  ,0x4e,0x65,0x8e,0xd3,0x84,0x23,0xe2,0x31
8
8
  ,0x61,0xdc
9
+ ,0xe3,0xe4,0x46,0xf7,0xed,0xe9,0xa1,0x9b
10
+ ,0x62,0xa4,0x69,0xe7,0x78,0x9b,0xcd,0x95
11
+ ,0x4e,0x65,0x8e,0xd3,0x84,0x23,0xe2,0x31
12
+ ,0x61,0xdc
@@ -14,30 +14,45 @@ unsigned char mac[crypto_box_MACBYTES];
14
14
 
15
15
  int main(void)
16
16
  {
17
- unsigned long long mlen;
18
- unsigned long long i;
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 = (unsigned long long)randombytes_uniform((uint32_t)sizeof m);
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, mlen + crypto_box_MACBYTES, nonce, alicepk,
27
- bobsk) != 0) {
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, i, nonce, alicepk, bobsk) == 0) {
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
- crypto_box_detached(c, mac, m, mlen, nonce, bobsk, alicepk);
40
- crypto_box_open_detached(m2, c, mac, mlen, nonce, alicepk, bobsk);
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;