rbnacl-libsodium 1.0.13 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/lib/rbnacl/libsodium.rb +1 -0
  4. data/lib/rbnacl/libsodium/version.rb +1 -1
  5. data/vendor/libsodium/AUTHORS +2 -2
  6. data/vendor/libsodium/ChangeLog +64 -0
  7. data/vendor/libsodium/Makefile.am +1 -0
  8. data/vendor/libsodium/README.markdown +1 -3
  9. data/vendor/libsodium/THANKS +13 -3
  10. data/vendor/libsodium/builds/Makefile.am +65 -0
  11. data/vendor/libsodium/builds/msvc/resource.rc +2 -2
  12. data/vendor/libsodium/builds/msvc/version.h +3 -3
  13. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +168 -173
  14. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +382 -394
  15. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +168 -173
  16. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +382 -394
  17. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +168 -173
  18. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +382 -394
  19. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +168 -173
  20. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +382 -394
  21. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +168 -173
  22. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +382 -394
  23. data/vendor/libsodium/configure.ac +59 -10
  24. data/vendor/libsodium/contrib/Findsodium.cmake +2 -0
  25. data/vendor/libsodium/dist-build/emscripten-symbols.def +72 -32
  26. data/vendor/libsodium/dist-build/emscripten.sh +33 -6
  27. data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +52 -38
  28. data/vendor/libsodium/dist-build/ios.sh +2 -2
  29. data/vendor/libsodium/libsodium.vcxproj +168 -173
  30. data/vendor/libsodium/libsodium.vcxproj.filters +220 -235
  31. data/vendor/libsodium/m4/ax_check_catchable_abrt.m4 +57 -0
  32. data/vendor/libsodium/m4/ax_check_gnu_make.m4 +2 -2
  33. data/vendor/libsodium/m4/ax_pthread.m4 +2 -2
  34. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  35. data/vendor/libsodium/packaging/dotnet-core/README.md +5 -5
  36. data/vendor/libsodium/packaging/dotnet-core/libsodium.props +5 -2
  37. data/vendor/libsodium/packaging/dotnet-core/prepare.py +13 -31
  38. data/vendor/libsodium/packaging/dotnet-core/recipes/linux-x64 +4 -0
  39. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  40. data/vendor/libsodium/src/libsodium/Makefile.am +11 -12
  41. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +11 -4
  42. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +17 -4
  43. data/vendor/libsodium/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +8 -1
  44. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +6 -0
  45. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +5 -4
  46. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +11 -4
  47. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +6 -0
  48. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +78 -17
  49. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +74 -64
  50. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +2 -0
  51. data/vendor/libsodium/src/libsodium/crypto_kx/crypto_kx.c +7 -0
  52. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +1 -1
  53. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +1 -0
  54. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +17 -17
  55. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +53 -48
  56. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +37 -11
  57. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +23 -179
  58. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx2.c +4 -12
  59. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx512f.c +244 -0
  60. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +3 -12
  61. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +4 -12
  62. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +1 -5
  63. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +1 -1
  64. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-avx512f.h +145 -0
  65. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +91 -14
  66. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +35 -14
  67. data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +41 -4
  68. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +31 -17
  69. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -0
  70. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +5 -1
  71. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +30 -1
  72. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +8 -0
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +3 -3
  74. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +6 -0
  75. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +5 -4
  76. data/vendor/libsodium/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +11 -4
  77. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +6 -0
  78. data/vendor/libsodium/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +311 -0
  79. data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +6 -0
  80. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ed25519_ref10.h +3 -0
  81. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +9 -2
  82. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +1 -1
  83. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +6 -5
  84. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +6 -0
  85. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c +3 -2
  86. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c +3 -2
  87. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u0.h +1 -1
  88. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.c +3 -2
  89. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +12 -0
  90. data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +6 -0
  91. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +7 -1
  92. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u0.h +1 -1
  93. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +6 -0
  94. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +6 -0
  95. data/vendor/libsodium/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +6 -0
  96. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +6 -0
  97. data/vendor/libsodium/src/libsodium/crypto_verify/sodium/verify.c +66 -29
  98. data/vendor/libsodium/src/libsodium/include/Makefile.am +1 -1
  99. data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
  100. data/vendor/libsodium/src/libsodium/include/sodium/core.h +9 -0
  101. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +26 -0
  102. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +16 -4
  103. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +10 -4
  104. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +4 -0
  105. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +6 -0
  106. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +24 -15
  107. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +8 -4
  108. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +40 -18
  109. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +8 -2
  110. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +8 -2
  111. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +11 -3
  112. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +4 -0
  113. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +6 -0
  114. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +17 -8
  115. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h +102 -0
  116. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +4 -0
  117. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +4 -0
  118. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +1 -0
  119. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +4 -0
  120. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +10 -0
  121. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +4 -0
  122. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +4 -0
  123. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +15 -5
  124. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xchacha20.h +4 -0
  125. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +4 -0
  126. data/vendor/libsodium/src/libsodium/include/sodium/export.h +9 -0
  127. data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +11 -0
  128. data/vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h +2 -30
  129. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +2 -0
  130. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +12 -9
  131. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +36 -0
  132. data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -2
  133. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +18 -14
  134. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +11 -10
  135. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +20 -8
  136. data/vendor/libsodium/src/libsodium/sodium/codecs.c +333 -0
  137. data/vendor/libsodium/src/libsodium/sodium/core.c +36 -4
  138. data/vendor/libsodium/src/libsodium/sodium/runtime.c +18 -0
  139. data/vendor/libsodium/src/libsodium/sodium/utils.c +87 -100
  140. data/vendor/libsodium/test/constcheck.sh +19 -0
  141. data/vendor/libsodium/test/default/Makefile.am +39 -7
  142. data/vendor/libsodium/test/default/aead_aes256gcm.c +6 -0
  143. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +16 -0
  144. data/vendor/libsodium/test/default/aead_xchacha20poly1305.c +25 -15
  145. data/vendor/libsodium/test/default/auth.c +13 -0
  146. data/vendor/libsodium/test/default/auth.exp +8 -0
  147. data/vendor/libsodium/test/default/box.c +3 -0
  148. data/vendor/libsodium/test/default/box2.c +2 -0
  149. data/vendor/libsodium/test/default/box_easy.c +1 -4
  150. data/vendor/libsodium/test/default/box_easy2.c +7 -3
  151. data/vendor/libsodium/test/default/chacha20.c +9 -2
  152. data/vendor/libsodium/test/default/cmptest.h +47 -1
  153. data/vendor/libsodium/test/default/codecs.c +226 -0
  154. data/vendor/libsodium/test/default/codecs.exp +28 -0
  155. data/vendor/libsodium/test/default/core3.c +42 -15
  156. data/vendor/libsodium/test/default/ed25519_convert.c +17 -0
  157. data/vendor/libsodium/test/default/kdf.c +8 -4
  158. data/vendor/libsodium/test/default/keygen.c +5 -2
  159. data/vendor/libsodium/test/default/kx.c +30 -0
  160. data/vendor/libsodium/test/default/metamorphic.c +187 -0
  161. data/vendor/libsodium/test/default/metamorphic.exp +1 -0
  162. data/vendor/libsodium/test/default/misuse.c +145 -0
  163. data/vendor/libsodium/test/default/misuse.exp +0 -0
  164. data/vendor/libsodium/test/default/onetimeauth.c +2 -0
  165. data/vendor/libsodium/test/default/{pwhash.c → pwhash_argon2i.c} +133 -106
  166. data/vendor/libsodium/test/default/{pwhash.exp → pwhash_argon2i.exp} +0 -1
  167. data/vendor/libsodium/test/default/pwhash_argon2id.c +254 -144
  168. data/vendor/libsodium/test/default/pwhash_argon2id.exp +2 -3
  169. data/vendor/libsodium/test/default/pwhash_scrypt.c +61 -18
  170. data/vendor/libsodium/test/default/pwhash_scrypt.exp +6 -0
  171. data/vendor/libsodium/test/default/randombytes.c +8 -3
  172. data/vendor/libsodium/test/default/secretbox.c +8 -0
  173. data/vendor/libsodium/test/default/secretbox2.c +5 -0
  174. data/vendor/libsodium/test/default/secretbox_easy.c +19 -1
  175. data/vendor/libsodium/test/default/secretbox_easy.exp +2 -0
  176. data/vendor/libsodium/test/default/secretbox_easy2.c +4 -0
  177. data/vendor/libsodium/test/default/secretstream.c +280 -0
  178. data/vendor/libsodium/test/default/secretstream.exp +1 -0
  179. data/vendor/libsodium/test/default/sign.c +31 -0
  180. data/vendor/libsodium/test/default/sodium_core.c +23 -1
  181. data/vendor/libsodium/test/default/sodium_core.exp +1 -1
  182. data/vendor/libsodium/test/default/sodium_utils.c +45 -56
  183. data/vendor/libsodium/test/default/sodium_utils.exp +0 -8
  184. data/vendor/libsodium/test/default/stream.c +2 -0
  185. data/vendor/libsodium/test/default/stream2.c +1 -0
  186. data/vendor/libsodium/test/default/xchacha20.c +58 -7
  187. metadata +21 -18
  188. data/vendor/libsodium/dist-build/emscripten-wasm.sh +0 -132
  189. data/vendor/libsodium/m4/pkg.m4 +0 -214
  190. data/vendor/libsodium/packaging/dotnet-core/desktop.targets +0 -16
  191. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c +0 -174
  192. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c +0 -66
  193. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/common.h +0 -766
  194. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts.h +0 -28
  195. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c +0 -28
  196. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128.h +0 -50
  197. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c +0 -149
  198. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c +0 -31
  199. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c +0 -195
  200. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr.c +0 -19
  201. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +0 -65
