rbnacl-libsodium 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +23 -0
  3. data/CHANGES.md +5 -0
  4. data/Gemfile +5 -2
  5. data/Rakefile +5 -0
  6. data/ext/rbnacl/extconf.rb +2 -1
  7. data/lib/rbnacl/libsodium.rb +8 -2
  8. data/lib/rbnacl/libsodium/version.rb +1 -1
  9. data/vendor/libsodium/AUTHORS +14 -0
  10. data/vendor/libsodium/ChangeLog +26 -0
  11. data/vendor/libsodium/LICENSE +1 -1
  12. data/vendor/libsodium/Makefile.am +1 -0
  13. data/vendor/libsodium/Makefile.in +9 -0
  14. data/vendor/libsodium/README.markdown +7 -0
  15. data/vendor/libsodium/aclocal.m4 +1 -0
  16. data/vendor/libsodium/appveyor.yml +25 -0
  17. data/vendor/libsodium/autom4te.cache/output.1 +640 -126
  18. data/vendor/libsodium/autom4te.cache/output.6 +19049 -0
  19. data/vendor/libsodium/autom4te.cache/requests +1151 -914
  20. data/vendor/libsodium/autom4te.cache/traces.1 +472 -426
  21. data/vendor/libsodium/autom4te.cache/traces.6 +3193 -0
  22. data/vendor/libsodium/builds/msvc/version.h +2 -2
  23. data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +50 -79
  24. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +20 -8
  25. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +208 -166
  26. data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +50 -79
  27. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +20 -8
  28. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +206 -164
  29. data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +52 -81
  30. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +20 -8
  31. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +206 -164
  32. data/vendor/libsodium/builds/msvc/vs2015/libsodium.sln +52 -81
  33. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +20 -8
  34. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +206 -164
  35. data/vendor/libsodium/configure +639 -125
  36. data/vendor/libsodium/configure.ac +94 -16
  37. data/vendor/libsodium/dist-build/Makefile.in +9 -0
  38. data/vendor/libsodium/dist-build/emscripten-symbols.def +370 -0
  39. data/vendor/libsodium/dist-build/emscripten.sh +9 -3
  40. data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +43 -0
  41. data/vendor/libsodium/libsodium-uninstalled.pc.in +1 -1
  42. data/vendor/libsodium/libsodium.pc.in +1 -1
  43. data/vendor/libsodium/libsodium.vcxproj +70 -66
  44. data/vendor/libsodium/libsodium.vcxproj.filters +204 -192
  45. data/vendor/libsodium/m4/ax_valgrind_check.m4 +190 -0
  46. data/vendor/libsodium/msvc-scripts/Makefile.in +9 -0
  47. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  48. data/vendor/libsodium/src/Makefile.in +9 -0
  49. data/vendor/libsodium/src/libsodium/Makefile.am +31 -6
  50. data/vendor/libsodium/src/libsodium/Makefile.in +238 -42
  51. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +234 -38
  52. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +208 -118
  53. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -2
  54. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +1 -4
  55. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1799 -1790
  56. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.h +39 -39
  57. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +86 -0
  58. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +28 -0
  59. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +38 -46
  60. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +47 -55
  61. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +47 -55
  62. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +47 -55
  63. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +7 -0
  64. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -89
  65. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +50 -141
  66. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +45 -0
  67. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +123 -0
  68. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +3 -2
  69. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +2 -2
  70. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/{blake2b-round.h → blake2b-compress-sse41.h} +2 -28
  71. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +2 -4
  72. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +97 -0
  73. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +339 -0
  74. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -2
  75. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -2
  76. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +29 -18
  77. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +4 -43
  78. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +3 -32
  79. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -20
  80. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +22 -41
  81. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +12 -39
  82. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +2 -4
  83. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -20
  84. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +570 -0
  85. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +198 -0
  86. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +444 -0
  87. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +32 -0
  88. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +229 -0
  89. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +222 -0
  90. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +40 -0
  91. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +238 -0
  92. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +251 -0
  93. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +80 -0
  94. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.h +8 -0
  95. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +38 -0
  96. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +117 -0
  97. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +164 -0
  98. data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +106 -0
  99. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
  100. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -4
  101. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +186 -186
  102. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +2 -2
  103. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +3 -2
  104. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +33 -33
  105. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +253 -254
  106. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +16 -17
  107. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +1 -0
  108. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +11 -11
  109. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +1 -0
  110. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +1 -1
  111. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +3 -2
  112. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +5 -3
  113. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +41 -41
  114. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +10 -2
  115. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +1 -1
  116. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +4 -0
  117. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +4 -0
  118. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +31 -32
  119. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +4 -0
  120. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +1 -1
  121. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +4 -0
  122. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +1 -1
  123. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +1 -1
  124. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +1 -1
  125. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +2 -6
  126. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +8 -28
  127. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -0
  128. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +6 -6
  129. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +1 -18
  130. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +20 -20
  131. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +4 -4
  132. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +6 -6
  133. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +56 -77
  134. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +1 -0
  135. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +1 -0
  136. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -8
  137. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +2 -8
  138. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -8
  139. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -8
  140. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -8
  141. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -8
  142. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +1 -5
  143. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +1 -5
  144. data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -0
  145. data/vendor/libsodium/src/libsodium/include/Makefile.in +19 -8
  146. data/vendor/libsodium/src/libsodium/include/sodium.h +3 -0
  147. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +50 -0
  148. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +94 -22
  149. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +6 -6
  150. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hchacha20.h +35 -0
  151. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -0
  152. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +89 -0
  153. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +86 -0
  154. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +6 -6
  155. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +0 -11
  156. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
  157. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -0
  158. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +5 -1
  159. data/vendor/libsodium/src/libsodium/sodium/common.h +150 -0
  160. data/vendor/libsodium/src/libsodium/sodium/core.c +3 -1
  161. data/vendor/libsodium/src/libsodium/sodium/runtime.c +37 -19
  162. data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -9
  163. data/vendor/libsodium/test/Makefile.in +9 -0
  164. data/vendor/libsodium/test/default/Makefile.am +10 -0
  165. data/vendor/libsodium/test/default/Makefile.in +53 -20
  166. data/vendor/libsodium/test/default/aead_aes256gcm.c +43 -17
  167. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +179 -86
  168. data/vendor/libsodium/test/default/auth7.c +5 -5
  169. data/vendor/libsodium/test/default/box.c +4 -4
  170. data/vendor/libsodium/test/default/box2.c +1 -1
  171. data/vendor/libsodium/test/default/core6.c +1 -1
  172. data/vendor/libsodium/test/default/generichash.c +12 -1
  173. data/vendor/libsodium/test/default/generichash2.c +2 -2
  174. data/vendor/libsodium/test/default/generichash3.c +21 -0
  175. data/vendor/libsodium/test/default/pwhash.c +186 -168
  176. data/vendor/libsodium/test/default/pwhash.exp +11 -30
  177. data/vendor/libsodium/test/default/pwhash_scrypt.c +349 -0
  178. data/vendor/libsodium/test/default/pwhash_scrypt.exp +31 -0
  179. data/vendor/libsodium/test/default/secretbox.c +1 -1
  180. data/vendor/libsodium/test/default/secretbox2.c +1 -1
  181. data/vendor/libsodium/test/default/sign.c +15 -0
  182. data/vendor/libsodium/test/default/sodium_utils2.c +8 -3
  183. data/vendor/libsodium/test/default/sodium_utils3.c +4 -2
  184. data/vendor/libsodium/test/default/verify1.c +0 -4
  185. data/vendor/libsodium/test/quirks/quirks.h +3 -0
  186. metadata +37 -22
  187. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +0 -43
  188. data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +0 -78
  189. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +0 -244
  190. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +0 -192
  191. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +0 -43
  192. data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +0 -78
  193. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +0 -244
  194. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +0 -192
  195. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +0 -43
  196. data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +0 -78
  197. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +0 -244
  198. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +0 -192
  199. data/vendor/libsodium/builds/msvc/vs2015/test/test.props +0 -43
  200. data/vendor/libsodium/builds/msvc/vs2015/test/test.runner.bat +0 -78
  201. data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +0 -244
  202. data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +0 -192
  203. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +0 -146
  204. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +0 -64
