rbnacl-libsodium 0.5.0.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) 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/AUTHORS +62 -81
  5. data/vendor/libsodium/ChangeLog +31 -1
  6. data/vendor/libsodium/README.markdown +15 -364
  7. data/vendor/libsodium/THANKS +6 -0
  8. data/vendor/libsodium/autom4te.cache/output.0 +67 -36
  9. data/vendor/libsodium/autom4te.cache/output.1 +67 -36
  10. data/vendor/libsodium/autom4te.cache/output.2 +67 -36
  11. data/vendor/libsodium/autom4te.cache/traces.0 +52 -51
  12. data/vendor/libsodium/autom4te.cache/traces.1 +137 -133
  13. data/vendor/libsodium/autom4te.cache/traces.2 +52 -51
  14. data/vendor/libsodium/builds/msvc/version.h +2 -2
  15. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +365 -345
  16. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1114 -1037
  17. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +8 -2
  18. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +364 -344
  19. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1113 -1036
  20. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +8 -2
  21. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +365 -345
  22. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1114 -1037
  23. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +8 -2
  24. data/vendor/libsodium/configure +66 -35
  25. data/vendor/libsodium/configure.ac +25 -14
  26. data/vendor/libsodium/dist-build/ios.sh +1 -1
  27. data/vendor/libsodium/dist-build/msys2-win64.sh +1 -1
  28. data/vendor/libsodium/libsodium.vcxproj +29 -14
  29. data/vendor/libsodium/libsodium.vcxproj.filters +77 -28
  30. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  31. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  32. data/vendor/libsodium/packaging/nuget/package.gsl +6 -1
  33. data/vendor/libsodium/packaging/nuget/package.nuspec +1 -1
  34. data/vendor/libsodium/src/libsodium/Makefile.am +31 -13
  35. data/vendor/libsodium/src/libsodium/Makefile.in +406 -155
  36. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +146 -0
  37. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +13 -0
  38. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +39 -73
  39. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +5 -0
  40. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +2 -0
  41. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +15 -0
  42. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -5
  43. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +6 -5
  44. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +25 -0
  45. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +76 -47
  46. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +30 -7
  47. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +3 -16
  48. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +3 -10
  49. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +11 -6
  50. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +23 -1
  51. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +1 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt-common.c +7 -7
  53. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt.h +6 -20
  54. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/nosse/pwhash_scryptxsalsa208sha256_nosse.c → scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c} +0 -0
  55. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.c +1 -11
  56. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.h +0 -0
  57. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c → scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c} +50 -25
  58. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/scrypt_platform.c +4 -0
  59. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/sse/pwhash_scryptxsalsa208sha256_sse.c → scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c} +0 -0
  60. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/sysendian.h +0 -0
  61. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +1 -1
  62. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/{ref → ref10}/api.h +0 -3
  63. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +14 -0
  64. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe.h +44 -0
  65. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_0_curve25519_ref10.c +23 -0
  66. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_1_curve25519_ref10.c +23 -0
  67. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c +61 -0
  68. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c +33 -0
  69. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c +77 -0
  70. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +73 -0
  71. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c +18 -0
  72. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c +74 -0
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c +257 -0
  74. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c +153 -0
  75. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c +61 -0
  76. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c +123 -0
  77. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/montgomery.h +140 -0
  78. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h +160 -0
  79. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +54 -0
  80. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +92 -61
  81. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +3 -3
  82. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +2 -2
  83. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +2 -2
  84. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +8 -4
  85. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +3 -3
  86. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +6 -3
  87. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +23 -23
  88. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/api.h +12 -0
  89. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +275 -0
  90. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c +36 -0
  91. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +11 -10
  92. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +8 -3
  93. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +8 -0
  94. data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -2
  95. data/vendor/libsodium/src/libsodium/include/Makefile.in +3 -2
  96. data/vendor/libsodium/src/libsodium/include/sodium.h +3 -1
  97. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +55 -0
  98. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +21 -0
  99. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +11 -1
  100. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +7 -0
  101. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +7 -0
  102. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +7 -0
  103. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +15 -0
  104. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +25 -0
  105. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +80 -0
  106. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +2 -2
  107. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +14 -0
  108. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +11 -0
  109. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +11 -6
  110. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +49 -0
  111. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +6 -0
  112. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +7 -7
  113. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +10 -14
  114. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -13
  115. data/vendor/libsodium/src/libsodium/sodium/compat.c +55 -4
  116. data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -0
  117. data/vendor/libsodium/test/default/Makefile.am +24 -12
  118. data/vendor/libsodium/test/default/Makefile.in +116 -73
  119. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +97 -0
  120. data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +8 -0
  121. data/vendor/libsodium/test/default/box_easy.c +1 -1
  122. data/vendor/libsodium/test/default/box_seed.c +28 -0
  123. data/vendor/libsodium/test/default/box_seed.exp +8 -0
  124. data/vendor/libsodium/test/default/chacha20.c +45 -0
  125. data/vendor/libsodium/test/default/chacha20.exp +5 -0
  126. data/vendor/libsodium/test/default/pwhash.c +83 -15
  127. data/vendor/libsodium/test/default/pwhash.exp +10 -1
  128. data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +67 -0
  129. data/vendor/libsodium/test/default/pwhash_scrypt_ll.exp +15 -0
  130. data/vendor/libsodium/test/default/secretbox_easy.c +13 -1
  131. data/vendor/libsodium/test/default/secretbox_easy.exp +19 -0
  132. data/vendor/libsodium/test/default/secretbox_easy2.c +5 -0
  133. data/vendor/libsodium/test/default/secretbox_easy2.exp +1 -0
  134. data/vendor/libsodium/test/default/sign.c +7 -3
  135. metadata +44 -21
  136. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/api.h +0 -8
  137. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/base_curve25519_ref.c +0 -20
  138. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/smult_curve25519_ref.c +0 -268
  139. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +0 -37
  140. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +0 -48
  141. data/vendor/libsodium/test/default/scalarmult7.c +0 -32
  142. data/vendor/libsodium/test/default/scalarmult7.exp +0 -1
  143. data/vendor/libsodium/test/default/scalarmult8.c +0 -32
  144. data/vendor/libsodium/test/default/scalarmult8.exp +0 -1
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  #include <stddef.h>
13
+ #include <stdint.h>
13
14
  #include "export.h"