@@ -8,5 +8,4 @@ c121209f0ba70aed93d49200e5dc82cce013cef25ea31e160bf8db3cf448a59d1a56f6c19259e18e
8
8
  e942951dfbc2d508294b10f9e97b47d0cd04e668a043cb95679cc1139df7c27cd54367688725be9d069f5704c12223e7e4ca181fbd0bed18bb4634795e545a6c04a7306933a41a794baedbb628d41bc285e0b9084055ae136f6b63624c874f5a1e1d8be7b0b7227a171d2d7ed578d88bfdcf18323198962d0dcad4126fd3f21adeb1e11d66252ea0c58c91696e91031bfdcc2a9dc0e028d17b9705ba2d7bcdcd1e3ba75b4b1fea
9
9
  9fbbc02a420b00614a49a8e8d89834df368fa54dbef5dce7f9928f4d09f45ce22766598c0c979a707b1df130ab8d63802447923f6e8b89b3c183d71d694161569b1937d8b58f0091fcb8b1f48f2e3f43067bb2498b727fb62cc776ed39219613aa2083619385ec64dfb38f3cda7fddce9cec708a1aa5e9b09d6a5f063cda6c644c5e4a6c1bba9362b27f050984ee3a91bbed69160c95d63c04724f
10
10
  28645e1a4f5bc2a58786c87f0d88c2c68047b874b122e2c3936fb6adf26d7ca8fbcb872a8aef282ff202526a91b8ca1d0926c4ae0f5429c342bfd4987916b147ccaa1624bbb2d3f197e56601a541939a1a867ee659515d379d252c8b53aa2297b6008f97bc4a246040b0fb4f46754482884ff04bdade7ffc74989c68ec085de660ef2071db22bacc227d43af282a2336049d78fe0b8ff543628dc8
