@leocuvee/wrkzcoin-multi-hashing 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/.travis.yml +5 -0
  2. package/LICENSE +674 -0
  3. package/README.md +87 -0
  4. package/appveyor.yml +12 -0
  5. package/argon2/.gitattributes +10 -0
  6. package/argon2/.travis.yml +25 -0
  7. package/argon2/Argon2.sln +160 -0
  8. package/argon2/CHANGELOG.md +32 -0
  9. package/argon2/CMakeLists.txt +87 -0
  10. package/argon2/LICENSE +314 -0
  11. package/argon2/Makefile +196 -0
  12. package/argon2/README.md +297 -0
  13. package/argon2/appveyor.yml +40 -0
  14. package/argon2/argon2-specs.pdf +0 -0
  15. package/argon2/export.sh +7 -0
  16. package/argon2/include/argon2.h +427 -0
  17. package/argon2/latex/CMakeLists.txt +34 -0
  18. package/argon2/latex/IEEEtran.cls +6347 -0
  19. package/argon2/latex/Makefile +18 -0
  20. package/argon2/latex/argon2-specs.tex +920 -0
  21. package/argon2/latex/pics/argon2-par.pdf +0 -0
  22. package/argon2/latex/pics/compression.pdf +0 -0
  23. package/argon2/latex/pics/generic.pdf +0 -0
  24. package/argon2/latex/pics/power-distribution.jpg +0 -0
  25. package/argon2/latex/tradeoff.bib +822 -0
  26. package/argon2/libargon2.pc +16 -0
  27. package/argon2/man/CMakeLists.txt +8 -0
  28. package/argon2/man/argon2.1 +57 -0
  29. package/argon2/meson.build +16 -0
  30. package/argon2/meson_options.txt +1 -0
  31. package/argon2/src/CMakeLists.txt +147 -0
  32. package/argon2/src/argon2.c +452 -0
  33. package/argon2/src/argon2.pc.in +11 -0
  34. package/argon2/src/blake2/blake2-impl.h +156 -0
  35. package/argon2/src/blake2/blake2.h +89 -0
  36. package/argon2/src/blake2/blake2b.c +390 -0
  37. package/argon2/src/blake2/blamka-round-opt.h +471 -0
  38. package/argon2/src/blake2/blamka-round-ref.h +56 -0
  39. package/argon2/src/core.c +634 -0
  40. package/argon2/src/core.h +228 -0
  41. package/argon2/src/encoding.c +467 -0
  42. package/argon2/src/encoding.h +57 -0
  43. package/argon2/src/genkat.h +51 -0
  44. package/argon2/src/meson.build +68 -0
  45. package/argon2/src/opt.c +283 -0
  46. package/argon2/src/optimization/CMakeLists.txt +10 -0
  47. package/argon2/src/ref.c +194 -0
  48. package/argon2/src/thread.c +57 -0
  49. package/argon2/src/thread.h +67 -0
  50. package/argon2/tests/CMakeLists.txt +43 -0
  51. package/argon2/tests/bench.c +111 -0
  52. package/argon2/tests/genkat.c +207 -0
  53. package/argon2/tests/kats/argon2d +12304 -0
  54. package/argon2/tests/kats/argon2d.shasum +1 -0
  55. package/argon2/tests/kats/argon2d_v16 +12304 -0
  56. package/argon2/tests/kats/argon2d_v16.shasum +1 -0
  57. package/argon2/tests/kats/argon2i +12304 -0
  58. package/argon2/tests/kats/argon2i.shasum +1 -0
  59. package/argon2/tests/kats/argon2i_v16 +12304 -0
  60. package/argon2/tests/kats/argon2i_v16.shasum +1 -0
  61. package/argon2/tests/kats/argon2id +12304 -0
  62. package/argon2/tests/kats/argon2id.shasum +1 -0
  63. package/argon2/tests/kats/argon2id_v16 +12304 -0
  64. package/argon2/tests/kats/argon2id_v16.shasum +1 -0
  65. package/argon2/tests/kats/check-sums.ps1 +48 -0
  66. package/argon2/tests/kats/check-sums.sh +16 -0
  67. package/argon2/tests/kats/test.ps1 +132 -0
  68. package/argon2/tests/kats/test.sh +117 -0
  69. package/argon2/tests/meson.build +34 -0
  70. package/argon2/tests/test.c +289 -0
  71. package/argon2/tool/CMakeLists.txt +7 -0
  72. package/argon2/tool/main.c +339 -0
  73. package/argon2/tool/meson.build +8 -0
  74. package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +226 -0
  75. package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
  76. package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +226 -0
  77. package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
  78. package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +225 -0
  79. package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters +66 -0
  80. package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +239 -0
  81. package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
  82. package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +227 -0
  83. package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
  84. package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +226 -0
  85. package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
  86. package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +226 -0
  87. package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
  88. package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +225 -0
  89. package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters +66 -0
  90. package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +227 -0
  91. package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
  92. package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +226 -0
  93. package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
  94. package/bcrypt.c +566 -0
  95. package/bcrypt.h +14 -0
  96. package/binding.gyp +93 -0
  97. package/blake.c +17 -0
  98. package/blake.h +16 -0
  99. package/boolberry.cc +11 -0
  100. package/boolberry.h +6 -0
  101. package/build/Makefile +354 -0
  102. package/build/Release/.deps/Release/multihashing.node.d +1 -0
  103. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/argon2.o.d +8 -0
  104. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/blake2/blake2b.o.d +8 -0
  105. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/core.o.d +10 -0
  106. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/encoding.o.d +8 -0
  107. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/ref.o.d +14 -0
  108. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/thread.o.d +5 -0
  109. package/build/Release/.deps/Release/obj.target/multihashing/bcrypt.o.d +4 -0
  110. package/build/Release/.deps/Release/obj.target/multihashing/blake.o.d +7 -0
  111. package/build/Release/.deps/Release/obj.target/multihashing/boolberry.o.d +12 -0
  112. package/build/Release/.deps/Release/obj.target/multihashing/c11.o.d +20 -0
  113. package/build/Release/.deps/Release/obj.target/multihashing/crypto/aesb.o.d +3 -0
  114. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_blake256.o.d +5 -0
  115. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_groestl.o.d +10 -0
  116. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_jh.o.d +9 -0
  117. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_keccak.o.d +7 -0
  118. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_skein.o.d +10 -0
  119. package/build/Release/.deps/Release/obj.target/multihashing/crypto/hash.o.d +7 -0
  120. package/build/Release/.deps/Release/obj.target/multihashing/crypto/oaes_lib.o.d +6 -0
  121. package/build/Release/.deps/Release/obj.target/multihashing/crypto/wild_keccak.o.d +8 -0
  122. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight.o.d +18 -0
  123. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark.o.d +18 -0
  124. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark_lite.o.d +18 -0
  125. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_fast.o.d +18 -0
  126. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_lite.o.d +18 -0
  127. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_soft_shell.o.d +18 -0
  128. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle.o.d +18 -0
  129. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle_lite.o.d +18 -0
  130. package/build/Release/.deps/Release/obj.target/multihashing/fresh.o.d +10 -0
  131. package/build/Release/.deps/Release/obj.target/multihashing/fugue.o.d +7 -0
  132. package/build/Release/.deps/Release/obj.target/multihashing/groestl.o.d +8 -0
  133. package/build/Release/.deps/Release/obj.target/multihashing/hefty1.o.d +12 -0
  134. package/build/Release/.deps/Release/obj.target/multihashing/keccak.o.d +8 -0
  135. package/build/Release/.deps/Release/obj.target/multihashing/multihashing.o.d +155 -0
  136. package/build/Release/.deps/Release/obj.target/multihashing/nist5.o.d +12 -0
  137. package/build/Release/.deps/Release/obj.target/multihashing/quark.o.d +14 -0
  138. package/build/Release/.deps/Release/obj.target/multihashing/qubit.o.d +12 -0
  139. package/build/Release/.deps/Release/obj.target/multihashing/scryptjane.o.d +30 -0
  140. package/build/Release/.deps/Release/obj.target/multihashing/scryptn.o.d +6 -0
  141. package/build/Release/.deps/Release/obj.target/multihashing/sha1.o.d +24 -0
  142. package/build/Release/.deps/Release/obj.target/multihashing/sha3/aes_helper.o.d +5 -0
  143. package/build/Release/.deps/Release/obj.target/multihashing/sha3/hamsi.o.d +7 -0
  144. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_blake.o.d +6 -0
  145. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_bmw.o.d +6 -0
  146. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_cubehash.o.d +6 -0
  147. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_echo.o.d +7 -0
  148. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_fugue.o.d +6 -0
  149. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_groestl.o.d +6 -0
  150. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_hefty1.o.d +5 -0
  151. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_jh.o.d +6 -0
  152. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_keccak.o.d +6 -0
  153. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_luffa.o.d +6 -0
  154. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shabal.o.d +6 -0
  155. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shavite.o.d +7 -0
  156. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_simd.o.d +6 -0
  157. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_skein.o.d +6 -0
  158. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_whirlpool.o.d +8 -0
  159. package/build/Release/.deps/Release/obj.target/multihashing/shavite3.o.d +7 -0
  160. package/build/Release/.deps/Release/obj.target/multihashing/skein.o.d +8 -0
  161. package/build/Release/.deps/Release/obj.target/multihashing/x11.o.d +20 -0
  162. package/build/Release/.deps/Release/obj.target/multihashing/x13.o.d +23 -0
  163. package/build/Release/.deps/Release/obj.target/multihashing/x15.o.d +26 -0
  164. package/build/Release/.deps/Release/obj.target/multihashing.node.d +1 -0
  165. package/build/Release/multihashing.node +0 -0
  166. package/build/binding.Makefile +6 -0
  167. package/build/multihashing.target.mk +255 -0
  168. package/c11.c +85 -0
  169. package/c11.h +17 -0
  170. package/crypto/aesb.c +177 -0
  171. package/crypto/c_blake256.c +326 -0
  172. package/crypto/c_blake256.h +43 -0
  173. package/crypto/c_groestl.c +360 -0
  174. package/crypto/c_groestl.h +56 -0
  175. package/crypto/c_jh.c +367 -0
  176. package/crypto/c_jh.h +20 -0
  177. package/crypto/c_keccak.c +112 -0
  178. package/crypto/c_keccak.h +26 -0
  179. package/crypto/c_skein.c +2036 -0
  180. package/crypto/c_skein.h +45 -0
  181. package/crypto/crypto.h +186 -0
  182. package/crypto/cryptonote_core/account.cpp +50 -0
  183. package/crypto/cryptonote_core/account.h +61 -0
  184. package/crypto/cryptonote_core/cryptonote_basic_impl.cpp +186 -0
  185. package/crypto/cryptonote_core/cryptonote_basic_impl.h +65 -0
  186. package/crypto/cryptonote_core/cryptonote_format_utils.cpp +766 -0
  187. package/crypto/cryptonote_core/cryptonote_format_utils.h +30 -0
  188. package/crypto/cryptonote_protocol/cryptonote_protocol_defs.h +152 -0
  189. package/crypto/groestl_tables.h +38 -0
  190. package/crypto/hash-ops.h +57 -0
  191. package/crypto/hash.c +24 -0
  192. package/crypto/hash.h +22 -0
  193. package/crypto/int-util.h +230 -0
  194. package/crypto/oaes_config.h +50 -0
  195. package/crypto/oaes_lib.c +1468 -0
  196. package/crypto/oaes_lib.h +215 -0
  197. package/crypto/skein_port.h +190 -0
  198. package/crypto/variant2_int_sqrt.h +168 -0
  199. package/crypto/wild_keccak.cpp +119 -0
  200. package/crypto/wild_keccak.h +168 -0
  201. package/cryptonight.c +300 -0
  202. package/cryptonight.h +17 -0
  203. package/cryptonight_dark.c +300 -0
  204. package/cryptonight_dark.h +17 -0
  205. package/cryptonight_dark_lite.c +300 -0
  206. package/cryptonight_dark_lite.h +17 -0
  207. package/cryptonight_fast.c +300 -0
  208. package/cryptonight_fast.h +17 -0
  209. package/cryptonight_lite.c +300 -0
  210. package/cryptonight_lite.h +17 -0
  211. package/cryptonight_soft_shell.c +298 -0
  212. package/cryptonight_soft_shell.h +17 -0
  213. package/cryptonight_turtle.c +300 -0
  214. package/cryptonight_turtle.h +17 -0
  215. package/cryptonight_turtle_lite.c +300 -0
  216. package/cryptonight_turtle_lite.h +17 -0
  217. package/fresh.c +42 -0
  218. package/fresh.h +16 -0
  219. package/fugue.c +12 -0
  220. package/fugue.h +16 -0
  221. package/groestl.c +40 -0
  222. package/groestl.h +17 -0
  223. package/hefty1.c +63 -0
  224. package/hefty1.h +16 -0
  225. package/index.js +1 -0
  226. package/keccak.c +14 -0
  227. package/keccak.h +16 -0
  228. package/leocuvee-wrkzcoin-multi-hashing-0.0.20.tgz +0 -0
  229. package/multihashing.cc +699 -0
  230. package/nist5.c +46 -0
  231. package/nist5.h +16 -0
  232. package/package.json +56 -0
  233. package/quark.c +210 -0
  234. package/quark.h +16 -0
  235. package/qubit.c +45 -0
  236. package/qubit.h +16 -0
  237. package/scryptjane/scrypt-jane-chacha.h +132 -0
  238. package/scryptjane/scrypt-jane-hash.h +48 -0
  239. package/scryptjane/scrypt-jane-hash_keccak.h +168 -0
  240. package/scryptjane/scrypt-jane-hash_sha256.h +135 -0
  241. package/scryptjane/scrypt-jane-mix_chacha-avx.h +340 -0
  242. package/scryptjane/scrypt-jane-mix_chacha-sse2.h +371 -0
  243. package/scryptjane/scrypt-jane-mix_chacha-ssse3.h +348 -0
  244. package/scryptjane/scrypt-jane-mix_chacha.h +69 -0
  245. package/scryptjane/scrypt-jane-mix_salsa-avx.h +381 -0
  246. package/scryptjane/scrypt-jane-mix_salsa-sse2.h +443 -0
  247. package/scryptjane/scrypt-jane-mix_salsa.h +70 -0
  248. package/scryptjane/scrypt-jane-pbkdf2.h +112 -0
  249. package/scryptjane/scrypt-jane-portable-x86.h +364 -0
  250. package/scryptjane/scrypt-jane-portable.h +281 -0
  251. package/scryptjane/scrypt-jane-romix-basic.h +67 -0
  252. package/scryptjane/scrypt-jane-romix-template.h +118 -0
  253. package/scryptjane/scrypt-jane-romix.h +27 -0
  254. package/scryptjane/scrypt-jane-salsa.h +106 -0
  255. package/scryptjane/scrypt-jane-test-vectors.h +261 -0
  256. package/scryptjane.c +223 -0
  257. package/scryptjane.h +36 -0
  258. package/scryptn.c +258 -0
  259. package/scryptn.h +16 -0
  260. package/sha1.c +65 -0
  261. package/sha1.h +16 -0
  262. package/sha256.h +440 -0
  263. package/sha3/aes_helper.c +392 -0
  264. package/sha3/hamsi.c +867 -0
  265. package/sha3/hamsi_helper.c +39648 -0
  266. package/sha3/md_helper.c +347 -0
  267. package/sha3/sph_blake.c +1114 -0
  268. package/sha3/sph_blake.h +327 -0
  269. package/sha3/sph_bmw.c +965 -0
  270. package/sha3/sph_bmw.h +328 -0
  271. package/sha3/sph_cubehash.c +723 -0
  272. package/sha3/sph_cubehash.h +292 -0
  273. package/sha3/sph_echo.c +1031 -0
  274. package/sha3/sph_echo.h +320 -0
  275. package/sha3/sph_fugue.c +1208 -0
  276. package/sha3/sph_fugue.h +81 -0
  277. package/sha3/sph_groestl.c +3119 -0
  278. package/sha3/sph_groestl.h +329 -0
  279. package/sha3/sph_hamsi.h +321 -0
  280. package/sha3/sph_hefty1.c +378 -0
  281. package/sha3/sph_hefty1.h +66 -0
  282. package/sha3/sph_jh.c +1116 -0
  283. package/sha3/sph_jh.h +298 -0
  284. package/sha3/sph_keccak.c +1824 -0
  285. package/sha3/sph_keccak.h +293 -0
  286. package/sha3/sph_luffa.c +1426 -0
  287. package/sha3/sph_luffa.h +296 -0
  288. package/sha3/sph_shabal.c +806 -0
  289. package/sha3/sph_shabal.h +344 -0
  290. package/sha3/sph_shavite.c +1764 -0
  291. package/sha3/sph_shavite.h +314 -0
  292. package/sha3/sph_simd.c +1799 -0
  293. package/sha3/sph_simd.h +309 -0
  294. package/sha3/sph_skein.c +1254 -0
  295. package/sha3/sph_skein.h +298 -0
  296. package/sha3/sph_types.h +1976 -0
  297. package/sha3/sph_whirlpool.c +3480 -0
  298. package/sha3/sph_whirlpool.h +209 -0
  299. package/shavite3.c +24 -0
  300. package/shavite3.h +16 -0
  301. package/skein.c +26 -0
  302. package/skein.h +16 -0
  303. package/stdint.h +259 -0
  304. package/tests/argon2-tests.js +16 -0
  305. package/tests/benchmark.js +36 -0
  306. package/tests/cryptonight-tests.js +189 -0
  307. package/tests/cryptonight_monero.js +53 -0
  308. package/tests/test.js +16 -0
  309. package/x11.c +85 -0
  310. package/x11.h +16 -0
  311. package/x13.c +97 -0
  312. package/x13.h +5 -0
  313. package/x15.c +106 -0
  314. package/x15.h +16 -0