@@ -8,25 +8,25 @@ static unsigned char a[64];
8
8
 
9
9
  int main(void)
10
10
  {
11
- int clen;
11
+ size_t clen;
12
12
 
13
13
  for (clen = 0; clen < sizeof c; ++clen) {
14
14
  randombytes_buf(key, sizeof key);
15
15
  randombytes_buf(c, clen);
16
16
  crypto_auth_hmacsha512(a, c, clen, key);
17
17
  if (crypto_auth_hmacsha512_verify(a, c, clen, key) != 0) {
18
- printf("fail %d\n", clen);
18
+ printf("fail %u\n", (unsigned int) clen);
19
19
  return 100;
20
20
  }
21
21
  if (clen > 0) {
22
- c[rand() % clen] += 1 + (rand() % 255);
22
+ c[(size_t) rand() % clen] += 1 + (rand() % 255);
23
23
  if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) {
24
- printf("forgery %d\n", clen);
24
+ printf("forgery %u\n", (unsigned int) clen);
25
25
  return 100;
26
26
  }
27
27
  a[rand() % sizeof a] += 1 + (rand() % 255);
28
28
  if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) {
29
- printf("forgery %d\n", clen);
29
+ printf("forgery %u\n", (unsigned int) clen);
30
30
  return 100;
31
31
  }
32
32
  }
@@ -22,7 +22,7 @@ static const unsigned char nonce[24]
22
22
  0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
23
23
  0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
24
24
 
25
- // API requires first 32 bytes to be 0
25
+ /* API requires first 32 bytes to be 0 */
26
26
  static const unsigned char m[163]
27
27
  = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28
28
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -55,12 +55,12 @@ int main(void)
55
55
  printf("\n");
56
56
  }
57
57
  printf("\n");
58
-
58
+
59
59
  ret = crypto_box(c, m, 163, nonce, small_order_p, alicesk);
60
60
  assert(ret == -1);
61
61
 
62
62
  memset(c, 0, sizeof c);
63
-
63
+
64
64
  ret = crypto_box_beforenm(k, bobpk, alicesk);
65
65
  assert(ret == 0);
66
66
  crypto_box_afternm(c, m, 163, nonce, k);
@@ -70,7 +70,7 @@ int main(void)
70
70
  printf("\n");
71
71
  }
72
72
  printf("\n");
73
-
73
+
74
74
  ret = crypto_box_beforenm(k, small_order_p, alicesk);
75
75
  assert(ret == -1);
76
76
 
@@ -22,7 +22,7 @@ static unsigned char nonce[24]
22
22
  0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
23
23
  0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
24
24
 
25
- // API requires first 16 bytes to be 0
25
+ /* API requires first 16 bytes to be 0 */
26
26
  static unsigned char c[163]
27
27
  = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28
28
  0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
@@ -17,7 +17,7 @@ static unsigned char c[16]
17
17
 
18
18
  static unsigned char out[64];
19
19
 
20
- void print(unsigned char *x, unsigned char *y)
20
+ static void print(unsigned char *x, unsigned char *y)
21
21
  {
22
22
  int i;
23
23
  unsigned int borrow = 0;
@@ -1291,7 +1291,7 @@ static struct {
1291
1291
  }
1292
1292
  };