11
- [tv3] pwhash_str failure (maybe intentional): [0]
12
11
  OK
@@ -79,7 +79,7 @@ tv(void)
79
79
  167, 3, 1784128, 1 },
80
80
  };
81
81
  char passwd[256];
82
- unsigned char salt[crypto_pwhash_argon2id_SALTBYTES];
82
+ unsigned char salt[crypto_pwhash_SALTBYTES];
83
83
  unsigned char out[256];
84
84
  char out_hex[256 * 2 + 1];
85
85
  size_t i = 0U;
@@ -90,10 +90,10 @@ tv(void)
90
90
  NULL, NULL);
91
91
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
92
92
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
93
- if (crypto_pwhash_argon2id(out, (unsigned long long) tests[i].outlen, passwd,
94
- tests[i].passwd_len, (const unsigned char *) salt,
95
- tests[i].opslimit, tests[i].memlimit,
96
- crypto_pwhash_argon2id_alg_argon2id13()) != 0) {
93
+ if (crypto_pwhash(out, (unsigned long long) tests[i].outlen, passwd,
94
+ tests[i].passwd_len, (const unsigned char *) salt,
95
+ tests[i].opslimit, tests[i].memlimit,
96
+ crypto_pwhash_alg_default()) != 0) {
97
97
  printf("[tv] pwhash failure (maybe intentional): [%u]\n",
98
98
  (unsigned int) i);
99
99
  continue;
@@ -131,7 +131,7 @@ tv2(void)
131
131
  155, 3, 1397645, 1 },
132
132
  };
133
133
  char passwd[256];
134
- unsigned char salt[crypto_pwhash_argon2id_SALTBYTES];
134
+ unsigned char salt[crypto_pwhash_SALTBYTES];
135
135
  unsigned char out[256];
136
136
  char out_hex[256 * 2 + 1];
137
137
  size_t i = 0U;
@@ -142,10 +142,10 @@ tv2(void)
142
142
  NULL, NULL);
143
143
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
144
144
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
145
- if (crypto_pwhash_argon2id(out, (unsigned long long) tests[i].outlen, passwd,
146
- tests[i].passwd_len, (const unsigned char *) salt,
147
- tests[i].opslimit, tests[i].memlimit,
148
- crypto_pwhash_argon2id_alg_argon2id13()) != 0) {
145
+ if (crypto_pwhash(out, (unsigned long long) tests[i].outlen, passwd,
146
+ tests[i].passwd_len, (const unsigned char *) salt,
147
+ tests[i].opslimit, tests[i].memlimit,
148
+ crypto_pwhash_alg_default()) != 0) {
149
149
  printf("[tv2] pwhash failure: [%u]\n", (unsigned int) i);
150
150
  continue;
151
151
  }
@@ -187,17 +187,17 @@ tv3(void)
187
187
  const char *out;
188
188
  } tests[] = {
189
189
  { "",
190
- "$argon2i$v=19$m=4096,t=1,p=1$X1NhbHQAAAAAAAAAAAAAAA$bWh++"
191
- "MKN1OiFHKgIWTLvIi1iHicmHH7+Fv3K88ifFfI" },
190
+ "$argon2id$v=19$m=4096,t=0,p=1$X1NhbHQAAAAAAAAAAAAAAA$bWh++MKN1OiFHKgIWTLvIi1iHicmHH7+Fv3K88ifFfI" },
192
191
  { "",
193
- "$argon2i$v=19$m=2048,t=4,p=1$SWkxaUhpY21ISDcrRnYzSw$Mbg/"
194
- "Eck1kpZir5T9io7C64cpffdTBaORgyriLQFgQj8" },
192
+ "$argon2id$v=19$m=2048,t=4,p=1$SWkxaUhpY21ISDcrRnYzSw$Mbg/Eck1kpZir5T9io7C64cpffdTBaORgyriLQFgQj8" },
193
+ { "",
194
+ "$argon2id$v=19$m=4882,t=2,p=1$bA81arsiXysd3WbTRzmEOw$Nm8QBM+7RH1DXo9rvp5cwKEOOOfD2g6JuxlXihoNcpE" },
195
+ { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg ",
196
+ "$argon2id$v=19$m=4096,t=0,p=1$PkEgMTYtYnl0ZXMgc2FsdA$ltB/ue1kPtBMBGfsysMpPigE6hiNEKZ9vs8vLNVDQGA" },
195
197
  { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg ",
196
- "$argon2i$v=19$m=4096,t=3,p=2$X1NhbHQAAAAAAAAAAAAAAA$z/QMiU4lQxGsYNc/"
197
- "+K/bizwsA1P11UG2dj/7+aILJ4I" },
198
+ "$argon2id$v=19$m=4096,t=19,p=1$PkEgMTYtYnl0ZXMgc2FsdA$ltB/ue1kPtBMBGfsysMpPigE6hiNEKZ9vs8vLNVDQGA" },
198
199
  { "K3S=KyH#)36_?]LxeR8QNKw6X=gFbxai$C%29V*",
199
- "$argon2i$v=19$m=4096,t=3,p=1$X1NhbHQAAAAAAAAAAAAAAA$fu2Wsecyt+"
200
- "yPnBvSvYN16oP5ozRmkp0ixJ1YL19V3Uo" }
200
+ "$argon2id$v=19$m=4096,t=1,p=3$PkEgcHJldHR5IGxvbmcgc2FsdA$HUqx5Z1b/ZypnUrvvJ5UC2Q+T6Q1WwASK/Kr9dRbGA0" }
201
201
  };