14
15
 
15
16
  #ifdef __cplusplus
@@ -36,6 +37,11 @@ int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m,
36
37
  unsigned long long mlen, const unsigned char *n,
37
38
  const unsigned char *k);
38
39
 
40
+ SODIUM_EXPORT
41
+ int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m,
42
+ unsigned long long mlen,
43
+ const unsigned char *n, uint64_t ic,
44
+ const unsigned char *k);
39
45
  #ifdef __cplusplus
40
46
  }
41
47
  #endif
@@ -26,28 +26,28 @@ typedef struct randombytes_implementation {
26
26
  } randombytes_implementation;
27
27
 
28
28
  SODIUM_EXPORT
29
- int randombytes_set_implementation(randombytes_implementation *impl);
29
+ int randombytes_set_implementation(randombytes_implementation *impl);
30
30
 
31
31
  SODIUM_EXPORT
32
- void randombytes(unsigned char * const buf, const unsigned long long buf_len);
32
+ void randombytes(unsigned char * const buf, const unsigned long long buf_len);
33
33
 
34
34
  SODIUM_EXPORT
35
35
  const char *randombytes_implementation_name(void);
36
36
 
37
37
  SODIUM_EXPORT
38
- uint32_t randombytes_random(void);
38
+ uint32_t randombytes_random(void);
39
39
 
40
40
  SODIUM_EXPORT
41
- void randombytes_stir(void);
41
+ void randombytes_stir(void);
42
42
 
43
43
  SODIUM_EXPORT
44
- uint32_t randombytes_uniform(const uint32_t upper_bound);
44
+ uint32_t randombytes_uniform(const uint32_t upper_bound);
45
45
 
46
46
  SODIUM_EXPORT
47
- void randombytes_buf(void * const buf, const size_t size);
47
+ void randombytes_buf(void * const buf, const size_t size);
48
48
 
49
49
  SODIUM_EXPORT
50
- int randombytes_close(void);
50
+ int randombytes_close(void);
51
51
 
52
52
  #ifdef __cplusplus
53
53
  }
@@ -25,8 +25,13 @@
25
25
 
26
26
  #ifdef _WIN32
27
27
  # include <windows.h>
28
- # include <wincrypt.h>
29
28
  # include <sys/timeb.h>
29
+ # define RtlGenRandom SystemFunction036
30
+ # if defined(__cplusplus)
31
+ extern "C"
32
+ # endif
33
+ BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
34
+ # pragma comment(lib, "advapi32.lib")
30
35
  #endif