1293
1293
 
1294
- int
1294
+ static int
1295
1295
  tv(void)
1296
1296
  {
1297
1297
  unsigned char *expected_out;
@@ -1366,6 +1366,17 @@ main(void)
1366
1366
  printf("%02x", (unsigned int) out[j]);
1367
1367
  }
1368
1368
  printf("\n");
1369
+
1370
+ assert(crypto_generichash(NULL, 0,
1371
+ in, (unsigned long long) sizeof in,
1372
+ k, sizeof k) == -1);
1373
+ assert(crypto_generichash(NULL, crypto_generichash_BYTES_MAX + 1,
1374
+ in, (unsigned long long) sizeof in,
1375
+ k, sizeof k) == -1);
1376
+ assert(crypto_generichash(NULL, (unsigned long long) sizeof in,
1377
+ in, (unsigned long long) sizeof in,
1378
+ k, crypto_generichash_KEYBYTES_MAX + 1) == -1);
1379
+
1369
1380
  assert(crypto_generichash_bytes_min() > 0U);
1370
1381
  assert(crypto_generichash_bytes_max() > 0U);
1371
1382
  assert(crypto_generichash_bytes() > 0U);
@@ -13,10 +13,10 @@ main(void)
13
13
 
14
14
  assert(crypto_generichash_statebytes() >= sizeof st);
15
15
  for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
16
- k[h] = h;
16
+ k[h] = (unsigned char) h;
17
17
 
18
18
  for (i = 0; i < MAXLEN; ++i) {
19
- in[i] = i;
19
+ in[i] = (unsigned char) i;
20
20
  if (crypto_generichash_init(&st, k,
21
21
  1 + i % crypto_generichash_KEYBYTES_MAX,
22
22
  1 + i % crypto_generichash_BYTES_MAX) != 0) {
@@ -20,6 +20,7 @@ main(void)
20
20
  size_t i;
21
21
  size_t j;
22
22
 
23
+ assert(crypto_generichash_blake2b_statebytes() >= sizeof st);
23
24
  for (h = 0; h < crypto_generichash_blake2b_KEYBYTES_MAX; ++h) {
24
25
  k[h] = (unsigned char) h;
25
26
  }
@@ -129,6 +130,19 @@ main(void)
129
130
  }
130
131
  printf("\n");
131
132
 
133
+ assert(crypto_generichash_blake2b_salt_personal
134
+ (NULL, 0,
135
+ in, (unsigned long long) sizeof in,
136
+ k, sizeof k, NULL, NULL) == -1);
137
+ assert(crypto_generichash_blake2b_salt_personal
138
+ (NULL, crypto_generichash_BYTES_MAX + 1,
139
+ in, (unsigned long long) sizeof in,
140
+ k, sizeof k, NULL, NULL) == -1);
141
+ assert(crypto_generichash_blake2b_salt_personal
142
+ (NULL, (unsigned long long) sizeof in,
143
+ in, (unsigned long long) sizeof in,
144
+ k, crypto_generichash_KEYBYTES_MAX + 1, NULL, NULL) == -1);
145
+
132
146
  crypto_generichash_blake2b_init_salt_personal(&st, NULL, 0U, crypto_generichash_BYTES,
133
147
  NULL, personal);
134
148
  crypto_generichash_blake2b_update(&st, in, MAXLEN);
@@ -147,6 +161,13 @@ main(void)
147
161
  }
148
162
  printf("\n");
149
163
 
164
+ assert(crypto_generichash_blake2b_init_salt_personal
165
+ (&st, k, sizeof k, 0, NULL, NULL) == -1);
166
+ assert(crypto_generichash_blake2b_init_salt_personal
167
+ (&st, k, sizeof k, crypto_generichash_blake2b_BYTES_MAX + 1, NULL, NULL) == -1);
168
+ assert(crypto_generichash_blake2b_init_salt_personal
169
+ (&st, k, crypto_generichash_blake2b_KEYBYTES_MAX + 1, sizeof out, NULL, NULL) == -1);
170
+
150
171
  assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, crypto_generichash_BYTES,
151
172
  NULL, personal) == 0);
152
173
  assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, crypto_generichash_BYTES,
@@ -3,8 +3,8 @@
3
3
  #include "cmptest.h"
4
4
 
5
5
  #define OUT_LEN 128
6
- #define OPSLIMIT 1000000
7
- #define MEMLIMIT 10000000
6
+ #define OPSLIMIT 3
7
+ #define MEMLIMIT 5000000
8
8
 
9
9
  static void tv(void)