202
202
  char *out;
203
203
  char *passwd;
@@ -210,7 +210,7 @@ tv3(void)
210
210
  passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
211
211
  assert(passwd != NULL);
212
212
  memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
213
- if (crypto_pwhash_argon2id_str_verify(out, passwd, strlen(passwd)) != 0) {
213
+ if (crypto_pwhash_str_verify(out, passwd, strlen(passwd)) != 0) {
214
214
  printf("[tv3] pwhash_argon2id_str failure (maybe intentional): [%u]\n",
215
215
  (unsigned int) i);
216
216
  continue;
@@ -220,167 +220,277 @@ tv3(void)
220
220
  } while (++i < (sizeof tests) / (sizeof tests[0]));
221
221
  }
222
222
 
223
- int
224
- main(void)
223
+ static void
224
+ str_tests(void)
225
225
  {
226
226
  char *str_out;
227
227
  char *str_out2;
228
228
  char *salt;
229
229
  const char *passwd = "Correct Horse Battery Staple";
230
230
 
231
- tv();
232
- tv2();
233
- tv3();
231
+
234
232
  salt = (char *) sodium_malloc(crypto_pwhash_argon2id_SALTBYTES);
235
233
  str_out = (char *) sodium_malloc(crypto_pwhash_argon2id_STRBYTES);
236
234
  str_out2 = (char *) sodium_malloc(crypto_pwhash_argon2id_STRBYTES);
237
235
  memcpy(salt, ">A 16-bytes salt", crypto_pwhash_argon2id_SALTBYTES);
238
- if (crypto_pwhash_argon2id_str(str_out, passwd, strlen(passwd), OPSLIMIT,
239
- MEMLIMIT) != 0) {
240
- printf("pwhash_argon2id_str failure: %s\n", strerror(errno));
241
- return 1;
236
+ if (crypto_pwhash_str(str_out, passwd, strlen(passwd), OPSLIMIT,
237
+ MEMLIMIT) != 0) {
238
+ printf("pwhash_str failure\n");
242
239
  }
243
- exit(0);
244
- if (crypto_pwhash_argon2id_str(str_out2, passwd, strlen(passwd), OPSLIMIT,
245
- MEMLIMIT) != 0) {
246
- printf("pwhash_argon2id_str(2) failure\n");
247
- return 1;
240
+ if (crypto_pwhash_str(str_out2, passwd, strlen(passwd), OPSLIMIT,
241
+ MEMLIMIT) != 0) {
242
+ printf("pwhash_str(2) failure\n");
248
243
  }
249
244
  if (strcmp(str_out, str_out2) == 0) {
250
- printf("pwhash_argon2id_str() doesn't generate different salts\n");
245
+ printf("pwhash_str() doesn't generate different salts\n");
246
+ }
247
+ if (crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT) != 0 ||
248
+ crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT) != 0) {
249
+ printf("needs_rehash() false positive\n");
250
+ }
251
+ if (crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT / 2) != 1 ||
252
+ crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT - 1, MEMLIMIT) != 1 ||
253
+ crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT * 2) != 1 ||
254
+ crypto_pwhash_str_needs_rehash(str_out, OPSLIMIT + 1, MEMLIMIT) != 1) {
255
+ printf("needs_rehash() false negative (0)\n");
256
+ }
257
+ if (crypto_pwhash_argon2id_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT / 2) != 1 ||
258
+ crypto_pwhash_argon2id_str_needs_rehash(str_out, OPSLIMIT - 1, MEMLIMIT) != 1 ||
259
+ crypto_pwhash_argon2id_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT * 2) != 1 ||
260
+ crypto_pwhash_argon2id_str_needs_rehash(str_out, OPSLIMIT + 1, MEMLIMIT) != 1) {
261
+ printf("needs_rehash() false negative (1)\n");
262
+ }
263
+ if (crypto_pwhash_argon2i_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT / 2) != -1 ||
264
+ crypto_pwhash_argon2i_str_needs_rehash(str_out, OPSLIMIT - 1, MEMLIMIT) != -1 ||
265
+ crypto_pwhash_argon2i_str_needs_rehash(str_out, OPSLIMIT, MEMLIMIT * 2) != -1 ||
266
+ crypto_pwhash_argon2i_str_needs_rehash(str_out, OPSLIMIT + 1, MEMLIMIT) != -1) {
267
+ printf("needs_rehash() false negative (2)\n");
268
+ }
269
+ if (crypto_pwhash_str_needs_rehash(str_out + 1, OPSLIMIT, MEMLIMIT) != -1 ||
270
+ crypto_pwhash_argon2id_str_needs_rehash(str_out + 1, OPSLIMIT, MEMLIMIT) != -1) {
271
+ printf("needs_rehash() didn't fail with an invalid hash string\n");
251
272
  }