@@ -0,0 +1 @@
1
+ 680774be1d3ad2e74bbc56ee715dd6eb97a58279bf22edc57d00e840ca1ae469 argon2id_v16
@@ -0,0 +1,48 @@
1
+ #! /usr/bin/env pwsh
2
+
3
+ Set-Variable tempfile -option Constant -value "tempfile"
4
+
5
+ function hash($path) {
6
+ $fullPath = Resolve-Path $path
7
+ $hash = new-object -TypeName System.Security.Cryptography.SHA256CryptoServiceProvider
8
+
9
+ $contents = [IO.File]::ReadAllText($fullPath) -replace "`r`n?", "`n"
10
+ # create UTF-8 encoding without signature
11
+ $utf8 = New-Object System.Text.UTF8Encoding $false
12
+ # write the text back
13
+ [IO.File]::WriteAllText($tempfile, $contents, $utf8)
14
+
15
+ $file = [System.IO.File]::Open($tempfile,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
16
+ $result = [System.BitConverter]::ToString($hash.ComputeHash($file))
17
+ $file.Dispose()
18
+
19
+ if (Test-Path $tempfile) {
20
+ Remove-Item $tempfile
21
+ }
22
+
23
+ return $result
24
+ }
25
+
26
+ function main() {
27
+ $files = $(Get-ChildItem * | Where-Object { $_.Name -match '^[a-z2]*(_v)?[0-9]*$' } | select -ExpandProperty name)
28
+ $_exit_code = 0
29
+
30
+ foreach ($file in $files) {
31
+ $new = $(hash $file).replace("-","")
32
+ $new = $new.ToLower()
33
+
34
+ $old=$(Get-Content $file".shasum")
35
+ $old = $old.Substring(0, $old.IndexOf(" "))
36
+
37
+ if ($new -eq $old) {
38
+ Write-Host $file "`tOK"
39
+ } else {
40
+ Write-Host $file "`tERROR: checksum mismatch"
41
+ $_exit_code = 1
42
+ }
43
+ }
44
+
45
+ return $_exit_code
46
+ }
47
+
48
+ exit $(main)
@@ -0,0 +1,16 @@
1
+ #! /usr/bin/env bash
2
+
3
+ _exit_code=0
4
+
5
+ for file in $(ls | grep '^[a-z2]*\(_v\)\?[0-9]*$' | xargs); do
6
+ new=$(shasum -a 256 "${file}")
7
+ old=$(cat "${file}.shasum")
8
+ if [ "${new}" = "${old}" ]; then
9
+ echo -e "${file} \t OK"
10
+ else
11
+ echo -e "${file} \t ERROR: checksum mismatch"
12
+ _exit_code=1
13
+ fi
14
+ done
15
+
16
+ exit ${_exit_code}
@@ -0,0 +1,132 @@
1
+ #! /usr/bin/env pwsh
2
+
3
+ $ErrorActionPreference = "Stop"
4
+
5
+ function New-TemporaryDirectory {
6
+ $parent = [System.IO.Path]::GetTempPath()
7
+ $name = [System.IO.Path]::GetRandomFileName()
8
+ New-Item -ItemType Directory -Path (Join-Path $parent "genkat.$name")
9
+ }
10
+
11
+ function Get-OSName {
12
+ $osname = "Windows"
13
+ if (Get-Command "uname" -errorAction SilentlyContinue) {
14
+ $osname = $(uname)
15
+ }
16
+ return $osname
17
+ }
18
+
19
+ function Get-PSScriptRoot {
20
+ $ScriptRoot = ""
21
+ try {
22
+ $ScriptRoot = Get-Variable -Name PSScriptRoot -ValueOnly -ErrorAction Stop
23
+ } catch {
24
+ $ScriptRoot = Split-Path $script:MyInvocation.MyCommand.Path
25
+ }
26
+ return $ScriptRoot
27
+ }
28
+
29
+ function CompareFiles($f1, $f2, $i) {
30
+ $f1_content = $(Get-Content $f1)
31
+ $f2_content = $(Get-Content $f2)
32
+
33
+ if (Compare-Object $f1_content $f2_content) {
34
+ Write-Host -NoNewline "ERROR"
35
+ exit $i
36
+ } else {
37
+ Write-Host -NoNewline "OK"
38
+ }
39
+ }
40
+
41
+ $help = @"
42
+ Usage: test.sh [flags]
43
+
44
+ Options:
45
+ -h,--help: Display this help
46
+ --genkat: Location of genkat binary
47
+ -v,--verbose: Verbose output
48
+ "@
49
+
50
+ function parseOptions ($argv, $options) {
51
+ $opts = @()
52
+ if (!$argv) { return $null }
53
+
54
+ foreach ($arg in $argv) {
55
+ $test = ($arg -is [int]) -or
56
+ ($arg -is [string]) -or
57
+ ($arg -is [float])
58
+ if (!$test) {
59
+ Write-Host "Bad argument: $arg is not an integer, float, nor string." -ForegroundColor Red
60
+ throw "Error: Bad Argument"
61
+ }
62
+ if ($arg -like '-*') {
63
+ $opts += $arg
64
+ }
65
+ }
66
+
67
+ if ($opts) {
68
+ foreach ($opt in $opts) {
69
+ switch ($opt) {
70
+ {$PSItem -eq '--genkat'} {
71
+ $opt_value_i = $argv.IndexOf($opt) + 1;
72
+ $options.genkat = [string] $argv[$opt_value_i];
73
+ $argv.RemoveAt($opt_value_i)
74
+ }
75
+ {($PSItem -eq '-h') -or ($PSItem -eq '--help')} {
76
+ Write-Host $help -ForegroundColor Cyan;
77
+ break 1
78
+ }
79
+ {($PSItem -eq '-v') -or ($PSItem -eq '--verbose')} {
80
+ $options.verbose = [bool] 1
81
+ }
82
+ default {
83
+ Write-Host "Bad option: $opt is not a valid option." -ForegroundColor Red
84
+ throw "Error: Bad Option"
85
+ }
86
+ }
87
+ $argv.Remove($opt)
88
+ }
89
+ }
90
+ return [array]$argv,$options
91
+ }#fn
92
+
93
+ function main($argv) {
94
+
95
+ $options = @{
96
+ genkat = [string] ""
97
+ help = [bool] 0
98
+ verbose = [bool] 0
99
+ }
100
+
101
+ $argv,$optparsed = parseOptions $argv $options
102
+ $scriptPath = Get-PSScriptRoot
103
+
104
+ Set-Variable tempdir -option Constant -value $(New-TemporaryDirectory)
105
+
106
+ $genkat = $options.genkat
107
+
108
+ $i = 0
109
+ foreach ($version in @(16, 19)) {
110
+ foreach ($type in @("i", "d", "id")) {
111
+ $i++
112
+
113
+ if (19 -eq $version) {
114
+ $kats = "argon2" + $type
115
+ } else {
116
+ $kats = "argon2" + $type + "_v" + $version
117
+ }
118
+
119
+ & $genkat $type $version > "$tempdir\$kats"
120
+
121
+ Write-Host -NoNewline "Argon2$type `tv=$version`: `t"
122
+ CompareFiles $tempdir\$kats $scriptPath\$kats $i
123
+ Write-Output ""
124
+ }
125
+ }
126
+
127
+ if (Test-Path $tempdir) {
128
+ Remove-Item -Recurse $tempdir
129
+ }
130
+ }
131
+
132
+ main $(New-Object System.Collections.ArrayList(,$args))
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -o errexit
4
+ set -o pipefail
5
+
6
+ export PS4="+${BASH_SOURCE[0]}:${LINENO}:${FUNCNAME}: "
7
+ #set -o xtrace
8
+
9
+ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
11
+ __base="$(basename ${__file} .bash)"
12
+
13
+ function __usage ()
14
+ {
15
+ cat <<-USAGE_HELP
16
+ Usage: ${__base} [flags]
17
+
18
+ Options:
19
+ --genkat: Location of genkat binary
20
+ -h,--help: Display this help
21
+ -v,--verbose: Verbose output
22
+ USAGE_HELP
23
+ }
24
+
25
+ function __parse_args() {
26
+ if [[ $# -eq 0 ]]; then
27
+ __usage
28
+ exit 1
29
+ fi
30
+
31
+ while true; do
32
+ case ${1} in
33
+ -h|-\?|--help)
34
+ __usage
35
+ exit 0
36
+ ;;
37
+ --genkat)
38
+ if [ -n "$2" ]; then
39
+ _genkat=$2
40
+ shift
41
+ else
42
+ printf 'ERROR: "--genkat" requires a non-empty option argument.\n' >&2
43
+ exit 1
44
+ fi
45
+ ;;
46
+ --genkat=?*)
47
+ _genkat=${1#*=} # Delete everything up to "=" and assign the remainder.
48
+ ;;
49
+ --genkat=) # Handle the case of an empty --genkat=
50
+ printf 'ERROR: "--genkat" requires a non-empty option argument.\n' >&2
51
+ exit 1
52
+ ;;
53
+ -v|--verbose)
54
+ _verbose=$((verbose + 1)) # Each -v argument adds 1 to verbosity.
55
+ ;;
56
+ --) # End of all options.
57
+ shift
58
+ break
59
+ ;;
60
+ -?*)
61
+ printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
62
+ ;;
63
+ *) # Default case: If no more options then break out of the loop.
64
+ break
65
+ esac
66
+
67
+ shift
68
+ done
69
+
70
+ if [[ -z ${_genkat+1} ]]; then
71
+ __usage
72
+ exit 1
73
+ fi
74
+ if [[ ! -f ${_genkat} ]]; then
75
+ printf "ERROR: ${_genkat} does not exist.\n" >&2
76
+ exit 2
77
+ fi
78
+ }
79
+
80
+ function __main () {
81
+
82
+ __parse_args $@
83
+
84
+ # create temporary directory
85
+ local tmpdir=$(mktemp -d "${TMPDIR:-/tmp/}genkat.XXXXXXXXXXXX")
86
+ mkdir -p ${tmpdir}
87
+
88
+ i=0
89
+ for version in 16 19; do
90
+ for type in i d id; do
91
+ i=$(($i+1))
92
+
93
+ printf "argon2$type \tv=$version: \t"
94
+
95
+ if [ 19 -eq $version ]; then
96
+ kats="argon2"$type
97
+ else
98
+ kats="argon2"$type"_v"$version
99
+ fi
100
+
101
+ ${_genkat} $type $version > "${tmpdir}/${kats}"
102
+ if diff --strip-trailing-cr "${tmpdir}/${kats}" "${__dir}/$kats"; then
103
+ printf "OK"
104
+ else
105
+ printf "ERROR"
106
+ exit $i
107
+ fi
108
+ printf "\n"
109
+ done
110
+ done
111
+
112
+ rm -rf ${tmpdir}
113
+
114
+ exit 0
115
+ }
116
+
117
+ __main $@
@@ -0,0 +1,34 @@
1
+ #############
2
+ # UNITTESTS #
3
+ #############
4
+
5
+ argon2_tests = executable('argon2-tests',
6
+ sources: 'test.c',
7
+ dependencies: argon2_shared_dep,
8
+ install: false)
9
+
10
+ test('argon2 tests', argon2_tests, timeout: 90)
11
+
12
+ ##########
13
+ # GENKAT #
14
+ ##########
15
+
16
+ genkat = executable('genkat',
17
+ sources: 'genkat.c',
18
+ dependencies: argon2_genkat_dep,
19
+ install: false)
20
+
21
+ genkat_test_script = build_machine.system() == 'windows' ? 'kats/test.ps1' : 'kats/test.sh'
22
+ genkat_wrapper = find_program([genkat_test_script], required : true)
23
+ test('argon2 genkat', genkat_wrapper, args: ['--genkat', genkat.full_path()])
24
+
25
+ #############
26
+ # BENCHMARK #
27
+ #############
28
+
29
+ argon2_benchmark = executable('bench',
30
+ sources: 'bench.c',
31
+ dependencies: argon2_static_dep,
32
+ install: false)
33
+
34
+ benchmark('argon2 benchmark', argon2_benchmark, timeout: 200)
@@ -0,0 +1,289 @@
1
+ /*
2
+ * Argon2 reference source code package - reference C implementations
3
+ *
4
+ * Copyright 2015
5
+ * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
6
+ *
7
+ * You may use this work under the terms of a Creative Commons CC0 1.0
8
+ * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
+ * these licenses can be found at:
10
+ *
11
+ * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * You should have received a copy of both of these licenses along with this
15
+ * software. If not, they may be obtained at the above URLs.
16
+ */
17
+
18
+ #include <stdio.h>
19
+ #include <stdint.h>
20
+ #include <stdlib.h>
21
+ #include <string.h>
22
+ #include <time.h>
23
+ #include <assert.h>
24
+
25
+ #include "argon2.h"
26
+
27
+ #define OUT_LEN 32
28
+ #define ENCODED_LEN 108
29
+
30
+ /* Test harness will assert:
31
+ * argon2_hash() returns ARGON2_OK
32
+ * HEX output matches expected
33
+ * encoded output matches expected
34
+ * argon2_verify() correctly verifies value
35
+ */
36
+
37
+ void hashtest(uint32_t version, uint32_t t, uint32_t m, uint32_t p, char *pwd,
38
+ char *salt, char *hexref, char *mcfref, argon2_type type) {
39
+ unsigned char out[OUT_LEN];
40
+ unsigned char hex_out[OUT_LEN * 2 + 4];
41
+ char encoded[ENCODED_LEN];
42
+ int ret, i;
43
+
44
+ printf("Hash test: $v=%d t=%d, m=%d, p=%d, pass=%s, salt=%s: ",
45
+ version, t, m, p, pwd, salt);
46
+
47
+ ret = argon2_hash(t, 1 << m, p, pwd, strlen(pwd), salt, strlen(salt), out,
48
+ OUT_LEN, encoded, ENCODED_LEN, type, version);
49
+ assert(ret == ARGON2_OK);
50
+
51
+ for (i = 0; i < OUT_LEN; ++i)
52
+ sprintf((char *)(hex_out + i * 2), "%02x", out[i]);
53
+ assert(memcmp(hex_out, hexref, OUT_LEN * 2) == 0);
54
+
55
+ if (ARGON2_VERSION_NUMBER == version) {
56
+ assert(memcmp(encoded, mcfref, strlen(mcfref)) == 0);
57
+ }
58
+
59
+ ret = argon2_verify(encoded, pwd, strlen(pwd), type);
60
+ assert(ret == ARGON2_OK);
61
+ ret = argon2_verify(mcfref, pwd, strlen(pwd), type);
62
+ assert(ret == ARGON2_OK);
63
+
64
+ printf("PASS\n");
65
+ }
66
+
67
+ int main() {
68
+ int ret;
69
+ unsigned char out[OUT_LEN];
70
+ char const *msg;
71
+ int version;
72
+
73
+ version = ARGON2_VERSION_10;
74
+ printf("Test Argon2i version number: %02x\n", version);
75
+
76
+ /* Multiple test cases for various input values */
77
+ hashtest(version, 2, 16, 1, "password", "somesalt",
78
+ "f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694",
79
+ "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
80
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", Argon2_i);
81
+ #ifdef TEST_LARGE_RAM
82
+ hashtest(version, 2, 20, 1, "password", "somesalt",
83
+ "9690ec55d28d3ed32562f2e73ea62b02b018757643a2ae6e79528459de8106e9",
84
+ "$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQ"
85
+ "$lpDsVdKNPtMlYvLnPqYrArAYdXZDoq5ueVKEWd6BBuk", Argon2_i);
86
+ #endif
87
+ hashtest(version, 2, 18, 1, "password", "somesalt",
88
+ "3e689aaa3d28a77cf2bc72a51ac53166761751182f1ee292e3f677a7da4c2467",
89
+ "$argon2i$m=262144,t=2,p=1$c29tZXNhbHQ"
90
+ "$Pmiaqj0op3zyvHKlGsUxZnYXURgvHuKS4/Z3p9pMJGc", Argon2_i);
91
+ hashtest(version, 2, 8, 1, "password", "somesalt",
92
+ "fd4dd83d762c49bdeaf57c47bdcd0c2f1babf863fdeb490df63ede9975fccf06",
93
+ "$argon2i$m=256,t=2,p=1$c29tZXNhbHQ"
94
+ "$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY", Argon2_i);
95
+ hashtest(version, 2, 8, 2, "password", "somesalt",
96
+ "b6c11560a6a9d61eac706b79a2f97d68b4463aa3ad87e00c07e2b01e90c564fb",
97
+ "$argon2i$m=256,t=2,p=2$c29tZXNhbHQ"
98
+ "$tsEVYKap1h6scGt5ovl9aLRGOqOth+AMB+KwHpDFZPs", Argon2_i);
99
+ hashtest(version, 1, 16, 1, "password", "somesalt",
100
+ "81630552b8f3b1f48cdb1992c4c678643d490b2b5eb4ff6c4b3438b5621724b2",
101
+ "$argon2i$m=65536,t=1,p=1$c29tZXNhbHQ"
102
+ "$gWMFUrjzsfSM2xmSxMZ4ZD1JCytetP9sSzQ4tWIXJLI", Argon2_i);
103
+ hashtest(version, 4, 16, 1, "password", "somesalt",
104
+ "f212f01615e6eb5d74734dc3ef40ade2d51d052468d8c69440a3a1f2c1c2847b",
105
+ "$argon2i$m=65536,t=4,p=1$c29tZXNhbHQ"
106
+ "$8hLwFhXm6110c03D70Ct4tUdBSRo2MaUQKOh8sHChHs", Argon2_i);
107
+ hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
108
+ "e9c902074b6754531a3a0be519e5baf404b30ce69b3f01ac3bf21229960109a3",
109
+ "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
110
+ "$6ckCB0tnVFMaOgvlGeW69ASzDOabPwGsO/ISKZYBCaM", Argon2_i);
111
+ hashtest(version, 2, 16, 1, "password", "diffsalt",
112
+ "79a103b90fe8aef8570cb31fc8b22259778916f8336b7bdac3892569d4f1c497",
113
+ "$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQ"
114
+ "$eaEDuQ/orvhXDLMfyLIiWXeJFvgza3vaw4kladTxxJc", Argon2_i);
115
+
116
+ /* Error state tests */
117
+
118
+ /* Handle an invalid encoding correctly (it is missing a $) */
119
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
120
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
121
+ "password", strlen("password"), Argon2_i);
122
+ assert(ret == ARGON2_DECODING_FAIL);
123
+ printf("Recognise an invalid encoding: PASS\n");
124
+
125
+ /* Handle an invalid encoding correctly (it is missing a $) */
126
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
127
+ "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
128
+ "password", strlen("password"), Argon2_i);
129
+ assert(ret == ARGON2_DECODING_FAIL);
130
+ printf("Recognise an invalid encoding: PASS\n");
131
+
132
+ /* Handle an invalid encoding correctly (salt is too short) */
133
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1$"
134
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
135
+ "password", strlen("password"), Argon2_i);
136
+ assert(ret == ARGON2_SALT_TOO_SHORT);
137
+ printf("Recognise an invalid salt in encoding: PASS\n");
138
+
139
+ /* Handle an mismatching hash (the encoded password is "passwore") */
140
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
141
+ "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
142
+ "password", strlen("password"), Argon2_i);
143
+ assert(ret == ARGON2_VERIFY_MISMATCH);
144
+ printf("Verify with mismatched password: PASS\n");
145
+
146
+ msg = argon2_error_message(ARGON2_DECODING_FAIL);
147
+ assert(strcmp(msg, "Decoding failed") == 0);
148
+ printf("Decode an error message: PASS\n");
149
+
150
+ printf("\n");
151
+
152
+ version = ARGON2_VERSION_NUMBER;
153
+ printf("Test Argon2i version number: %02x\n", version);
154
+
155
+ /* Multiple test cases for various input values */
156
+ hashtest(version, 2, 16, 1, "password", "somesalt",
157
+ "c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0",
158
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
159
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA", Argon2_i);
160
+ #ifdef TEST_LARGE_RAM
161
+ hashtest(version, 2, 20, 1, "password", "somesalt",
162
+ "d1587aca0922c3b5d6a83edab31bee3c4ebaef342ed6127a55d19b2351ad1f41",
163
+ "$argon2i$v=19$m=1048576,t=2,p=1$c29tZXNhbHQ"
164
+ "$0Vh6ygkiw7XWqD7asxvuPE667zQu1hJ6VdGbI1GtH0E", Argon2_i);
165
+ #endif
166
+ hashtest(version, 2, 18, 1, "password", "somesalt",
167
+ "296dbae80b807cdceaad44ae741b506f14db0959267b183b118f9b24229bc7cb",
168
+ "$argon2i$v=19$m=262144,t=2,p=1$c29tZXNhbHQ"
169
+ "$KW266AuAfNzqrUSudBtQbxTbCVkmexg7EY+bJCKbx8s", Argon2_i);
170
+ hashtest(version, 2, 8, 1, "password", "somesalt",
171
+ "89e9029f4637b295beb027056a7336c414fadd43f6b208645281cb214a56452f",
172
+ "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ"
173
+ "$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8", Argon2_i);
174
+ hashtest(version, 2, 8, 2, "password", "somesalt",
175
+ "4ff5ce2769a1d7f4c8a491df09d41a9fbe90e5eb02155a13e4c01e20cd4eab61",
176
+ "$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ"
177
+ "$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2E", Argon2_i);
178
+ hashtest(version, 1, 16, 1, "password", "somesalt",
179
+ "d168075c4d985e13ebeae560cf8b94c3b5d8a16c51916b6f4ac2da3ac11bbecf",
180
+ "$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQ"
181
+ "$0WgHXE2YXhPr6uVgz4uUw7XYoWxRkWtvSsLaOsEbvs8", Argon2_i);
182
+ hashtest(version, 4, 16, 1, "password", "somesalt",
183
+ "aaa953d58af3706ce3df1aefd4a64a84e31d7f54175231f1285259f88174ce5b",
184
+ "$argon2i$v=19$m=65536,t=4,p=1$c29tZXNhbHQ"
185
+ "$qqlT1YrzcGzj3xrv1KZKhOMdf1QXUjHxKFJZ+IF0zls", Argon2_i);
186
+ hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
187
+ "14ae8da01afea8700c2358dcef7c5358d9021282bd88663a4562f59fb74d22ee",
188
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
189
+ "$FK6NoBr+qHAMI1jc73xTWNkCEoK9iGY6RWL1n7dNIu4", Argon2_i);
190
+ hashtest(version, 2, 16, 1, "password", "diffsalt",
191
+ "b0357cccfbef91f3860b0dba447b2348cbefecadaf990abfe9cc40726c521271",
192
+ "$argon2i$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ"
193
+ "$sDV8zPvvkfOGCw26RHsjSMvv7K2vmQq/6cxAcmxSEnE", Argon2_i);
194
+
195
+
196
+ /* Error state tests */
197
+
198
+ /* Handle an invalid encoding correctly (it is missing a $) */
199
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
200
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
201
+ "password", strlen("password"), Argon2_i);
202
+ assert(ret == ARGON2_DECODING_FAIL);
203
+ printf("Recognise an invalid encoding: PASS\n");
204
+
205
+ /* Handle an invalid encoding correctly (it is missing a $) */
206
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
207
+ "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
208
+ "password", strlen("password"), Argon2_i);
209
+ assert(ret == ARGON2_DECODING_FAIL);
210
+ printf("Recognise an invalid encoding: PASS\n");
211
+
212
+ /* Handle an invalid encoding correctly (salt is too short) */
213
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$"
214
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
215
+ "password", strlen("password"), Argon2_i);
216
+ assert(ret == ARGON2_SALT_TOO_SHORT);
217
+ printf("Recognise an invalid salt in encoding: PASS\n");
218
+
219
+ /* Handle an mismatching hash (the encoded password is "passwore") */
220
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
221
+ "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
222
+ "password", strlen("password"), Argon2_i);
223
+ assert(ret == ARGON2_VERIFY_MISMATCH);
224
+ printf("Verify with mismatched password: PASS\n");
225
+
226
+ msg = argon2_error_message(ARGON2_DECODING_FAIL);
227
+ assert(strcmp(msg, "Decoding failed") == 0);
228
+ printf("Decode an error message: PASS\n\n");
229
+
230
+ printf("Test Argon2id version number: %02x\n", version);
231
+
232
+ /* Multiple test cases for various input values */
233
+ hashtest(version, 2, 16, 1, "password", "somesalt",
234
+ "09316115d5cf24ed5a15a31a3ba326e5cf32edc24702987c02b6566f61913cf7",
235
+ "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
236
+ "$CTFhFdXPJO1aFaMaO6Mm5c8y7cJHAph8ArZWb2GRPPc", Argon2_id);
237
+ hashtest(version, 2, 18, 1, "password", "somesalt",
238
+ "78fe1ec91fb3aa5657d72e710854e4c3d9b9198c742f9616c2f085bed95b2e8c",
239
+ "$argon2id$v=19$m=262144,t=2,p=1$c29tZXNhbHQ"
240
+ "$eP4eyR+zqlZX1y5xCFTkw9m5GYx0L5YWwvCFvtlbLow", Argon2_id);
241
+ hashtest(version, 2, 8, 1, "password", "somesalt",
242
+ "9dfeb910e80bad0311fee20f9c0e2b12c17987b4cac90c2ef54d5b3021c68bfe",
243
+ "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ"
244
+ "$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4", Argon2_id);
245
+ hashtest(version, 2, 8, 2, "password", "somesalt",
246
+ "6d093c501fd5999645e0ea3bf620d7b8be7fd2db59c20d9fff9539da2bf57037",
247
+ "$argon2id$v=19$m=256,t=2,p=2$c29tZXNhbHQ"
248
+ "$bQk8UB/VmZZF4Oo79iDXuL5/0ttZwg2f/5U52iv1cDc", Argon2_id);
249
+ hashtest(version, 1, 16, 1, "password", "somesalt",
250
+ "f6a5adc1ba723dddef9b5ac1d464e180fcd9dffc9d1cbf76cca2fed795d9ca98",
251
+ "$argon2id$v=19$m=65536,t=1,p=1$c29tZXNhbHQ"
252
+ "$9qWtwbpyPd3vm1rB1GThgPzZ3/ydHL92zKL+15XZypg", Argon2_id);
253
+ hashtest(version, 4, 16, 1, "password", "somesalt",
254
+ "9025d48e68ef7395cca9079da4c4ec3affb3c8911fe4f86d1a2520856f63172c",
255
+ "$argon2id$v=19$m=65536,t=4,p=1$c29tZXNhbHQ"
256
+ "$kCXUjmjvc5XMqQedpMTsOv+zyJEf5PhtGiUghW9jFyw", Argon2_id);
257
+ hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
258
+ "0b84d652cf6b0c4beaef0dfe278ba6a80df6696281d7e0d2891b817d8c458fde",
259
+ "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
260
+ "$C4TWUs9rDEvq7w3+J4umqA32aWKB1+DSiRuBfYxFj94", Argon2_id);
261
+ hashtest(version, 2, 16, 1, "password", "diffsalt",
262
+ "bdf32b05ccc42eb15d58fd19b1f856b113da1e9a5874fdcc544308565aa8141c",
263
+ "$argon2id$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ"
264
+ "$vfMrBczELrFdWP0ZsfhWsRPaHppYdP3MVEMIVlqoFBw", Argon2_id);
265
+
266
+ /* Common error state tests */
267
+
268
+ printf("\n");
269
+ printf("Common error state tests\n");
270
+
271
+ ret = argon2_hash(2, 1, 1, "password", strlen("password"),
272
+ "diffsalt", strlen("diffsalt"),
273
+ out, OUT_LEN, NULL, 0, Argon2_id, version);
274
+ assert(ret == ARGON2_MEMORY_TOO_LITTLE);
275
+ printf("Fail on invalid memory: PASS\n");
276
+
277
+ ret = argon2_hash(2, 1 << 12, 1, NULL, strlen("password"),
278
+ "diffsalt", strlen("diffsalt"),
279
+ out, OUT_LEN, NULL, 0, Argon2_id, version);
280
+ assert(ret == ARGON2_PWD_PTR_MISMATCH);
281
+ printf("Fail on invalid null pointer: PASS\n");
282
+
283
+ ret = argon2_hash(2, 1 << 12, 1, "password", strlen("password"), "s", 1,
284
+ out, OUT_LEN, NULL, 0, Argon2_id, version);
285
+ assert(ret == ARGON2_SALT_TOO_SHORT);
286
+ printf("Fail on salt too short: PASS\n");
287
+
288
+ return 0;
289
+ }
@@ -0,0 +1,7 @@
1
+ add_executable(argon2 "main.c")
2
+
3
+ target_link_libraries(argon2 PUBLIC argon2-static)
4
+
5
+ install(TARGETS argon2
6
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
7
+ )