10
10
  {
@@ -15,6 +15,7 @@ static void tv(void)
15
15
  size_t outlen;
16
16
  unsigned long long opslimit;
17
17
  size_t memlimit;
18
+ unsigned int lanes;
18
19
  } tests[] = {
19
20
  { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
20
21
  "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
@@ -22,13 +23,13 @@ static void tv(void)
22
23
  "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
23
24
  127,
24
25
  "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
25
- 155, 481326, 7256678 },
26
+ 155, 5, 7256678, 1 },
26
27
  { "e125cee61c8cb7778d9e5ad0a6f5d978ce9f84de213a8556d9ffe202020ab4a6ed"
27
28
  "9074a4eb3416f9b168f137510f3a30b70b96cbfa219ff99f6c6eaffb15c06b60e0"
28
29
  "0cc2890277f0fd3c622115772f7048adaebed86e",
29
30
  86,
30
31
  "f1192dd5dc2368b9cd421338b22433455ee0a3699f9379a08b9650ea2c126f0d",
31
- 250, 535778, 7849083 },
32
+ 250, 4, 7849083, 1 },
32
33
  { "92263cbf6ac376499f68a4289d3bb59e5a22335eba63a32e6410249155b956b6a3"
33
34
  "b48d4a44906b18b897127300b375b8f834f1ceffc70880a885f47c33876717e392"
34
35
  "be57f7da3ae58da4fd1f43daa7e44bb82d3717af4319349c24cd31e46d295856b0"
@@ -37,7 +38,7 @@ static void tv(void)
37
38
  "711f58c8c392016b2fdfc09c64f0f6b6ab7b",
38
39
  183,
39
40
  "3b840e20e9555e9fb031c4ba1f1747ce25cc1d0ff664be676b9b4a90641ff194",
40
- 249, 311757, 7994791 },
41
+ 249, 3, 7994791, 1 },
41
42
  { "027b6d8e8c8c474e9b69c7d9ed4f9971e8e1ce2f6ba95048414c3970f0f09b70e3"
42
43
  "b6c5ae05872b3d8678705b7d381829c351a5a9c88c233569b35d6b0b809df44b64"
43
44
  "51a9c273f1150e2ef8a0b5437eb701e373474cd44b97ef0248ebce2ca0400e1b53"
@@ -45,19 +46,13 @@ static void tv(void)
45
46
  "9bb078ed1f0d31e7f9b8062409f37f19f8550aae",
46
47
  152,
47
48
  "eb2a3056a09ad2d7d7f975bcd707598f24cd32518cde3069f2e403b34bfee8a5",
48
- 5, 643464, 1397645 },
49
+ 5, 4, 1397645, 1 },
49
50
  { "4a857e2ee8aa9b6056f2424e84d24a72473378906ee04a46cb05311502d5250b82"
50
51
  "ad86b83c8f20a23dbb74f6da60b0b6ecffd67134d45946ac8ebfb3064294bc097d"
51
52
  "43ced68642bfb8bbbdd0f50b30118f5e",
52
53
  82,
53
54
  "39d82eef32010b8b79cc5ba88ed539fbaba741100f2edbeca7cc171ffeabf258",
54
- 190, 758010, 5432947 },
55
- { "1845e375479537e9dd4f4486d5c91ac72775d66605eeb11a787b78a7745f1fd005"
56
- "2d526c67235dbae1b2a4d575a74cb551c8e9096c593a497aee74ba3047d911358e"
57
- "de57bc27c9ea1829824348daaab606217cc931dcb6627787bd6e4e5854f0e8",
58
- 97,
59
- "3ee91a805aa62cfbe8dce29a2d9a44373a5006f4a4ce24022aca9cecb29d1473",
60
- 212, 233177, 13101817 },
55
+ 190, 3, 1432947, 1 },
61
56
  { "c7b09aec680e7b42fedd7fc792e78b2f6c1bea8f4a884320b648f81e8cf515e8ba"
62
57
  "9dcfb11d43c4aae114c1734aa69ca82d44998365db9c93744fa28b63fd16000e82"
63
58
  "61cbbe083e7e2da1e5f696bde0834fe53146d7e0e35e7de9920d041f5a5621aabe"
@@ -65,19 +60,12 @@ static void tv(void)
65
60
  "089dbeb6d6342a909c1307b3fff5fe2cf4da56bdae50848f",
66
61
  156,
67
62
  "039c056d933b475032777edbaffac50f143f64c123329ed9cf59e3b65d3f43b6",
68
- 178, 234753, 4886999 },
69
- { "8f3a06e2fd8711350a517bb12e31f3d3423e8dc0bb14aac8240fca0995938d59bb"
70
- "37bd0a7dfc9c9cc0705684b46612e8c8b1d6655fb0f9887562bb9899791a0250d1"
71
- "320f945eda48cdc20c233f40a5bb0a7e3ac5ad7250ce684f68fc0b8c9633bfd75a"
72
- "ad116525af7bdcdbbdb4e00ab163fd4df08f243f12557e",
73
- 122,
74
- "90631f686a8c3dbc0703ffa353bc1fdf35774568ac62406f98a13ed8f47595fd",
75
- 55, 695191, 15738350 },
63
+ 178, 3, 4886999, 1 },
76
64
  { "b540beb016a5366524d4605156493f9874514a5aa58818cd0c6dfffaa9e90205f1"
77
65
  "7b",
78
66
  34,
79
67
  "44071f6d181561670bda728d43fb79b443bb805afdebaf98622b5165e01b15fb",
80
- 231, 78652, 6631659 },
68
+ 231, 1, 1631659, 1 },
81
69
  { "a14975c26c088755a8b715ff2528d647cd343987fcf4aa25e7194a8417fb2b4b3f"
82
70
  "7268da9f3182b4cfb22d138b2749d673a47ecc7525dd15a0a3c66046971784bb63"
83
71
  "d7eae24cc84f2631712075a10e10a96b0e0ee67c43e01c423cb9c44e5371017e9c"
@@ -87,10 +75,10 @@ static void tv(void)
87
75
  "55a3b4169f22cccb0745a2689407ea1901a0a766eb99",
88
76
  220,
89
77
  "3d968b2752b8838431165059319f3ff8910b7b8ecb54ea01d3f54769e9d98daf",
90
- 167, 717248, 10784179 },
78
+ 167, 3, 1784128, 1 },
91
79
  };
92
80
  char passwd[256];
93
- unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
81
+ unsigned char salt[crypto_pwhash_SALTBYTES];
94
82
  unsigned char out[256];
95
83
  char out_hex[256 * 2 + 1];
96
84
  size_t i = 0U;
@@ -101,12 +89,12 @@ static void tv(void)
101
89
  NULL, NULL);