252
273
  if (sodium_is_zero((const unsigned char *) str_out + strlen(str_out),
253
- crypto_pwhash_argon2id_STRBYTES - strlen(str_out)) != 1 ||
274
+ crypto_pwhash_STRBYTES - strlen(str_out)) != 1 ||
254
275
  sodium_is_zero((const unsigned char *) str_out2 + strlen(str_out2),
255
- crypto_pwhash_argon2id_STRBYTES - strlen(str_out2)) != 1) {
276
+ crypto_pwhash_STRBYTES - strlen(str_out2)) != 1) {
256
277
  printf("pwhash_argon2id_str() doesn't properly pad with zeros\n");
257
278
  }
258
279
  if (crypto_pwhash_argon2id_str_verify(str_out, passwd, strlen(passwd)) != 0) {
259
280
  printf("pwhash_argon2id_str_verify(1) failure\n");
260
281
  }
282
+ if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != 0) {
283
+ printf("pwhash_str_verify(1') failure\n");
284
+ }
261
285
  str_out[14]++;
262
- if (crypto_pwhash_argon2id_str_verify(str_out, passwd, strlen(passwd)) != -1) {
286
+ if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != -1) {
263
287
  printf("pwhash_argon2id_str_verify(2) failure\n");
264
288
  }
265
289
  str_out[14]--;
266
290
  assert(str_out[crypto_pwhash_argon2id_STRBYTES - 1U] == 0);
267
291
 