31
36
 
32
37
  #define SALSA20_RANDOM_BLOCK_SIZE crypto_core_salsa20_OUTPUTBYTES
@@ -41,9 +46,6 @@ typedef struct Salsa20Random_ {
41
46
  size_t rnd32_outleft;
42
47
  #ifndef _MSC_VER
43
48
  pid_t pid;
44
- #endif
45
- #ifdef _WIN32
46
- HCRYPTPROV hcrypt_prov;
47
49
  #endif
48
50
  int random_data_source_fd;
49
51
  int initialized;
@@ -119,8 +121,7 @@ randombytes_salsa20_random_random_dev_open(void)
119
121
  int fd;
120
122
 
121
123
  do {
122
- if (access(*device, F_OK | R_OK) == 0 &&
123
- (fd = open(*device, O_RDONLY)) != -1) {
124
+ if ((fd = open(*device, O_RDONLY)) != -1) {
124
125
  if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) {
125
126
  return fd;
126
127
  }
@@ -154,11 +155,6 @@ randombytes_salsa20_random_init(void)
154
155
  {
155
156
  stream.nonce = sodium_hrtime();
156
157
  assert(stream.nonce != (uint64_t) 0U);
157
-
158
- if (! CryptAcquireContextW(&stream.hcrypt_prov, NULL, NULL,
159
- PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
160
- abort();
161
- }
162
158
  }
163
159
  #endif
164
160
 
@@ -188,7 +184,7 @@ randombytes_salsa20_random_stir(void)
188
184
  abort();
189
185
  }
190
186
  #else /* _WIN32 */
191
- if (! CryptGenRandom(stream.hcrypt_prov, sizeof m0, (BYTE *) m0)) {
187
+ if (! RtlGenRandom((PVOID) m0, (ULONG) sizeof m0)) {
192
188
  abort();
193
189
  }
194
190
  #endif
@@ -256,8 +252,7 @@ randombytes_salsa20_random_close(void)
256
252
  ret = 0;
257
253
  }
258
254
  #else /* _WIN32 */
259
- if (stream.initialized != 0 &&
260
- CryptReleaseContext(stream.hcrypt_prov, 0)) {
255
+ if (stream.initialized != 0) {
261
256
  stream.initialized = 0;
262
257
  ret = 0;
263
258
  }
@@ -279,6 +274,7 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size)
279
274
  randombytes_salsa20_random_stir_if_needed();
280
275
  COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES);
281
276
  #ifdef ULONG_LONG_MAX
277
+ /* coverity[result_independent_of_operands] */
282
278
  assert(size <= ULONG_LONG_MAX);
283
279
  #endif
284
280
  ret = crypto_stream_salsa20((unsigned char *) buf, (unsigned long long) size,
@@ -22,7 +22,12 @@
22
22
 
23
23
  #ifdef _WIN32
24
24
  # include <windows.h>
25
- # include <wincrypt.h>
25
+ # define RtlGenRandom SystemFunction036
26
+ # if defined(__cplusplus)
27
+ extern "C"
28
+ # endif
29
+ BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
30
+ # pragma comment(lib, "advapi32.lib")
26
31
  #endif
27
32
 
28
33
  #ifdef __OpenBSD__
@@ -59,9 +64,6 @@ randombytes_sysrandom_close(void)
59
64
  #else /* __OpenBSD__ */
60
65
 
61
66
  typedef struct SysRandom_ {
62
- #ifdef _WIN32
63
- HCRYPTPROV hcrypt_prov;
64
- #endif
65
67
  int random_data_source_fd;
66
68
  int initialized;
67
69
  } SysRandom;
@@ -111,8 +113,7 @@ randombytes_sysrandom_random_dev_open(void)
111
113
  int fd;
112
114
 
113
115
  do {
114
- if (access(*device, F_OK | R_OK) == 0 &&
115
- (fd = open(*device, O_RDONLY)) != -1) {
116
+ if ((fd = open(*device, O_RDONLY)) != -1) {
116
117
  if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) {
117
118
  return fd;
118
119
  }
@@ -141,10 +142,6 @@ randombytes_sysrandom_init(void)
141
142
  static void
142
143
  randombytes_sysrandom_init(void)
143
144
  {
144
- if (! CryptAcquireContextW(&stream.hcrypt_prov, NULL, NULL,
145
- PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
146
- abort();
147
- }
148
145
  }
149
146
  #endif
150
147
 
@@ -178,8 +175,7 @@ randombytes_sysrandom_close(void)
178
175
  ret = 0;
179
176
  }
180
177
  #else /* _WIN32 */
181
- if (stream.initialized != 0 &&
182
- CryptReleaseContext(stream.hcrypt_prov, 0)) {
178
+ if (stream.initialized != 0) {
183
179
  stream.initialized = 0;
184
180
  ret = 0;
185
181
  }
@@ -202,6 +198,7 @@ randombytes_sysrandom_buf(void * const buf, const size_t size)
202
198
  {
203
199
  randombytes_sysrandom_stir_if_needed();
204
200
  #ifdef ULONG_LONG_MAX
201
+ /* coverity[result_independent_of_operands] */
205
202
  assert(size <= ULONG_LONG_MAX);
206
203
  #endif
207
204
  #ifndef _WIN32
@@ -212,7 +209,7 @@ randombytes_sysrandom_buf(void * const buf, const size_t size)
212
209
  if (size > 0xffffffff) {
213
210
  abort();
214
211
  }
215
- if (! CryptGenRandom(stream.hcrypt_prov, (DWORD) size, (BYTE *) buf)) {
212
+ if (! RtlGenRandom((PVOID) buf, (ULONG) size)) {
216
213
  abort();
217
214
  }
218
215
  #endif
@@ -5,6 +5,7 @@
5
5
  #include "crypto_hash_sha256.h"
6
6
  #include "crypto_hash_sha512.h"
7
7
  #include "crypto_onetimeauth_poly1305.h"
8
+ #include "crypto_pwhash_scryptsalsa208sha256.h"
8
9
  #include "crypto_scalarmult_curve25519.h"
9
10
  #include "crypto_secretbox_xsalsa20poly1305.h"
10
11
  #include "crypto_sign_ed25519.h"
@@ -14,12 +15,62 @@
14
15
  #include "crypto_verify_32.h"
15
16
  #include "export.h"
16
17
 
17
- #ifdef EXPORT_ORIGINAL_IMPLEMENTATIONS
18
-
19
18
  #ifdef __cplusplus
20
19
  extern "C" {
21
20
  #endif
22
21
 
22
+ #undef crypto_pwhash_scryptxsalsa208sha256_saltbytes
23
+ SODIUM_EXPORT size_t
24
+ crypto_pwhash_scryptxsalsa208sha256_saltbytes(void)
25
+ {
26
+ return crypto_pwhash_scryptsalsa208sha256_saltbytes();
27
+ }
28
+
29
+ #undef crypto_pwhash_scryptxsalsa208sha256_strbytes
30
+ SODIUM_EXPORT size_t
31
+ crypto_pwhash_scryptxsalsa208sha256_strbytes(void)
32
+ {
33
+ return crypto_pwhash_scryptsalsa208sha256_strbytes();
34
+ }
35
+
36
+ #undef crypto_pwhash_scryptxsalsa208sha256
37
+ SODIUM_EXPORT int
38
+ crypto_pwhash_scryptxsalsa208sha256(unsigned char * const out,
39
+ unsigned long long outlen,
40
+ const char * const passwd,
41
+ unsigned long long passwdlen,
42
+ const unsigned char * const salt,
43
+ unsigned long long opslimit,
44
+ size_t memlimit)
45
+ {
46
+ return crypto_pwhash_scryptsalsa208sha256(out, outlen, passwd, passwdlen,
47
+ salt, opslimit, memlimit);
48
+ }
49
+
50
+ #undef crypto_pwhash_scryptxsalsa208sha256_str
51
+ SODIUM_EXPORT int
52
+ crypto_pwhash_scryptxsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
53
+ const char * const passwd,
54
+ unsigned long long passwdlen,
55
+ unsigned long long opslimit,
56
+ size_t memlimit)
57
+ {
58
+ return crypto_pwhash_scryptsalsa208sha256_str(out, passwd, passwdlen,
59
+ opslimit, memlimit);
60
+ }
61
+
62
+ #undef crypto_pwhash_scryptxsalsa208sha256_str_verify
63
+ SODIUM_EXPORT int
64
+ crypto_pwhash_scryptxsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
65
+ const char * const passwd,
66
+ unsigned long long passwdlen)
67
+ {
68
+ return crypto_pwhash_scryptsalsa208sha256_str_verify(str,
69
+ passwd, passwdlen);
70
+ }
71
+
72
+ #ifdef EXPORT_ORIGINAL_IMPLEMENTATIONS
73
+
23
74
  #undef crypto_hash_sha256_ref
24
75
  SODIUM_EXPORT int
25
76
  crypto_hash_sha256_ref(unsigned char *out, const unsigned char *in,
@@ -303,8 +354,8 @@ crypto_stream_salsa20_ref_xor(unsigned char *c,
303
354
  return crypto_stream_salsa20_xor(c, m, mlen, n, k);
304
355
  }
305
356
 
306
- #ifdef __cplusplus
307
- }
308
357
  #endif
309
358
 
359
+ #ifdef __cplusplus
360
+ }
310
361
  #endif
@@ -19,6 +19,15 @@
19
19
  # include <wincrypt.h>
20
20
  #endif
21
21
 
22
+ #ifdef HAVE_WEAK_SYMBOLS
23
+ __attribute__((weak)) void
24
+ __sodium_dummy_symbol_to_prevent_lto(void * const pnt, const size_t len)
25
+ {
26
+ (void) pnt;
27
+ (void) len;
28
+ }
29
+ #endif
30
+
22
31
  void
23
32
  sodium_memzero(void * const pnt, const size_t len)
24
33
  {
@@ -30,6 +39,9 @@ sodium_memzero(void * const pnt, const size_t len)
30
39
  }
31
40
  #elif defined(HAVE_EXPLICIT_BZERO)
32
41
  explicit_bzero(pnt, len);
42
+ #elif HAVE_WEAK_SYMBOLS
43
+ memset(pnt, 0, len);
44
+ __sodium_dummy_symbol_to_prevent_lto(pnt, len);
33
45
  #else
34
46
  volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
35
47
  size_t i = (size_t) 0U;
@@ -161,6 +173,9 @@ sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen,
161
173
  int
162
174
  sodium_mlock(void * const addr, const size_t len)
163
175
  {
176
+ #ifdef MADV_DONTDUMP
177
+ (void) madvise(addr, len, MADV_DONTDUMP);
178
+ #endif
164
179
  #ifdef HAVE_MLOCK
165
180
  return mlock(addr, len);
166
181
  #elif defined(HAVE_VIRTUALLOCK)
@@ -175,6 +190,9 @@ int
175
190
  sodium_munlock(void * const addr, const size_t len)
176
191
  {
177
192
  sodium_memzero(addr, len);
193
+ #ifdef MADV_DODUMP
194
+ (void) madvise(addr, len, MADV_DODUMP);
195
+ #endif
178
196
  #ifdef HAVE_MLOCK
179
197
  return munlock(addr, len);
180
198
  #elif defined(HAVE_VIRTUALLOCK)
@@ -2,6 +2,7 @@
2
2
  EXTRA_DIST = \
3
3
  cmptest.h \
4
4
  wintest.bat \
5
+ aead_chacha20poly1305.exp \
5
6
  auth.exp \
6
7
  auth2.exp \
7
8
  auth3.exp \
@@ -14,6 +15,8 @@ EXTRA_DIST = \
14
15
  box8.exp \
15
16
  box_easy.exp \
16
17
  box_easy2.exp \
18
+ box_seed.exp \
19
+ chacha20.exp \
17
20
  core1.exp \
18
21
  core2.exp \
19
22
  core3.exp \
@@ -30,12 +33,11 @@ EXTRA_DIST = \
30
33
  onetimeauth2.exp \
31
34
  onetimeauth7.exp \
32
35
  pwhash.exp \
36
+ pwhash_scrypt_ll.exp \
33
37
  scalarmult.exp \
34
38
  scalarmult2.exp \
35
39
  scalarmult5.exp \
36
40
  scalarmult6.exp \
37
- scalarmult7.exp \
38
- scalarmult8.exp \
39
41
  secretbox.exp \
40
42
  secretbox2.exp \
41
43
  secretbox7.exp \
@@ -56,6 +58,7 @@ EXTRA_DIST = \
56
58
  verify1.exp
57
59
 
58
60
  DISTCLEANFILES = \
61
+ aead_chacha20poly1305.res \
59
62
  auth.res \
60
63
  auth2.res \
61
64
  auth3.res \
@@ -68,6 +71,8 @@ DISTCLEANFILES = \
68
71
  box8.res \
69
72
  box_easy.res \
70
73
  box_easy2.res \
74
+ box_seed.res \
75
+ chacha20.res \
71
76
  core1.res \
72
77
  core2.res \
73
78
  core3.res \
@@ -84,12 +89,11 @@ DISTCLEANFILES = \
84
89
  onetimeauth2.res \
85
90
  onetimeauth7.res \
86
91
  pwhash.res \
92
+ pwhash_scrypt_ll.res \
87
93
  scalarmult.res \
88
94
  scalarmult2.res \
89
95
  scalarmult5.res \
90
96
  scalarmult6.res \
91
- scalarmult7.res \
92
- scalarmult8.res \
93
97
  secretbox.res \
94
98
  secretbox2.res \
95
99
  secretbox7.res \
@@ -118,6 +122,7 @@ AM_CPPFLAGS = \
118
122
  -I$(top_srcdir)/test/quirks
119
123
 
120
124
  TESTS_TARGETS = \
125
+ aead_chacha20poly1305 \
121
126
  auth \
122
127
  auth2 \
123
128
  auth3 \
@@ -130,6 +135,8 @@ TESTS_TARGETS = \
130
135
  box8 \
131
136
  box_easy \
132
137
  box_easy2 \
138
+ box_seed \
139
+ chacha20 \
133
140
  core1 \
134
141
  core2 \
135
142
  core3 \
@@ -145,13 +152,12 @@ TESTS_TARGETS = \
145
152
  onetimeauth2 \
146
153
  onetimeauth7 \
147
154
  pwhash \
155
+ pwhash_scrypt_ll \
148
156
  randombytes \
149
157
  scalarmult \
150
158
  scalarmult2 \
151
159
  scalarmult5 \
152
160
  scalarmult6 \
153
- scalarmult7 \
154
- scalarmult8 \
155
161
  secretbox \
156
162
  secretbox2 \
157
163
  secretbox7 \
@@ -178,6 +184,9 @@ TESTS = $(TESTS_TARGETS)
178
184
  TESTS_LDADD = \
179
185
  ${top_builddir}/src/libsodium/libsodium.la
180
186
 
187
+ aead_chacha20poly1305_SOURCE = cmptest.h aead_chacha20poly1305.c
188
+ aead_chacha20poly1305_LDADD = $(TESTS_LDADD)
189
+
181
190
  auth_SOURCE = cmptest.h auth.c
182
191
  auth_LDADD = $(TESTS_LDADD)
183
192
 
@@ -214,6 +223,12 @@ box_easy_LDADD = $(TESTS_LDADD)
214
223
  box_easy2_SOURCE = cmptest.h box_easy2.c
215
224
  box_easy2_LDADD = $(TESTS_LDADD)
216
225
 
226
+ box_seed_SOURCE = cmptest.h box_seed.c
227
+ box_seed_LDADD = $(TESTS_LDADD)
228
+
229
+ chacha20_SOURCE = cmptest.h chacha20.c
230
+ chacha20_LDADD = $(TESTS_LDADD)
231
+
217
232
  core1_SOURCE = cmptest.h core1.c
218
233
  core1_LDADD = $(TESTS_LDADD)
219
234
 
@@ -259,6 +274,9 @@ onetimeauth7_LDADD = $(TESTS_LDADD)
259
274
  pwhash_SOURCE = cmptest.h pwhash.c
260
275
  pwhash_LDADD = $(TESTS_LDADD)
261
276
 
277
+ pwhash_scrypt_ll_SOURCE = cmptest.h pwhash_scrypt_ll.c
278
+ pwhash_scrypt_ll_LDADD = $(TESTS_LDADD)
279
+
262
280
  randombytes_SOURCE = randombytes.c
263
281
  randombytes_LDADD = $(TESTS_LDADD)
264
282
 
@@ -274,12 +292,6 @@ scalarmult5_LDADD = $(TESTS_LDADD)
274
292
  scalarmult6_SOURCE = cmptest.h scalarmult6.c
275
293
  scalarmult6_LDADD = $(TESTS_LDADD)
276
294
 
277
- scalarmult7_SOURCE = cmptest.h scalarmult7.c
278
- scalarmult7_LDADD = $(TESTS_LDADD)
279
-
280
- scalarmult8_SOURCE = cmptest.h scalarmult8.c
281
- scalarmult8_LDADD = $(TESTS_LDADD)
282
-
283
295
  secretbox_SOURCE = cmptest.h secretbox.c
284
296
  secretbox_LDADD = $(TESTS_LDADD)
285
297