102
90
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
103
91
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
104
- if (crypto_pwhash_scryptsalsa208sha256(
105
- out, (unsigned long long) tests[i].outlen,
106
- passwd, tests[i].passwdlen,
107
- (const unsigned char *) salt, tests[i].opslimit,
108
- tests[i].memlimit) != 0) {
109
- printf("pwhash failure\n");
92
+ if (crypto_pwhash(out, (unsigned long long) tests[i].outlen,
93
+ passwd, tests[i].passwdlen,
94
+ (const unsigned char *) salt, tests[i].opslimit,
95
+ tests[i].memlimit, crypto_pwhash_alg_default()) != 0) {
96
+ printf("[tv] pwhash failure (maybe intentional): [%u]\n", (unsigned int) i);
97
+ continue;
110
98
  }
111
99
  sodium_bin2hex(out_hex, sizeof out_hex, out, tests[i].outlen);
112
100
  printf("%s\n", out_hex);
@@ -122,6 +110,7 @@ static void tv2(void)
122
110
  size_t outlen;
123
111
  unsigned long long opslimit;
124
112
  size_t memlimit;
113
+ unsigned int lanes;
125
114
  } tests[] = {
126
115
  { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
127
116
  "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
@@ -129,17 +118,17 @@ static void tv2(void)
129
118
  "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
130
119
  127,
131
120
  "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
132
- 155, 64, 1397645 },
121
+ 155, 4, 1397645, 1 },
133
122
  { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
134
123
  "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
135
124
  "a232d76d52dfbca38ca8dcbd665b17d1665f7cf5fe59772ec909733b24de97d6f5"
136
125
  "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
137
126
  127,
138
127
  "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
139
- 155, 32768, 1397645 },
128
+ 155, 3, 1397645, 1 },
140
129
  };
141
130
  char passwd[256];
142
- unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
131
+ unsigned char salt[crypto_pwhash_SALTBYTES];
143
132
  unsigned char out[256];
144
133
  char out_hex[256 * 2 + 1];
145
134
  size_t i = 0U;
@@ -150,16 +139,41 @@ static void tv2(void)
150
139
  NULL, NULL);
151
140
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
152
141
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
153
- if (crypto_pwhash_scryptsalsa208sha256(
154
- out, (unsigned long long) tests[i].outlen,
155
- passwd, tests[i].passwdlen,
156
- (const unsigned char *) salt, tests[i].opslimit,
157
- tests[i].memlimit) != 0) {
158
- printf("pwhash failure\n");
142
+ if (crypto_pwhash(out, (unsigned long long) tests[i].outlen,
143
+ passwd, tests[i].passwdlen,
144
+ (const unsigned char *) salt, tests[i].opslimit,
145
+ tests[i].memlimit, crypto_pwhash_alg_default()) != 0) {
146
+ printf("[tv2] pwhash failure: [%u]\n", (unsigned int) i);
147
+ continue;
159
148
  }
160
149
  sodium_bin2hex(out_hex, sizeof out_hex, out, tests[i].outlen);
161
150
  printf("%s\n", out_hex);
162
151
  } while (++i < (sizeof tests) / (sizeof tests[0]));
152
+
153
+ if (crypto_pwhash(out, sizeof out, "password", strlen("password"),
154
+ salt, 3, 1ULL << 12, 0) != -1) {
155
+ printf("[tv2] pwhash should have failed (0)\n");
156
+ }
157
+ if (crypto_pwhash(out, sizeof out, "password", strlen("password"),
158
+ salt, 3, 1, crypto_pwhash_alg_default()) != -1) {
159
+ printf("[tv2] pwhash should have failed (1)\n");
160
+ }
161
+ if (crypto_pwhash(out, sizeof out, "password", strlen("password"),
162
+ salt, 3, 1ULL << 12, crypto_pwhash_alg_default()) != -1) {
163
+ printf("[tv2] pwhash should have failed (2)\n");
164
+ }
165
+ if (crypto_pwhash(out, sizeof out, "password", strlen("password"),
166
+ salt, 2, 1ULL << 12, crypto_pwhash_alg_default()) != -1) {
167
+ printf("[tv2] pwhash should have failed (3)\n");
168
+ }
169
+ if (crypto_pwhash(out, 0x100000000ULL, "password", strlen("password"),
170
+ salt, 3, 1ULL << 12, crypto_pwhash_alg_default()) != -1) {
171
+ printf("[tv2] pwhash with a long output length should have failed\n");
172
+ }
173
+ if (crypto_pwhash(out, sizeof out, "password", 0x100000000ULL,
174
+ salt, 3, 1ULL << 12, crypto_pwhash_alg_default()) != -1) {
175
+ printf("[tv2] pwhash with a long password length should have failed\n");
176
+ }
163
177
  }
164
178
 
165
179
  static void tv3(void)
@@ -168,103 +182,15 @@ static void tv3(void)
168
182
  const char *passwd;
169
183
  const char *out;