268
- if (crypto_pwhash_argon2id_str(str_out2, passwd, 0x100000000ULL, OPSLIMIT,
292
+ if (crypto_pwhash_str(str_out2, passwd, 0x100000000ULL, OPSLIMIT,
269
293
  MEMLIMIT) != -1) {
270
- printf("pwhash_argon2id_str() with a large password should have failed\n");
271
- return 1;
272
- }
273
- if (crypto_pwhash_argon2id_str(str_out2, passwd, strlen(passwd), 1, MEMLIMIT) !=
274
- -1) {
275
- printf("pwhash_argon2id_str() with a small opslimit should have failed\n");
276
- return 1;
277
- }
278
- if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
279
- "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
280
- "password", 0x100000000ULL) != -1) {
281
- printf("pwhash_argon2id_str_verify(invalid(0)) failure\n");
282
- }
283
- if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
284
- "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
285
- "password", strlen("password")) != -1) {
286
- printf("pwhash_argon2id_str_verify(invalid(1)) failure %d\n", errno);
287
- }
288
- if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
289
- "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
290
- "password", strlen("password")) != -1) {
291
- printf("pwhash_argon2id_str_verify(invalid(2)) failure\n");
292
- }
293
- if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
294
- "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
295
- "password", strlen("password")) != -1) {
296
- printf("pwhash_argon2id_str_verify(invalid(3)) failure\n");
297
- }
298
- if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
299
- "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
300
- "password", strlen("password")) != -1) {
301
- printf("pwhash_argon2id_str_verify(invalid(4)) failure\n");
302
- }
303
- if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
304
- "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
305
- "password", strlen("password")) != -1) {
306
- printf("pwhash_argon2id_str_verify(invalid(5)) failure\n");
307
- }
308
- if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
309
- "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
310
- "password", strlen("password")) != -1) {
311
- printf("pwhash_argon2id_str_verify(invalid(6)) failure\n");
312
- }
313
- if (crypto_pwhash_argon2id_str_verify(
314
- "$argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
315
- "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
316
- "password", strlen("password")) != 0) {
317
- printf("pwhash_argon2id_str_verify(valid(7)) failure\n");
318
- }
319
- if (crypto_pwhash_argon2id_str_verify(
320
- "$argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
321
- "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
322
- "passwore", strlen("passwore")) != -1 || errno != EINVAL) {
323
- printf("pwhash_argon2id_str_verify(invalid(7)) failure\n");
324
- }
325
- if (crypto_pwhash_argon2id_str_verify(
326
- "$Argon2i$v=19$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
327
- "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
328
- "password", strlen("password")) != -1 || errno != EINVAL) {
329
- printf("pwhash_argon2id_str_verify(invalid(8)) failure\n");
330
- }
331
- if (crypto_pwhash_argon2id_str_verify(
332
- "$argon2i$v=1$m=4096,t=3,p=2$b2RpZHVlamRpc29kaXNrdw"
333
- "$TNnWIwlu1061JHrnCqIAmjs3huSxYIU+0jWipu7Kc9M",
334
- "password", strlen("password")) != -1 || errno != EINVAL) {
335
- printf("pwhash_argon2id_str_verify(invalid(9)) failure\n");
336
- }
337
- assert(crypto_pwhash_argon2id_bytes_min() > 0U);
338
- assert(crypto_pwhash_argon2id_bytes_max() > crypto_pwhash_argon2id_bytes_min());
339
- assert(crypto_pwhash_argon2id_passwd_max() > crypto_pwhash_argon2id_passwd_min());
340
- assert(crypto_pwhash_argon2id_saltbytes() > 0U);
341
- assert(crypto_pwhash_argon2id_strbytes() > 1U);
342
- assert(crypto_pwhash_argon2id_strbytes() > strlen(crypto_pwhash_argon2id_strprefix()));
294
+ printf("pwhash_str() with a large password should have failed\n");
295
+ }
296
+ if (crypto_pwhash_str(str_out2, passwd, strlen(passwd), 1, MEMLIMIT) != 0) {
297
+ printf("pwhash_str() with a small opslimit should not have failed\n");
298
+ }
299
+ if (crypto_pwhash_str(str_out2, passwd, strlen(passwd), 0, MEMLIMIT) != -1) {
300
+ printf("pwhash_argon2id_str() with a null opslimit should have failed\n");
301
+ }
302
+ if (crypto_pwhash_str_verify("$argon2id$m=65536,t=2,p=1c29tZXNhbHQ"
303
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
304
+ "password", 0x100000000ULL) != -1) {
305
+ printf("pwhash_str_verify(invalid(0)) failure\n");
306
+ }
307
+ if (crypto_pwhash_str_verify("$argon2id$m=65536,t=2,p=1c29tZXNhbHQ"
308
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
309
+ "password", strlen("password")) != -1) {
310
+ printf("pwhash_str_verify(invalid(1)) failure %d\n", errno);
311
+ }
312
+ if (crypto_pwhash_str_verify("$argon2id$m=65536,t=2,p=1$c29tZXNhbHQ"
313
+ "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
314
+ "password", strlen("password")) != -1) {
315
+ printf("pwhash_str_verify(invalid(2)) failure\n");
316
+ }
317
+ if (crypto_pwhash_str_verify("$argon2id$m=65536,t=2,p=1$c29tZXNhbHQ"
318
+ "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
319
+ "password", strlen("password")) != -1) {
320
+ printf("pwhash_str_verify(invalid(3)) failure\n");
321
+ }
322
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
323
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
324
+ "password", strlen("password")) != -1) {
325
+ printf("pwhash_str_verify(invalid(4)) failure\n");
326
+ }
327
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
328
+ "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
329
+ "password", strlen("password")) != -1) {
330
+ printf("pwhash_str_verify(invalid(5)) failure\n");
331
+ }
332
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
333
+ "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
334
+ "password", strlen("password")) != -1) {
335
+ printf("pwhash_str_verify(invalid(6)) failure\n");
336
+ }
337
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=256,t=3,p=1$MDEyMzQ1Njc"
338
+ "$G5ajKFCoUzaXRLdz7UJb5wGkb2Xt+X5/GQjUYtS2+TE",
339
+ "password", strlen("password")) != 0) {
340
+ printf("pwhash_str_verify(valid(7)) failure\n");
341
+ }
342
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=256,t=3,p=1$MDEyMzQ1Njc"
343
+ "$G5ajKFCoUzaXRLdz7UJb5wGkb2Xt+X5/GQjUYtS2+TE",
344
+ "passwore", strlen("passwore")) != -1 || errno != EINVAL) {
345
+ printf("pwhash_str_verify(invalid(7)) failure\n");
346
+ }
347
+ if (crypto_pwhash_str_verify("$Argon2id$v=19$m=256,t=3,p=1$MDEyMzQ1Njc"
348
+ "$G5ajKFCoUzaXRLdz7UJb5wGkb2Xt+X5/GQjUYtS2+TE",
349
+ "password", strlen("password")) != -1 || errno != EINVAL) {
350
+ printf("pwhash_str_verify(invalid(8)) failure\n");
351
+ }
352
+ if (crypto_pwhash_str_verify("$argon2id$v=19$m=256,t=3,p=2$MDEyMzQ1Njc"
353
+ "$G5ajKFCoUzaXRLdz7UJb5wGkb2Xt+X5/GQjUYtS2+TE",
354
+ "password", strlen("password")) != -1 || errno != EINVAL) {
355
+ printf("pwhash_str_verify(invalid(9)) failure\n");
356
+ }
357
+ assert(crypto_pwhash_str_alg(str_out, "test", 4, OPSLIMIT, MEMLIMIT,
358
+ crypto_pwhash_ALG_ARGON2ID13) == 0);
359
+ assert(crypto_pwhash_argon2id_str_verify(str_out, "test", 4) == 0);
360
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out,
361
+ OPSLIMIT, MEMLIMIT) == 0);
362
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out,
363
+ OPSLIMIT / 2, MEMLIMIT) == 1);
364
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out,
365
+ OPSLIMIT, MEMLIMIT / 2) == 1);
366
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out, 0, 0) == 1);
367
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out, 0, 0) == -1);
368
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out + 1,
369
+ OPSLIMIT, MEMLIMIT) == -1);
370
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out, 0, 0) == -1);
371
+ assert(crypto_pwhash_argon2i_str_needs_rehash("", OPSLIMIT, MEMLIMIT) == -1);
372
+ assert(crypto_pwhash_str_alg(str_out, "test", 4, OPSLIMIT, MEMLIMIT,
373
+ crypto_pwhash_ALG_ARGON2I13) == 0);
374
+ assert(crypto_pwhash_argon2i_str_verify(str_out, "test", 4) == 0);
375
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out,
376
+ OPSLIMIT, MEMLIMIT) == 0);
377
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out,
378
+ OPSLIMIT / 2, MEMLIMIT) == 1);
379
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out,
380
+ OPSLIMIT, MEMLIMIT / 2) == 1);
381
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out, 0, 0) == 1);
382
+ assert(crypto_pwhash_argon2id_str_needs_rehash(str_out, 0, 0) == -1);
383
+ assert(crypto_pwhash_argon2i_str_needs_rehash("", OPSLIMIT, MEMLIMIT) == -1);
384
+ assert(crypto_pwhash_argon2i_str_needs_rehash(str_out + 1,
385
+ OPSLIMIT, MEMLIMIT) == -1);
386
+ sodium_free(salt);
387
+ sodium_free(str_out);
388
+ sodium_free(str_out2);
389
+ }
343
390
 
