@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,360 @@
1
+ /* hash.c April 2012
2
+ * Groestl ANSI C code optimised for 32-bit machines
3
+ * Author: Thomas Krinninger
4
+ *
5
+ * This work is based on the implementation of
6
+ * Soeren S. Thomsen and Krystian Matusiewicz
7
+ *
8
+ *
9
+ */
10
+
11
+ #include "c_groestl.h"
12
+ #include "groestl_tables.h"
13
+
14
+ #define P_TYPE 0
15
+ #define Q_TYPE 1
16
+
17
+ const uint8_t shift_Values[2][8] = {{0,1,2,3,4,5,6,7},{1,3,5,7,0,2,4,6}};
18
+
19
+ const uint8_t indices_cyclic[15] = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6};
20
+
21
+
22
+ #define ROTATE_COLUMN_DOWN(v1, v2, amount_bytes, temp_var) {temp_var = (v1<<(8*amount_bytes))|(v2>>(8*(4-amount_bytes))); \
23
+ v2 = (v2<<(8*amount_bytes))|(v1>>(8*(4-amount_bytes))); \
24
+ v1 = temp_var;}
25
+
26
+
27
+ #define COLUMN(x,y,i,c0,c1,c2,c3,c4,c5,c6,c7,tv1,tv2,tu,tl,t) \
28
+ tu = T[2*(uint32_t)x[4*c0+0]]; \
29
+ tl = T[2*(uint32_t)x[4*c0+0]+1]; \
30
+ tv1 = T[2*(uint32_t)x[4*c1+1]]; \
31
+ tv2 = T[2*(uint32_t)x[4*c1+1]+1]; \
32
+ ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \
33
+ tu ^= tv1; \
34
+ tl ^= tv2; \
35
+ tv1 = T[2*(uint32_t)x[4*c2+2]]; \
36
+ tv2 = T[2*(uint32_t)x[4*c2+2]+1]; \
37
+ ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \
38
+ tu ^= tv1; \
39
+ tl ^= tv2; \
40
+ tv1 = T[2*(uint32_t)x[4*c3+3]]; \
41
+ tv2 = T[2*(uint32_t)x[4*c3+3]+1]; \
42
+ ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \
43
+ tu ^= tv1; \
44
+ tl ^= tv2; \
45
+ tl ^= T[2*(uint32_t)x[4*c4+0]]; \
46
+ tu ^= T[2*(uint32_t)x[4*c4+0]+1]; \
47
+ tv1 = T[2*(uint32_t)x[4*c5+1]]; \
48
+ tv2 = T[2*(uint32_t)x[4*c5+1]+1]; \
49
+ ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \
50
+ tl ^= tv1; \
51
+ tu ^= tv2; \
52
+ tv1 = T[2*(uint32_t)x[4*c6+2]]; \
53
+ tv2 = T[2*(uint32_t)x[4*c6+2]+1]; \
54
+ ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \
55
+ tl ^= tv1; \
56
+ tu ^= tv2; \
57
+ tv1 = T[2*(uint32_t)x[4*c7+3]]; \
58
+ tv2 = T[2*(uint32_t)x[4*c7+3]+1]; \
59
+ ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \
60
+ tl ^= tv1; \
61
+ tu ^= tv2; \
62
+ y[i] = tu; \
63
+ y[i+1] = tl;
64
+
65
+
66
+ /* compute one round of P (short variants) */
67
+ static void RND512P(uint8_t *x, uint32_t *y, uint32_t r) {
68
+ uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp;
69
+ uint32_t* x32 = (uint32_t*)x;
70
+ x32[ 0] ^= 0x00000000^r;
71
+ x32[ 2] ^= 0x00000010^r;
72
+ x32[ 4] ^= 0x00000020^r;
73
+ x32[ 6] ^= 0x00000030^r;
74
+ x32[ 8] ^= 0x00000040^r;
75
+ x32[10] ^= 0x00000050^r;
76
+ x32[12] ^= 0x00000060^r;
77
+ x32[14] ^= 0x00000070^r;
78
+ COLUMN(x,y, 0, 0, 2, 4, 6, 9, 11, 13, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
79
+ COLUMN(x,y, 2, 2, 4, 6, 8, 11, 13, 15, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
80
+ COLUMN(x,y, 4, 4, 6, 8, 10, 13, 15, 1, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
81
+ COLUMN(x,y, 6, 6, 8, 10, 12, 15, 1, 3, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
82
+ COLUMN(x,y, 8, 8, 10, 12, 14, 1, 3, 5, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
83
+ COLUMN(x,y,10, 10, 12, 14, 0, 3, 5, 7, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
84
+ COLUMN(x,y,12, 12, 14, 0, 2, 5, 7, 9, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
85
+ COLUMN(x,y,14, 14, 0, 2, 4, 7, 9, 11, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
86
+ }
87
+
88
+ /* compute one round of Q (short variants) */
89
+ static void RND512Q(uint8_t *x, uint32_t *y, uint32_t r) {
90
+ uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp;
91
+ uint32_t* x32 = (uint32_t*)x;
92
+ x32[ 0] = ~x32[ 0];
93
+ x32[ 1] ^= 0xffffffff^r;
94
+ x32[ 2] = ~x32[ 2];
95
+ x32[ 3] ^= 0xefffffff^r;
96
+ x32[ 4] = ~x32[ 4];
97
+ x32[ 5] ^= 0xdfffffff^r;
98
+ x32[ 6] = ~x32[ 6];
99
+ x32[ 7] ^= 0xcfffffff^r;
100
+ x32[ 8] = ~x32[ 8];
101
+ x32[ 9] ^= 0xbfffffff^r;
102
+ x32[10] = ~x32[10];
103
+ x32[11] ^= 0xafffffff^r;
104
+ x32[12] = ~x32[12];
105
+ x32[13] ^= 0x9fffffff^r;
106
+ x32[14] = ~x32[14];
107
+ x32[15] ^= 0x8fffffff^r;
108
+ COLUMN(x,y, 0, 2, 6, 10, 14, 1, 5, 9, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
109
+ COLUMN(x,y, 2, 4, 8, 12, 0, 3, 7, 11, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
110
+ COLUMN(x,y, 4, 6, 10, 14, 2, 5, 9, 13, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
111
+ COLUMN(x,y, 6, 8, 12, 0, 4, 7, 11, 15, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
112
+ COLUMN(x,y, 8, 10, 14, 2, 6, 9, 13, 1, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
113
+ COLUMN(x,y,10, 12, 0, 4, 8, 11, 15, 3, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
114
+ COLUMN(x,y,12, 14, 2, 6, 10, 13, 1, 5, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
115
+ COLUMN(x,y,14, 0, 4, 8, 12, 15, 3, 7, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
116
+ }
117
+
118
+ /* compute compression function (short variants) */
119
+ static void F512(uint32_t *h, const uint32_t *m) {
120
+ int i;
121
+ uint32_t Ptmp[2*COLS512];
122
+ uint32_t Qtmp[2*COLS512];
123
+ uint32_t y[2*COLS512];
124
+ uint32_t z[2*COLS512];
125
+
126
+ for (i = 0; i < 2*COLS512; i++) {
127
+ z[i] = m[i];
128
+ Ptmp[i] = h[i]^m[i];
129
+ }
130
+
131
+ /* compute Q(m) */
132
+ RND512Q((uint8_t*)z, y, 0x00000000);
133
+ RND512Q((uint8_t*)y, z, 0x01000000);
134
+ RND512Q((uint8_t*)z, y, 0x02000000);
135
+ RND512Q((uint8_t*)y, z, 0x03000000);
136
+ RND512Q((uint8_t*)z, y, 0x04000000);
137
+ RND512Q((uint8_t*)y, z, 0x05000000);
138
+ RND512Q((uint8_t*)z, y, 0x06000000);
139
+ RND512Q((uint8_t*)y, z, 0x07000000);
140
+ RND512Q((uint8_t*)z, y, 0x08000000);
141
+ RND512Q((uint8_t*)y, Qtmp, 0x09000000);
142
+
143
+ /* compute P(h+m) */
144
+ RND512P((uint8_t*)Ptmp, y, 0x00000000);
145
+ RND512P((uint8_t*)y, z, 0x00000001);
146
+ RND512P((uint8_t*)z, y, 0x00000002);
147
+ RND512P((uint8_t*)y, z, 0x00000003);
148
+ RND512P((uint8_t*)z, y, 0x00000004);
149
+ RND512P((uint8_t*)y, z, 0x00000005);
150
+ RND512P((uint8_t*)z, y, 0x00000006);
151
+ RND512P((uint8_t*)y, z, 0x00000007);
152
+ RND512P((uint8_t*)z, y, 0x00000008);
153
+ RND512P((uint8_t*)y, Ptmp, 0x00000009);
154
+
155
+ /* compute P(h+m) + Q(m) + h */
156
+ for (i = 0; i < 2*COLS512; i++) {
157
+ h[i] ^= Ptmp[i]^Qtmp[i];
158
+ }
159
+ }
160
+
161
+
162
+ /* digest up to msglen bytes of input (full blocks only) */
163
+ static void Transform(hashState *ctx,
164
+ const uint8_t *input,
165
+ int msglen) {
166
+
167
+ /* digest message, one block at a time */
168
+ for (; msglen >= SIZE512;
169
+ msglen -= SIZE512, input += SIZE512) {
170
+ F512(ctx->chaining,(uint32_t*)input);
171
+
172
+ /* increment block counter */
173
+ ctx->block_counter1++;
174
+ if (ctx->block_counter1 == 0) ctx->block_counter2++;
175
+ }
176
+ }
177
+
178
+ /* given state h, do h <- P(h)+h */
179
+ static void OutputTransformation(hashState *ctx) {
180
+ int j;
181
+ uint32_t temp[2*COLS512];
182
+ uint32_t y[2*COLS512];
183
+ uint32_t z[2*COLS512];
184
+
185
+
186
+
187
+ for (j = 0; j < 2*COLS512; j++) {
188
+ temp[j] = ctx->chaining[j];
189
+ }
190
+ RND512P((uint8_t*)temp, y, 0x00000000);
191
+ RND512P((uint8_t*)y, z, 0x00000001);
192
+ RND512P((uint8_t*)z, y, 0x00000002);
193
+ RND512P((uint8_t*)y, z, 0x00000003);
194
+ RND512P((uint8_t*)z, y, 0x00000004);
195
+ RND512P((uint8_t*)y, z, 0x00000005);
196
+ RND512P((uint8_t*)z, y, 0x00000006);
197
+ RND512P((uint8_t*)y, z, 0x00000007);
198
+ RND512P((uint8_t*)z, y, 0x00000008);
199
+ RND512P((uint8_t*)y, temp, 0x00000009);
200
+ for (j = 0; j < 2*COLS512; j++) {
201
+ ctx->chaining[j] ^= temp[j];
202
+ }
203
+ }
204
+
205
+ /* initialise context */
206
+ static void Init(hashState* ctx) {
207
+ uint32_t i = 0;
208
+ /* allocate memory for state and data buffer */
209
+
210
+ for(;i<(SIZE512/sizeof(uint32_t));i++)
211
+ {
212
+ ctx->chaining[i] = 0;
213
+ }
214
+
215
+ /* set initial value */
216
+ ctx->chaining[2*COLS512-1] = u32BIG((uint32_t)HASH_BIT_LEN);
217
+
218
+ /* set other variables */
219
+ ctx->buf_ptr = 0;
220
+ ctx->block_counter1 = 0;
221
+ ctx->block_counter2 = 0;
222
+ ctx->bits_in_last_byte = 0;
223
+ }
224
+
225
+ /* update state with databitlen bits of input */
226
+ static void Update(hashState* ctx,
227
+ const BitSequence* input,
228
+ DataLength databitlen) {
229
+ int index = 0;
230
+ int msglen = (int)(databitlen/8);
231
+ int rem = (int)(databitlen%8);
232
+
233
+ /* if the buffer contains data that has not yet been digested, first
234
+ add data to buffer until full */
235
+ if (ctx->buf_ptr) {
236
+ while (ctx->buf_ptr < SIZE512 && index < msglen) {
237
+ ctx->buffer[(int)ctx->buf_ptr++] = input[index++];
238
+ }
239
+ if (ctx->buf_ptr < SIZE512) {
240
+ /* buffer still not full, return */
241
+ if (rem) {
242
+ ctx->bits_in_last_byte = rem;
243
+ ctx->buffer[(int)ctx->buf_ptr++] = input[index];
244
+ }
245
+ return;
246
+ }
247
+
248
+ /* digest buffer */
249
+ ctx->buf_ptr = 0;
250
+ Transform(ctx, ctx->buffer, SIZE512);
251
+ }
252
+
253
+ /* digest bulk of message */
254
+ Transform(ctx, input+index, msglen-index);
255
+ index += ((msglen-index)/SIZE512)*SIZE512;
256
+
257
+ /* store remaining data in buffer */
258
+ while (index < msglen) {
259
+ ctx->buffer[(int)ctx->buf_ptr++] = input[index++];
260
+ }
261
+
262
+ /* if non-integral number of bytes have been supplied, store
263
+ remaining bits in last byte, together with information about
264
+ number of bits */
265
+ if (rem) {
266
+ ctx->bits_in_last_byte = rem;
267
+ ctx->buffer[(int)ctx->buf_ptr++] = input[index];
268
+ }
269
+ }
270
+
271
+ #define BILB ctx->bits_in_last_byte
272
+
273
+ /* finalise: process remaining data (including padding), perform
274
+ output transformation, and write hash result to 'output' */
275
+ static void Final(hashState* ctx,
276
+ BitSequence* output) {
277
+ int i, j = 0, hashbytelen = HASH_BIT_LEN/8;
278
+ uint8_t *s = (BitSequence*)ctx->chaining;
279
+
280
+ /* pad with '1'-bit and first few '0'-bits */
281
+ if (BILB) {
282
+ ctx->buffer[(int)ctx->buf_ptr-1] &= ((1<<BILB)-1)<<(8-BILB);
283
+ ctx->buffer[(int)ctx->buf_ptr-1] ^= 0x1<<(7-BILB);
284
+ BILB = 0;
285
+ }
286
+ else ctx->buffer[(int)ctx->buf_ptr++] = 0x80;
287
+
288
+ /* pad with '0'-bits */
289
+ if (ctx->buf_ptr > SIZE512-LENGTHFIELDLEN) {
290
+ /* padding requires two blocks */
291
+ while (ctx->buf_ptr < SIZE512) {
292
+ ctx->buffer[(int)ctx->buf_ptr++] = 0;
293
+ }
294
+ /* digest first padding block */
295
+ Transform(ctx, ctx->buffer, SIZE512);
296
+ ctx->buf_ptr = 0;
297
+ }
298
+ while (ctx->buf_ptr < SIZE512-LENGTHFIELDLEN) {
299
+ ctx->buffer[(int)ctx->buf_ptr++] = 0;
300
+ }
301
+
302
+ /* length padding */
303
+ ctx->block_counter1++;
304
+ if (ctx->block_counter1 == 0) ctx->block_counter2++;
305
+ ctx->buf_ptr = SIZE512;
306
+
307
+ while (ctx->buf_ptr > SIZE512-(int)sizeof(uint32_t)) {
308
+ ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter1;
309
+ ctx->block_counter1 >>= 8;
310
+ }
311
+ while (ctx->buf_ptr > SIZE512-LENGTHFIELDLEN) {
312
+ ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter2;
313
+ ctx->block_counter2 >>= 8;
314
+ }
315
+ /* digest final padding block */
316
+ Transform(ctx, ctx->buffer, SIZE512);
317
+ /* perform output transformation */
318
+ OutputTransformation(ctx);
319
+
320
+ /* store hash result in output */
321
+ for (i = SIZE512-hashbytelen; i < SIZE512; i++,j++) {
322
+ output[j] = s[i];
323
+ }
324
+
325
+ /* zeroise relevant variables and deallocate memory */
326
+ for (i = 0; i < COLS512; i++) {
327
+ ctx->chaining[i] = 0;
328
+ }
329
+ for (i = 0; i < SIZE512; i++) {
330
+ ctx->buffer[i] = 0;
331
+ }
332
+ }
333
+
334
+ /* hash bit sequence */
335
+ void groestl(const BitSequence* data,
336
+ DataLength databitlen,
337
+ BitSequence* hashval) {
338
+
339
+ hashState context;
340
+
341
+ /* initialise */
342
+ Init(&context);
343
+
344
+
345
+ /* process message */
346
+ Update(&context, data, databitlen);
347
+
348
+ /* finalise */
349
+ Final(&context, hashval);
350
+ }
351
+ /*
352
+ static int crypto_hash(unsigned char *out,
353
+ const unsigned char *in,
354
+ unsigned long long len)
355
+ {
356
+ groestl(in, 8*len, out);
357
+ return 0;
358
+ }
359
+
360
+ */
@@ -0,0 +1,56 @@
1
+ #pragma once
2
+ /*
3
+ #include "crypto_uint8.h"
4
+ #include "crypto_uint32.h"
5
+ #include "crypto_uint64.h"
6
+ #include "crypto_hash.h"
7
+
8
+ typedef crypto_uint8 uint8_t;
9
+ typedef crypto_uint32 uint32_t;
10
+ typedef crypto_uint64 uint64_t;
11
+ */
12
+ #include <stdint.h>
13
+ #include "hash.h"
14
+
15
+ /* some sizes (number of bytes) */
16
+ #define ROWS 8
17
+ #define LENGTHFIELDLEN ROWS
18
+ #define COLS512 8
19
+
20
+ #define SIZE512 (ROWS*COLS512)
21
+
22
+ #define ROUNDS512 10
23
+ #define HASH_BIT_LEN 256
24
+
25
+ #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff))
26
+
27
+
28
+ #define li_32(h) 0x##h##u
29
+ #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n)))
30
+ #define u32BIG(a) \
31
+ ((ROTL32(a,8) & li_32(00FF00FF)) | \
32
+ (ROTL32(a,24) & li_32(FF00FF00)))
33
+
34
+
35
+ /* NIST API begin */
36
+ typedef struct {
37
+ uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */
38
+ uint32_t block_counter1,
39
+ block_counter2; /* message block counter(s) */
40
+ BitSequence buffer[SIZE512]; /* data buffer */
41
+ int buf_ptr; /* data buffer pointer */
42
+ int bits_in_last_byte; /* no. of message bits in last byte of
43
+ data buffer */
44
+ } hashState;
45
+
46
+ /*void Init(hashState*);
47
+ void Update(hashState*, const BitSequence*, DataLength);
48
+ void Final(hashState*, BitSequence*); */
49
+ void groestl(const BitSequence*, DataLength, BitSequence*);
50
+ /* NIST API end */
51
+
52
+ /*
53
+ int crypto_hash(unsigned char *out,
54
+ const unsigned char *in,
55
+ unsigned long long len);
56
+ */