170
184
  } tests[] = {
171
- { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg "
172
- "nrDFal+Jxl3,2`#^tFSu%v_+7iYse8-cCkNf!tD=KrW)",
173
- "$7$B6....1....75gBMAGwfFWZqBdyF3WdTQnWdUsuTiWjG1fF9c1jiSD$tc8RoB3."
174
- "Em3/zNgMLWo2u00oGIoTyJv4fl3Fl8Tix72" },
175
- { "bl72h6#y<':MFRZ>B IA1=NRkCKS%W8`1I.2uQxJN0g)N N aTt^4K!Iw5r "
176
- "H6;crDsv^a55j9tsk'/GqweZn;cdk6+F_St6:#*=?ZCD_lw>.",
177
- "$7$A6....3....Iahc6qM0.UQJHVgE4h9oa1/"
178
- "4OWlWLm9CCtfguvz6bQD$QnXCo3M7nIqtry2WKsUZ5gQ.mY0wAlJu."
179
- "WUhtE8vF66" },
180
- { "Py "
181
- ">e.5b+tLo@rL`dC2k@eJ&4eVl!W=JJ4+k&mAt@gt',FS1JjqKW3aq21:]^kna`"
182
- "mde7kVkN5NrpKUptu)@4*b&?BE_sJMG1=&@`3GBCV]Wg7xwgo7x3El",
183
- "$7$96..../....f6bEusKt79kK4wdYN0ki2nw4bJQ7P3rN6k3BSigsK/"
184
- "D$Dsvuw7vXj5xijmrb/NOhdgoyK/OiSIYv88cEtl9Cik7" },
185
- { "2vj;Um]FKOL27oam(:Uo8+UmSTvb1FD*h?jk_,S=;RDgF-$Fjk?]9yvfxe@fN^!NN("
186
- "Cuml?+2Raa",
187
- "$7$86....I....7XwIxLtCx4VphmFeUa6OGuGJrFaIaYzDiLNu/"
188
- "tyUPhD$U3q5GCEqCWxMwh.YQHDJrlg7FIZgViv9pcXE3h1vg61" },
189
- { "CT=[9uUoGav,J`kU+348tA50ue#sL:ABZ3QgF+r[#vh:tTOiL>s8tv%,Jeo]jH/"
190
- "_4^i(*jD-_ku[9Ko[=86 06V",
191
- "$7$A6....2....R3.bjH6YS9wz9z8Jsj.3weGQ3J80ZZElGw2oVux1TP6$"
192
- "i5u6lFzXDHaIgYEICinLD6WNaovbiXP8SnLrDRdKgA9" },
193
- { "J#wNn`hDgOpTHNI.w^1a70%f,.9V_m038H_JIJQln`vdWnn/"
194
- "rmILR?9H5g(+`;@H(2VosN9Fgk[WEjaBr'yB9Q19-imNa04[Mk5kvGcSn-TV",
195
- "$7$B6....1....Dj1y.4mF1J9XmT/6IDskYdCLaPFJTq9xcCwXQ1DpT92$92/"
196
- "hYfZLRq1nTLyIz.uc/dC6wLqwnsoqpkadrCXusm6" },
197
- { "j4BS38Asa;p)[K+9TY!3YDj<LK-`nLVXQw9%*QfM",
198
- "$7$B6....1....5Ods8mojVwXJq4AywF/uI9BdMSiJ/zT8hQP/"
199
- "4cB68VC$nk4ExHNXJ802froj51/1wJTrSZvTIyyK7PecOxRRaz0" },
200
- { "M.R>Qw+!qJb]>pP :_.9`dxM9k [eR7Y!yL-3)sNs[R,j_/^ "
201
- "TH=5ny'15>6UXWcQW^6D%XCsO[vN[%ReA-`tV1vW(Nt*0KVK#]45P_A",
202
- "$7$B6....1....D/"
203
- "eyk8N5y6Z8YVQEsw521cTx.9zzLuK7YDs1KMMh.o4$alfW8ZbsUWnXc."
204
- "vqon2zoljVk24Tt1.IsCuo2KurvS2" },
205
- { "K3S=KyH#)36_?]LxeR8QNKw6X=gFb'ai$C%29V* "
206
- "tyh^Wo$TN-#Q4qkmtTCf0LLb.^E$0uykkP",
207
- "$7$B6....1....CuBuU97xgAage8whp/"
208
- "JNKobo0TFbsORGVbfcQIefyP8$aqalP."
209
- "XofGViB8EPLONqHma8vs1xc9uTIMYh9CgE.S8" },
210
- { "Y0!?iQa9M%5ekffW(`",
211
- "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
212
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
213
-
214
- /* Invalid pwhash strings */
215
-
216
- { "Y0!?iQa9M%5ekffW(`",
217
- "$7$A6....1....$TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4"
218
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
219
- { "Y0!?iQa9M%5ekffW(`",
220
- "$7$.6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
221
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
222
- { "Y0!?iQa9M%5ekffW(`",
223
- "$7$A.....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
224
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
225
- { "Y0!?iQa9M%5ekffW(`",
226
- "$7$A6.........TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
227
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
228
- { "Y0!?iQa9M%5ekffW(`",
229
- "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i44269$"
230
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AH" },
231
- { "Y0!?iQa9M%5ekffW(`",
232
- "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
233
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx54269" },
234
- { "Y0!?iQa9M%5ekffW(`",
235
- "$7^A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
236
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
237
- { "Y0!?iQa9M%5ekffW(`",
238
- "$7$!6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
239
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
240
- { "Y0!?iQa9M%5ekffW(`",
241
- "$7$A!....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
242
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
243
- { "Y0!?iQa9M%5ekffW(`",
244
- "$7$A6....!....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
245
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
246
- { "",
247
- "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
248
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
249
- { "Y0!?iQa9M%5ekffW(`",
250
- "$7fA6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4#"
251
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
252
- { "Y0!?iQa9M%5ekffW(`",
253
- "$7$AX....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
254
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
255
- { "Y0!?iQa9M%5ekffW(`",
256
- "$7$A6....1!...TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
257
- "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
258
- { "Y0!?iQa9M%5ekffW(`",
259
- "$7$A6....1" },
260
- { "Y0!?iQa9M%5ekffW(`",
261
- "$7$" },
262
- { "Y0!?iQa9M%5ekffW(`",
263
- "" },
264
- { "Y0!?iQa9M%5ekffW(`",
265
- "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
266
- "" },
267
- };
185
+ { "",
186
+ "$argon2i$v=19$m=4096,t=1,p=1$X1NhbHQAAAAAAAAAAAAAAA$bWh++MKN1OiFHKgIWTLvIi1iHicmHH7+Fv3K88ifFfI" },
187
+ { "",
188
+ "$argon2i$v=19$m=2048,t=4,p=1$SWkxaUhpY21ISDcrRnYzSw$Mbg/Eck1kpZir5T9io7C64cpffdTBaORgyriLQFgQj8" },
189
+ { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg ",
190
+ "$argon2i$v=19$m=4096,t=3,p=2$X1NhbHQAAAAAAAAAAAAAAA$z/QMiU4lQxGsYNc/+K/bizwsA1P11UG2dj/7+aILJ4I" },
191
+ { "K3S=KyH#)36_?]LxeR8QNKw6X=gFbxai$C%29V*",
192
+ "$argon2i$v=19$m=4096,t=3,p=1$X1NhbHQAAAAAAAAAAAAAAA$fu2Wsecyt+yPnBvSvYN16oP5ozRmkp0ixJ1YL19V3Uo" }
193
+ };
268
194
  char *out;
269
195
  char *passwd;
270
196
  size_t i = 0U;
@@ -276,9 +202,10 @@ static void tv3(void)
276
202
  passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
277
203
  assert(passwd != NULL);
278
204
  memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
279
- if (crypto_pwhash_scryptsalsa208sha256_str_verify
205
+ if (crypto_pwhash_str_verify
280
206
  (out, passwd, strlen(passwd)) != 0) {
281
- printf("pwhash_str failure: [%u]\n", (unsigned int)i);
207
+ printf("[tv3] pwhash_str failure (maybe intentional): [%u]\n", (unsigned int) i);
208
+ continue;
282
209
  }
283
210
  sodium_free(out);
284
211
  sodium_free(passwd);
@@ -295,49 +222,140 @@ int main(void)
295
222
  tv();
296
223
  tv2();
297
224
  tv3();
298
- salt = (char *)
299
- sodium_malloc(crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
300
- str_out = (char *)
301
- sodium_malloc(crypto_pwhash_scryptsalsa208sha256_STRBYTES);
302
- str_out2 = (char *)
303
- sodium_malloc(crypto_pwhash_scryptsalsa208sha256_STRBYTES);
304
- memcpy(salt, "[<~A 32-bytes salt for scrypt~>]",
305
- crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
306
- if (crypto_pwhash_scryptsalsa208sha256_str(str_out, passwd, strlen(passwd),
307
- OPSLIMIT, MEMLIMIT) != 0) {
225
+ salt = (char *) sodium_malloc(crypto_pwhash_SALTBYTES);
226
+ str_out = (char *) sodium_malloc(crypto_pwhash_STRBYTES);
227
+ str_out2 = (char *) sodium_malloc(crypto_pwhash_STRBYTES);
228
+ memcpy(salt, ">A 16-bytes salt", crypto_pwhash_SALTBYTES);
229
+ if (crypto_pwhash_str(str_out, passwd, strlen(passwd),
230
+ OPSLIMIT, MEMLIMIT) != 0) {
308
231
  printf("pwhash_str failure\n");
232
+ return 1;
309
233
  }
310
- if (crypto_pwhash_scryptsalsa208sha256_str(str_out2, passwd, strlen(passwd),
311
- OPSLIMIT, MEMLIMIT) != 0) {
234
+ if (crypto_pwhash_str(str_out2, passwd, strlen(passwd),
235
+ OPSLIMIT, MEMLIMIT) != 0) {
312
236
  printf("pwhash_str(2) failure\n");
237
+ return 1;
313
238
  }
314
239
  if (strcmp(str_out, str_out2) == 0) {
315
- printf("pwhash_str doesn't generate different salts\n");
240
+ printf("pwhash_str() doesn't generate different salts\n");
316
241
  }
317
- if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
318
- strlen(passwd)) != 0) {
319
- printf("pwhash_str_verify failure\n");
242
+ if (sodium_is_zero((const unsigned char *) str_out + strlen(str_out),
243
+ crypto_pwhash_STRBYTES - strlen(str_out)) != 1 ||
244
+ sodium_is_zero((const unsigned char *) str_out2 + strlen(str_out2),
245
+ crypto_pwhash_STRBYTES - strlen(str_out2)) != 1) {
246
+ printf("pwhash_str() doesn't properly pad with zeros\n");
320
247
  }
321
- if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
322
- strlen(passwd)) != 0) {
323
- printf("pwhash_str_verify failure\n");
248
+ if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != 0) {
249
+ printf("pwhash_str_verify(1) failure\n");
324
250
  }
325
251
  str_out[14]++;
326
- if (crypto_pwhash_scryptsalsa208sha256_str_verify(
327
- str_out, passwd, strlen(passwd)) == 0) {
252
+ if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != -1) {
328
253
  printf("pwhash_str_verify(2) failure\n");
329
254
  }
330
255
  str_out[14]--;
256
+ assert(str_out[crypto_pwhash_STRBYTES - 1U] == 0);
257
+
258
+ if (crypto_pwhash_str(str_out2, passwd, 0x100000000ULL,
259
+ OPSLIMIT, MEMLIMIT) != -1) {
260
+ printf("pwhash_str() with a large password should have failed\n");
261
+ return 1;
262
+ }
263
+ if (crypto_pwhash_str(str_out2, passwd, strlen(passwd),
264
+ 1, MEMLIMIT) != -1) {
265
+ printf("pwhash_str() with a small opslimit should have failed\n");
266
+ return 1;
267
+ }
268
+ if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
269
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
270
+ "password", 0x100000000ULL) != -1) {
271
+ printf("pwhash_str_verify(invalid(0)) failure\n");
272
+ }
273
+ if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
274
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
275
+ "password", strlen("password")) != -1) {
276
+ printf("pwhash_str_verify(invalid(1)) failure\n");
277
+ }
278
+ if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
279
+ "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
280
+ "password", strlen("password")) != -1) {
281
+ printf("pwhash_str_verify(invalid(2)) failure\n");
282
+ }
283
+ if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
284
+ "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
285
+ "password", strlen("password")) != -1) {
286
+ printf("pwhash_str_verify(invalid(3)) failure\n");
287
+ }
288
+ if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
289
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
290
+ "password", strlen("password")) != -1) {
291
+ printf("pwhash_str_verify(invalid(4)) failure\n");
292
+ }
293
+ if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
294
+ "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
295
+ "password", strlen("password")) != -1) {
296
+ printf("pwhash_str_verify(invalid(5)) failure\n");
297
+ }
298
+ if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
299
+ "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
300
+ "password", strlen("password")) != -1) {
301
+ printf("pwhash_str_verify(invalid(6)) failure\n");
302
+ }
303
+ if (crypto_pwhash_str_verify("$argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
304
+ "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
305
+ "password", strlen("password")) != 0) {
306
+ printf("pwhash_str_verify(valid(7)) failure\n");
307
+ }
308
+ if (crypto_pwhash_str_verify("$argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
309
+ "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
310
+ "passwore", strlen("passwore")) != -1) {
311
+ printf("pwhash_str_verify(invalid(7)) failure\n");
312
+ }
313
+ if (crypto_pwhash_str_verify("$Argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
314
+ "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
315
+ "password", strlen("password")) != -1) {
316
+ printf("pwhash_str_verify(invalid(8)) failure\n");
317
+ }
318
+ if (crypto_pwhash_str_verify("$argon2i$v=1$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
319
+ "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
320
+ "password", strlen("password")) != -1) {
321
+ printf("pwhash_str_verify(invalid(9)) failure\n");
322
+ }
323
+ assert(crypto_pwhash_saltbytes() > 0U);
324
+ assert(crypto_pwhash_strbytes() > 1U);
325
+ assert(crypto_pwhash_strbytes() > strlen(crypto_pwhash_strprefix()));
326
+ assert(crypto_pwhash_opslimit_interactive() > 0U);
327
+ assert(crypto_pwhash_memlimit_interactive() > 0U);
328
+ assert(crypto_pwhash_opslimit_moderate() > 0U);
329
+ assert(crypto_pwhash_memlimit_moderate() > 0U);
330
+ assert(crypto_pwhash_opslimit_sensitive() > 0U);
331
+ assert(crypto_pwhash_memlimit_sensitive() > 0U);
332
+ assert(strcmp(crypto_pwhash_primitive(), "argon2i") == 0);
333
+
334
+ assert(crypto_pwhash_opslimit_interactive() == crypto_pwhash_OPSLIMIT_INTERACTIVE);
335
+ assert(crypto_pwhash_memlimit_interactive() == crypto_pwhash_MEMLIMIT_INTERACTIVE);
336
+ assert(crypto_pwhash_opslimit_moderate() == crypto_pwhash_OPSLIMIT_MODERATE);
337
+ assert(crypto_pwhash_memlimit_moderate() == crypto_pwhash_MEMLIMIT_MODERATE);
338
+ assert(crypto_pwhash_opslimit_sensitive() == crypto_pwhash_OPSLIMIT_SENSITIVE);
339
+ assert(crypto_pwhash_memlimit_sensitive() == crypto_pwhash_MEMLIMIT_SENSITIVE);
331
340
 
332
- assert(str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U] == 0);
333
- assert(crypto_pwhash_scryptsalsa208sha256_saltbytes() > 0U);
334
- assert(crypto_pwhash_scryptsalsa208sha256_strbytes() > 1U);
335
- assert(crypto_pwhash_scryptsalsa208sha256_strbytes() >
336
- strlen(crypto_pwhash_scryptsalsa208sha256_strprefix()));
337
- assert(crypto_pwhash_scryptsalsa208sha256_opslimit_interactive() > 0U);
338
- assert(crypto_pwhash_scryptsalsa208sha256_memlimit_interactive() > 0U);
339
- assert(crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive() > 0U);
340
- assert(crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive() > 0U);
341
+ assert(crypto_pwhash_argon2i_saltbytes() == crypto_pwhash_saltbytes());
342
+ assert(crypto_pwhash_argon2i_strbytes() == crypto_pwhash_strbytes());
343
+ assert(strcmp(crypto_pwhash_argon2i_strprefix(), crypto_pwhash_strprefix()) == 0);
344
+ assert(crypto_pwhash_argon2i_opslimit_interactive() ==
345
+ crypto_pwhash_opslimit_interactive());
346
+ assert(crypto_pwhash_argon2i_opslimit_moderate() ==
347
+ crypto_pwhash_opslimit_moderate());
348
+ assert(crypto_pwhash_argon2i_opslimit_sensitive() ==
349
+ crypto_pwhash_opslimit_sensitive());
350
+ assert(crypto_pwhash_argon2i_memlimit_interactive() ==
351
+ crypto_pwhash_memlimit_interactive());
352
+ assert(crypto_pwhash_argon2i_memlimit_moderate() ==
353
+ crypto_pwhash_memlimit_moderate());
354
+ assert(crypto_pwhash_argon2i_memlimit_sensitive() ==
355
+ crypto_pwhash_memlimit_sensitive());
356
+ assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_argon2i_alg_argon2i13());
357
+ assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_ALG_ARGON2I13);
358
+ assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_alg_default());
341
359
 
342
360
  sodium_free(salt);
343
361
  sodium_free(str_out);