344
- assert(crypto_pwhash_argon2id_opslimit_min() > 0U);
345
- assert(crypto_pwhash_argon2id_opslimit_max() > 0U);
346
- assert(crypto_pwhash_argon2id_memlimit_min() > 0U);
347
- assert(crypto_pwhash_argon2id_memlimit_max() > 0U);
348
- assert(crypto_pwhash_argon2id_opslimit_interactive() > 0U);
349
- assert(crypto_pwhash_argon2id_memlimit_interactive() > 0U);
350
- assert(crypto_pwhash_argon2id_opslimit_moderate() > 0U);
351
- assert(crypto_pwhash_argon2id_memlimit_moderate() > 0U);
352
- assert(crypto_pwhash_argon2id_opslimit_sensitive() > 0U);
353
- assert(crypto_pwhash_argon2id_memlimit_sensitive() > 0U);
391
+ int
392
+ main(void)
393
+ {
394
+ tv();
395
+ tv2();
396
+ tv3();
397
+ str_tests();
398
+
399
+ assert(crypto_pwhash_bytes_min() > 0U);
400
+ assert(crypto_pwhash_bytes_max() > crypto_pwhash_bytes_min());
401
+ assert(crypto_pwhash_passwd_max() > crypto_pwhash_passwd_min());
402
+ assert(crypto_pwhash_saltbytes() > 0U);
403
+ assert(crypto_pwhash_strbytes() > 1U);
404
+ assert(crypto_pwhash_strbytes() > strlen(crypto_pwhash_strprefix()));
405
+
406
+ assert(crypto_pwhash_opslimit_min() > 0U);
407
+ assert(crypto_pwhash_opslimit_max() > 0U);
408
+ assert(crypto_pwhash_memlimit_min() > 0U);
409
+ assert(crypto_pwhash_memlimit_max() > 0U);
410
+ assert(crypto_pwhash_opslimit_interactive() > 0U);
411
+ assert(crypto_pwhash_memlimit_interactive() > 0U);
412
+ assert(crypto_pwhash_opslimit_moderate() > 0U);
413
+ assert(crypto_pwhash_memlimit_moderate() > 0U);
414
+ assert(crypto_pwhash_opslimit_sensitive() > 0U);
415
+ assert(crypto_pwhash_memlimit_sensitive() > 0U);
416
+ assert(strcmp(crypto_pwhash_primitive(), "argon2i") == 0);
354
417
 
355
- assert(crypto_pwhash_argon2id_bytes_min() == crypto_pwhash_argon2id_BYTES_MIN);
356
- assert(crypto_pwhash_argon2id_bytes_max() == crypto_pwhash_argon2id_BYTES_MAX);
357
- assert(crypto_pwhash_argon2id_passwd_min() == crypto_pwhash_argon2id_PASSWD_MIN);
358
- assert(crypto_pwhash_argon2id_passwd_max() == crypto_pwhash_argon2id_PASSWD_MAX);
359
- assert(crypto_pwhash_argon2id_saltbytes() == crypto_pwhash_argon2id_SALTBYTES);
360
- assert(crypto_pwhash_argon2id_strbytes() == crypto_pwhash_argon2id_STRBYTES);
418
+ assert(crypto_pwhash_bytes_min() == crypto_pwhash_BYTES_MIN);
419
+ assert(crypto_pwhash_bytes_max() == crypto_pwhash_BYTES_MAX);
420
+ assert(crypto_pwhash_passwd_min() == crypto_pwhash_PASSWD_MIN);
421
+ assert(crypto_pwhash_passwd_max() == crypto_pwhash_PASSWD_MAX);
422
+ assert(crypto_pwhash_saltbytes() == crypto_pwhash_SALTBYTES);
423
+ assert(crypto_pwhash_strbytes() == crypto_pwhash_STRBYTES);
361
424
 
362
- assert(crypto_pwhash_argon2id_opslimit_min() == crypto_pwhash_argon2id_OPSLIMIT_MIN);
363
- assert(crypto_pwhash_argon2id_opslimit_max() == crypto_pwhash_argon2id_OPSLIMIT_MAX);
364
- assert(crypto_pwhash_argon2id_memlimit_min() == crypto_pwhash_argon2id_MEMLIMIT_MIN);
365
- assert(crypto_pwhash_argon2id_memlimit_max() == crypto_pwhash_argon2id_MEMLIMIT_MAX);
425
+ assert(crypto_pwhash_opslimit_min() == crypto_pwhash_OPSLIMIT_MIN);
426
+ assert(crypto_pwhash_opslimit_max() == crypto_pwhash_OPSLIMIT_MAX);
427
+ assert(crypto_pwhash_memlimit_min() == crypto_pwhash_MEMLIMIT_MIN);
428
+ assert(crypto_pwhash_memlimit_max() == crypto_pwhash_MEMLIMIT_MAX);
429
+ assert(crypto_pwhash_opslimit_interactive() ==
430
+ crypto_pwhash_OPSLIMIT_INTERACTIVE);
431
+ assert(crypto_pwhash_memlimit_interactive() ==
432
+ crypto_pwhash_MEMLIMIT_INTERACTIVE);
433
+ assert(crypto_pwhash_opslimit_moderate() ==
434
+ crypto_pwhash_OPSLIMIT_MODERATE);
435
+ assert(crypto_pwhash_memlimit_moderate() ==
436
+ crypto_pwhash_MEMLIMIT_MODERATE);
437
+ assert(crypto_pwhash_opslimit_sensitive() ==
438
+ crypto_pwhash_OPSLIMIT_SENSITIVE);
439
+ assert(crypto_pwhash_memlimit_sensitive() ==
440
+ crypto_pwhash_MEMLIMIT_SENSITIVE);
441
+
442
+ assert(crypto_pwhash_argon2id_bytes_min() == crypto_pwhash_bytes_min());
443
+ assert(crypto_pwhash_argon2id_bytes_max() == crypto_pwhash_bytes_max());
444
+ assert(crypto_pwhash_argon2id_passwd_min() == crypto_pwhash_passwd_min());
445
+ assert(crypto_pwhash_argon2id_passwd_max() == crypto_pwhash_passwd_max());
446
+ assert(crypto_pwhash_argon2id_saltbytes() == crypto_pwhash_saltbytes());
447
+ assert(crypto_pwhash_argon2id_strbytes() == crypto_pwhash_strbytes());
448
+ assert(strcmp(crypto_pwhash_argon2id_strprefix(),
449
+ crypto_pwhash_strprefix()) == 0);
450
+ assert(crypto_pwhash_argon2id_opslimit_min() ==
451
+ crypto_pwhash_opslimit_min());
452
+ assert(crypto_pwhash_argon2id_opslimit_max() ==
453
+ crypto_pwhash_opslimit_max());
454
+ assert(crypto_pwhash_argon2id_memlimit_min() ==
455
+ crypto_pwhash_memlimit_min());
456
+ assert(crypto_pwhash_argon2id_memlimit_max() ==
457
+ crypto_pwhash_memlimit_max());
366
458
  assert(crypto_pwhash_argon2id_opslimit_interactive() ==
367
- crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE);
368
- assert(crypto_pwhash_argon2id_memlimit_interactive() ==
369
- crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE);
459
+ crypto_pwhash_opslimit_interactive());
370
460
  assert(crypto_pwhash_argon2id_opslimit_moderate() ==
371
- crypto_pwhash_argon2id_OPSLIMIT_MODERATE);
372
- assert(crypto_pwhash_argon2id_memlimit_moderate() ==
373
- crypto_pwhash_argon2id_MEMLIMIT_MODERATE);
461
+ crypto_pwhash_opslimit_moderate());
374
462
  assert(crypto_pwhash_argon2id_opslimit_sensitive() ==
375
- crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE);
463
+ crypto_pwhash_opslimit_sensitive());
464
+ assert(crypto_pwhash_argon2id_memlimit_interactive() ==
465
+ crypto_pwhash_memlimit_interactive());
466
+ assert(crypto_pwhash_argon2id_memlimit_moderate() ==
467
+ crypto_pwhash_memlimit_moderate());
376
468
  assert(crypto_pwhash_argon2id_memlimit_sensitive() ==
377
- crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE);
378
-
379
- assert(crypto_pwhash_argon2id_alg_argon2id13() == crypto_pwhash_argon2id_ALG_ARGON2ID13);
469
+ crypto_pwhash_memlimit_sensitive());
470
+ assert(crypto_pwhash_alg_argon2id13() ==
471
+ crypto_pwhash_argon2id_alg_argon2id13());
472
+ assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_ALG_ARGON2I13);
473
+ assert(crypto_pwhash_alg_argon2i13() != crypto_pwhash_alg_default());
474
+ assert(crypto_pwhash_alg_argon2id13() == crypto_pwhash_ALG_ARGON2ID13);
475
+ assert(crypto_pwhash_alg_argon2id13() != crypto_pwhash_alg_argon2i13());
476
+ assert(crypto_pwhash_alg_argon2id13() == crypto_pwhash_alg_default());
380
477
 
381
- sodium_free(salt);
382
- sodium_free(str_out);
383
- sodium_free(str_out2);
478
+ assert(crypto_pwhash_argon2id(NULL, 0, NULL, 0, NULL,
479
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE,
480
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE,
481
+ 0) == -1);
482
+ assert(crypto_pwhash_argon2id(NULL, 0, NULL, 0, NULL,
483
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE,
484
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE,
485
+ crypto_pwhash_ALG_ARGON2I13) == -1);
486
+ assert(crypto_pwhash_argon2i(NULL, 0, NULL, 0, NULL,
487
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE,
488
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE,
489
+ 0) == -1);
490
+ assert(crypto_pwhash_argon2i(NULL, 0, NULL, 0, NULL,
491
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE,
492
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE,
493
+ crypto_pwhash_ALG_ARGON2ID13) == -1);
384
494
 
385
495
  printf("OK\n");
386
496