@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.
- package/.travis.yml +5 -0
- package/LICENSE +674 -0
- package/README.md +87 -0
- package/appveyor.yml +12 -0
- package/argon2/.gitattributes +10 -0
- package/argon2/.travis.yml +25 -0
- package/argon2/Argon2.sln +160 -0
- package/argon2/CHANGELOG.md +32 -0
- package/argon2/CMakeLists.txt +87 -0
- package/argon2/LICENSE +314 -0
- package/argon2/Makefile +196 -0
- package/argon2/README.md +297 -0
- package/argon2/appveyor.yml +40 -0
- package/argon2/argon2-specs.pdf +0 -0
- package/argon2/export.sh +7 -0
- package/argon2/include/argon2.h +427 -0
- package/argon2/latex/CMakeLists.txt +34 -0
- package/argon2/latex/IEEEtran.cls +6347 -0
- package/argon2/latex/Makefile +18 -0
- package/argon2/latex/argon2-specs.tex +920 -0
- package/argon2/latex/pics/argon2-par.pdf +0 -0
- package/argon2/latex/pics/compression.pdf +0 -0
- package/argon2/latex/pics/generic.pdf +0 -0
- package/argon2/latex/pics/power-distribution.jpg +0 -0
- package/argon2/latex/tradeoff.bib +822 -0
- package/argon2/libargon2.pc +16 -0
- package/argon2/man/CMakeLists.txt +8 -0
- package/argon2/man/argon2.1 +57 -0
- package/argon2/meson.build +16 -0
- package/argon2/meson_options.txt +1 -0
- package/argon2/src/CMakeLists.txt +147 -0
- package/argon2/src/argon2.c +452 -0
- package/argon2/src/argon2.pc.in +11 -0
- package/argon2/src/blake2/blake2-impl.h +156 -0
- package/argon2/src/blake2/blake2.h +89 -0
- package/argon2/src/blake2/blake2b.c +390 -0
- package/argon2/src/blake2/blamka-round-opt.h +471 -0
- package/argon2/src/blake2/blamka-round-ref.h +56 -0
- package/argon2/src/core.c +634 -0
- package/argon2/src/core.h +228 -0
- package/argon2/src/encoding.c +467 -0
- package/argon2/src/encoding.h +57 -0
- package/argon2/src/genkat.h +51 -0
- package/argon2/src/meson.build +68 -0
- package/argon2/src/opt.c +283 -0
- package/argon2/src/optimization/CMakeLists.txt +10 -0
- package/argon2/src/ref.c +194 -0
- package/argon2/src/thread.c +57 -0
- package/argon2/src/thread.h +67 -0
- package/argon2/tests/CMakeLists.txt +43 -0
- package/argon2/tests/bench.c +111 -0
- package/argon2/tests/genkat.c +207 -0
- package/argon2/tests/kats/argon2d +12304 -0
- package/argon2/tests/kats/argon2d.shasum +1 -0
- package/argon2/tests/kats/argon2d_v16 +12304 -0
- package/argon2/tests/kats/argon2d_v16.shasum +1 -0
- package/argon2/tests/kats/argon2i +12304 -0
- package/argon2/tests/kats/argon2i.shasum +1 -0
- package/argon2/tests/kats/argon2i_v16 +12304 -0
- package/argon2/tests/kats/argon2i_v16.shasum +1 -0
- package/argon2/tests/kats/argon2id +12304 -0
- package/argon2/tests/kats/argon2id.shasum +1 -0
- package/argon2/tests/kats/argon2id_v16 +12304 -0
- package/argon2/tests/kats/argon2id_v16.shasum +1 -0
- package/argon2/tests/kats/check-sums.ps1 +48 -0
- package/argon2/tests/kats/check-sums.sh +16 -0
- package/argon2/tests/kats/test.ps1 +132 -0
- package/argon2/tests/kats/test.sh +117 -0
- package/argon2/tests/meson.build +34 -0
- package/argon2/tests/test.c +289 -0
- package/argon2/tool/CMakeLists.txt +7 -0
- package/argon2/tool/main.c +339 -0
- package/argon2/tool/meson.build +8 -0
- package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +226 -0
- package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +226 -0
- package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +225 -0
- package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters +66 -0
- package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +239 -0
- package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
- package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +227 -0
- package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +226 -0
- package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +226 -0
- package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +225 -0
- package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters +66 -0
- package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +227 -0
- package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
- package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +226 -0
- package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
- package/bcrypt.c +566 -0
- package/bcrypt.h +14 -0
- package/binding.gyp +93 -0
- package/blake.c +17 -0
- package/blake.h +16 -0
- package/boolberry.cc +11 -0
- package/boolberry.h +6 -0
- package/build/Makefile +354 -0
- package/build/Release/.deps/Release/multihashing.node.d +1 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/argon2.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/blake2/blake2b.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/core.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/encoding.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/ref.o.d +14 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/thread.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/bcrypt.o.d +4 -0
- package/build/Release/.deps/Release/obj.target/multihashing/blake.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/boolberry.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/c11.o.d +20 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/aesb.o.d +3 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_blake256.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_groestl.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_jh.o.d +9 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_keccak.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_skein.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/hash.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/oaes_lib.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/wild_keccak.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_fast.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_soft_shell.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/fresh.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/fugue.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/groestl.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/hefty1.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/keccak.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/multihashing.o.d +155 -0
- package/build/Release/.deps/Release/obj.target/multihashing/nist5.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/quark.o.d +14 -0
- package/build/Release/.deps/Release/obj.target/multihashing/qubit.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/scryptjane.o.d +30 -0
- package/build/Release/.deps/Release/obj.target/multihashing/scryptn.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha1.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/aes_helper.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/hamsi.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_blake.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_bmw.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_cubehash.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_echo.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_fugue.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_groestl.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_hefty1.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_jh.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_keccak.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_luffa.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shabal.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shavite.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_simd.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_skein.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_whirlpool.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/shavite3.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/skein.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x11.o.d +20 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x13.o.d +23 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x15.o.d +26 -0
- package/build/Release/.deps/Release/obj.target/multihashing.node.d +1 -0
- package/build/Release/multihashing.node +0 -0
- package/build/binding.Makefile +6 -0
- package/build/multihashing.target.mk +255 -0
- package/c11.c +85 -0
- package/c11.h +17 -0
- package/crypto/aesb.c +177 -0
- package/crypto/c_blake256.c +326 -0
- package/crypto/c_blake256.h +43 -0
- package/crypto/c_groestl.c +360 -0
- package/crypto/c_groestl.h +56 -0
- package/crypto/c_jh.c +367 -0
- package/crypto/c_jh.h +20 -0
- package/crypto/c_keccak.c +112 -0
- package/crypto/c_keccak.h +26 -0
- package/crypto/c_skein.c +2036 -0
- package/crypto/c_skein.h +45 -0
- package/crypto/crypto.h +186 -0
- package/crypto/cryptonote_core/account.cpp +50 -0
- package/crypto/cryptonote_core/account.h +61 -0
- package/crypto/cryptonote_core/cryptonote_basic_impl.cpp +186 -0
- package/crypto/cryptonote_core/cryptonote_basic_impl.h +65 -0
- package/crypto/cryptonote_core/cryptonote_format_utils.cpp +766 -0
- package/crypto/cryptonote_core/cryptonote_format_utils.h +30 -0
- package/crypto/cryptonote_protocol/cryptonote_protocol_defs.h +152 -0
- package/crypto/groestl_tables.h +38 -0
- package/crypto/hash-ops.h +57 -0
- package/crypto/hash.c +24 -0
- package/crypto/hash.h +22 -0
- package/crypto/int-util.h +230 -0
- package/crypto/oaes_config.h +50 -0
- package/crypto/oaes_lib.c +1468 -0
- package/crypto/oaes_lib.h +215 -0
- package/crypto/skein_port.h +190 -0
- package/crypto/variant2_int_sqrt.h +168 -0
- package/crypto/wild_keccak.cpp +119 -0
- package/crypto/wild_keccak.h +168 -0
- package/cryptonight.c +300 -0
- package/cryptonight.h +17 -0
- package/cryptonight_dark.c +300 -0
- package/cryptonight_dark.h +17 -0
- package/cryptonight_dark_lite.c +300 -0
- package/cryptonight_dark_lite.h +17 -0
- package/cryptonight_fast.c +300 -0
- package/cryptonight_fast.h +17 -0
- package/cryptonight_lite.c +300 -0
- package/cryptonight_lite.h +17 -0
- package/cryptonight_soft_shell.c +298 -0
- package/cryptonight_soft_shell.h +17 -0
- package/cryptonight_turtle.c +300 -0
- package/cryptonight_turtle.h +17 -0
- package/cryptonight_turtle_lite.c +300 -0
- package/cryptonight_turtle_lite.h +17 -0
- package/fresh.c +42 -0
- package/fresh.h +16 -0
- package/fugue.c +12 -0
- package/fugue.h +16 -0
- package/groestl.c +40 -0
- package/groestl.h +17 -0
- package/hefty1.c +63 -0
- package/hefty1.h +16 -0
- package/index.js +1 -0
- package/keccak.c +14 -0
- package/keccak.h +16 -0
- package/leocuvee-wrkzcoin-multi-hashing-0.0.20.tgz +0 -0
- package/multihashing.cc +699 -0
- package/nist5.c +46 -0
- package/nist5.h +16 -0
- package/package.json +56 -0
- package/quark.c +210 -0
- package/quark.h +16 -0
- package/qubit.c +45 -0
- package/qubit.h +16 -0
- package/scryptjane/scrypt-jane-chacha.h +132 -0
- package/scryptjane/scrypt-jane-hash.h +48 -0
- package/scryptjane/scrypt-jane-hash_keccak.h +168 -0
- package/scryptjane/scrypt-jane-hash_sha256.h +135 -0
- package/scryptjane/scrypt-jane-mix_chacha-avx.h +340 -0
- package/scryptjane/scrypt-jane-mix_chacha-sse2.h +371 -0
- package/scryptjane/scrypt-jane-mix_chacha-ssse3.h +348 -0
- package/scryptjane/scrypt-jane-mix_chacha.h +69 -0
- package/scryptjane/scrypt-jane-mix_salsa-avx.h +381 -0
- package/scryptjane/scrypt-jane-mix_salsa-sse2.h +443 -0
- package/scryptjane/scrypt-jane-mix_salsa.h +70 -0
- package/scryptjane/scrypt-jane-pbkdf2.h +112 -0
- package/scryptjane/scrypt-jane-portable-x86.h +364 -0
- package/scryptjane/scrypt-jane-portable.h +281 -0
- package/scryptjane/scrypt-jane-romix-basic.h +67 -0
- package/scryptjane/scrypt-jane-romix-template.h +118 -0
- package/scryptjane/scrypt-jane-romix.h +27 -0
- package/scryptjane/scrypt-jane-salsa.h +106 -0
- package/scryptjane/scrypt-jane-test-vectors.h +261 -0
- package/scryptjane.c +223 -0
- package/scryptjane.h +36 -0
- package/scryptn.c +258 -0
- package/scryptn.h +16 -0
- package/sha1.c +65 -0
- package/sha1.h +16 -0
- package/sha256.h +440 -0
- package/sha3/aes_helper.c +392 -0
- package/sha3/hamsi.c +867 -0
- package/sha3/hamsi_helper.c +39648 -0
- package/sha3/md_helper.c +347 -0
- package/sha3/sph_blake.c +1114 -0
- package/sha3/sph_blake.h +327 -0
- package/sha3/sph_bmw.c +965 -0
- package/sha3/sph_bmw.h +328 -0
- package/sha3/sph_cubehash.c +723 -0
- package/sha3/sph_cubehash.h +292 -0
- package/sha3/sph_echo.c +1031 -0
- package/sha3/sph_echo.h +320 -0
- package/sha3/sph_fugue.c +1208 -0
- package/sha3/sph_fugue.h +81 -0
- package/sha3/sph_groestl.c +3119 -0
- package/sha3/sph_groestl.h +329 -0
- package/sha3/sph_hamsi.h +321 -0
- package/sha3/sph_hefty1.c +378 -0
- package/sha3/sph_hefty1.h +66 -0
- package/sha3/sph_jh.c +1116 -0
- package/sha3/sph_jh.h +298 -0
- package/sha3/sph_keccak.c +1824 -0
- package/sha3/sph_keccak.h +293 -0
- package/sha3/sph_luffa.c +1426 -0
- package/sha3/sph_luffa.h +296 -0
- package/sha3/sph_shabal.c +806 -0
- package/sha3/sph_shabal.h +344 -0
- package/sha3/sph_shavite.c +1764 -0
- package/sha3/sph_shavite.h +314 -0
- package/sha3/sph_simd.c +1799 -0
- package/sha3/sph_simd.h +309 -0
- package/sha3/sph_skein.c +1254 -0
- package/sha3/sph_skein.h +298 -0
- package/sha3/sph_types.h +1976 -0
- package/sha3/sph_whirlpool.c +3480 -0
- package/sha3/sph_whirlpool.h +209 -0
- package/shavite3.c +24 -0
- package/shavite3.h +16 -0
- package/skein.c +26 -0
- package/skein.h +16 -0
- package/stdint.h +259 -0
- package/tests/argon2-tests.js +16 -0
- package/tests/benchmark.js +36 -0
- package/tests/cryptonight-tests.js +189 -0
- package/tests/cryptonight_monero.js +53 -0
- package/tests/test.js +16 -0
- package/x11.c +85 -0
- package/x11.h +16 -0
- package/x13.c +97 -0
- package/x13.h +5 -0
- package/x15.c +106 -0
- package/x15.h +16 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
/* $Id: cubehash.c 227 2010-06-16 17:28:38Z tp $ */
|
|
2
|
+
/*
|
|
3
|
+
* CubeHash implementation.
|
|
4
|
+
*
|
|
5
|
+
* ==========================(LICENSE BEGIN)============================
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
10
|
+
* a copy of this software and associated documentation files (the
|
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
14
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
15
|
+
* the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be
|
|
18
|
+
* included in all copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
21
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
24
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
25
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
26
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
*
|
|
28
|
+
* ===========================(LICENSE END)=============================
|
|
29
|
+
*
|
|
30
|
+
* @author Thomas Pornin <thomas.pornin@cryptolog.com>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
#include <stddef.h>
|
|
34
|
+
#include <string.h>
|
|
35
|
+
#include <limits.h>
|
|
36
|
+
|
|
37
|
+
#include "sph_cubehash.h"
|
|
38
|
+
#ifdef __cplusplus
|
|
39
|
+
extern "C"{
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_CUBEHASH
|
|
43
|
+
#define SPH_SMALL_FOOTPRINT_CUBEHASH 1
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* Some tests were conducted on an Intel Core2 Q6600 (32-bit and 64-bit
|
|
48
|
+
* mode), a PowerPC G3, and a MIPS-compatible CPU (Broadcom BCM3302).
|
|
49
|
+
* It appears that the optimal settings are:
|
|
50
|
+
* -- full unroll, no state copy on the "big" systems (x86, PowerPC)
|
|
51
|
+
* -- unroll to 4 or 8, state copy on the "small" system (MIPS)
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
#if SPH_SMALL_FOOTPRINT_CUBEHASH
|
|
55
|
+
|
|
56
|
+
#if !defined SPH_CUBEHASH_UNROLL
|
|
57
|
+
#define SPH_CUBEHASH_UNROLL 4
|
|
58
|
+
#endif
|
|
59
|
+
#if !defined SPH_CUBEHASH_NOCOPY
|
|
60
|
+
#define SPH_CUBEHASH_NOCOPY 1
|
|
61
|
+
#endif
|
|
62
|
+
|
|
63
|
+
#else
|
|
64
|
+
|
|
65
|
+
#if !defined SPH_CUBEHASH_UNROLL
|
|
66
|
+
#define SPH_CUBEHASH_UNROLL 0
|
|
67
|
+
#endif
|
|
68
|
+
#if !defined SPH_CUBEHASH_NOCOPY
|
|
69
|
+
#define SPH_CUBEHASH_NOCOPY 0
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
#ifdef _MSC_VER
|
|
75
|
+
#pragma warning (disable: 4146)
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
static const sph_u32 IV224[] = {
|
|
79
|
+
SPH_C32(0xB0FC8217), SPH_C32(0x1BEE1A90), SPH_C32(0x829E1A22),
|
|
80
|
+
SPH_C32(0x6362C342), SPH_C32(0x24D91C30), SPH_C32(0x03A7AA24),
|
|
81
|
+
SPH_C32(0xA63721C8), SPH_C32(0x85B0E2EF), SPH_C32(0xF35D13F3),
|
|
82
|
+
SPH_C32(0x41DA807D), SPH_C32(0x21A70CA6), SPH_C32(0x1F4E9774),
|
|
83
|
+
SPH_C32(0xB3E1C932), SPH_C32(0xEB0A79A8), SPH_C32(0xCDDAAA66),
|
|
84
|
+
SPH_C32(0xE2F6ECAA), SPH_C32(0x0A713362), SPH_C32(0xAA3080E0),
|
|
85
|
+
SPH_C32(0xD8F23A32), SPH_C32(0xCEF15E28), SPH_C32(0xDB086314),
|
|
86
|
+
SPH_C32(0x7F709DF7), SPH_C32(0xACD228A4), SPH_C32(0x704D6ECE),
|
|
87
|
+
SPH_C32(0xAA3EC95F), SPH_C32(0xE387C214), SPH_C32(0x3A6445FF),
|
|
88
|
+
SPH_C32(0x9CAB81C3), SPH_C32(0xC73D4B98), SPH_C32(0xD277AEBE),
|
|
89
|
+
SPH_C32(0xFD20151C), SPH_C32(0x00CB573E)
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
static const sph_u32 IV256[] = {
|
|
93
|
+
SPH_C32(0xEA2BD4B4), SPH_C32(0xCCD6F29F), SPH_C32(0x63117E71),
|
|
94
|
+
SPH_C32(0x35481EAE), SPH_C32(0x22512D5B), SPH_C32(0xE5D94E63),
|
|
95
|
+
SPH_C32(0x7E624131), SPH_C32(0xF4CC12BE), SPH_C32(0xC2D0B696),
|
|
96
|
+
SPH_C32(0x42AF2070), SPH_C32(0xD0720C35), SPH_C32(0x3361DA8C),
|
|
97
|
+
SPH_C32(0x28CCECA4), SPH_C32(0x8EF8AD83), SPH_C32(0x4680AC00),
|
|
98
|
+
SPH_C32(0x40E5FBAB), SPH_C32(0xD89041C3), SPH_C32(0x6107FBD5),
|
|
99
|
+
SPH_C32(0x6C859D41), SPH_C32(0xF0B26679), SPH_C32(0x09392549),
|
|
100
|
+
SPH_C32(0x5FA25603), SPH_C32(0x65C892FD), SPH_C32(0x93CB6285),
|
|
101
|
+
SPH_C32(0x2AF2B5AE), SPH_C32(0x9E4B4E60), SPH_C32(0x774ABFDD),
|
|
102
|
+
SPH_C32(0x85254725), SPH_C32(0x15815AEB), SPH_C32(0x4AB6AAD6),
|
|
103
|
+
SPH_C32(0x9CDAF8AF), SPH_C32(0xD6032C0A)
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
static const sph_u32 IV384[] = {
|
|
107
|
+
SPH_C32(0xE623087E), SPH_C32(0x04C00C87), SPH_C32(0x5EF46453),
|
|
108
|
+
SPH_C32(0x69524B13), SPH_C32(0x1A05C7A9), SPH_C32(0x3528DF88),
|
|
109
|
+
SPH_C32(0x6BDD01B5), SPH_C32(0x5057B792), SPH_C32(0x6AA7A922),
|
|
110
|
+
SPH_C32(0x649C7EEE), SPH_C32(0xF426309F), SPH_C32(0xCB629052),
|
|
111
|
+
SPH_C32(0xFC8E20ED), SPH_C32(0xB3482BAB), SPH_C32(0xF89E5E7E),
|
|
112
|
+
SPH_C32(0xD83D4DE4), SPH_C32(0x44BFC10D), SPH_C32(0x5FC1E63D),
|
|
113
|
+
SPH_C32(0x2104E6CB), SPH_C32(0x17958F7F), SPH_C32(0xDBEAEF70),
|
|
114
|
+
SPH_C32(0xB4B97E1E), SPH_C32(0x32C195F6), SPH_C32(0x6184A8E4),
|
|
115
|
+
SPH_C32(0x796C2543), SPH_C32(0x23DE176D), SPH_C32(0xD33BBAEC),
|
|
116
|
+
SPH_C32(0x0C12E5D2), SPH_C32(0x4EB95A7B), SPH_C32(0x2D18BA01),
|
|
117
|
+
SPH_C32(0x04EE475F), SPH_C32(0x1FC5F22E)
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
static const sph_u32 IV512[] = {
|
|
121
|
+
SPH_C32(0x2AEA2A61), SPH_C32(0x50F494D4), SPH_C32(0x2D538B8B),
|
|
122
|
+
SPH_C32(0x4167D83E), SPH_C32(0x3FEE2313), SPH_C32(0xC701CF8C),
|
|
123
|
+
SPH_C32(0xCC39968E), SPH_C32(0x50AC5695), SPH_C32(0x4D42C787),
|
|
124
|
+
SPH_C32(0xA647A8B3), SPH_C32(0x97CF0BEF), SPH_C32(0x825B4537),
|
|
125
|
+
SPH_C32(0xEEF864D2), SPH_C32(0xF22090C4), SPH_C32(0xD0E5CD33),
|
|
126
|
+
SPH_C32(0xA23911AE), SPH_C32(0xFCD398D9), SPH_C32(0x148FE485),
|
|
127
|
+
SPH_C32(0x1B017BEF), SPH_C32(0xB6444532), SPH_C32(0x6A536159),
|
|
128
|
+
SPH_C32(0x2FF5781C), SPH_C32(0x91FA7934), SPH_C32(0x0DBADEA9),
|
|
129
|
+
SPH_C32(0xD65C8A2B), SPH_C32(0xA5A70E75), SPH_C32(0xB1C62456),
|
|
130
|
+
SPH_C32(0xBC796576), SPH_C32(0x1921C8F7), SPH_C32(0xE7989AF1),
|
|
131
|
+
SPH_C32(0x7795D246), SPH_C32(0xD43E3B44)
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
#define T32 SPH_T32
|
|
135
|
+
#define ROTL32 SPH_ROTL32
|
|
136
|
+
|
|
137
|
+
#if SPH_CUBEHASH_NOCOPY
|
|
138
|
+
|
|
139
|
+
#define DECL_STATE
|
|
140
|
+
#define READ_STATE(cc)
|
|
141
|
+
#define WRITE_STATE(cc)
|
|
142
|
+
|
|
143
|
+
#define x0 ((sc)->state[ 0])
|
|
144
|
+
#define x1 ((sc)->state[ 1])
|
|
145
|
+
#define x2 ((sc)->state[ 2])
|
|
146
|
+
#define x3 ((sc)->state[ 3])
|
|
147
|
+
#define x4 ((sc)->state[ 4])
|
|
148
|
+
#define x5 ((sc)->state[ 5])
|
|
149
|
+
#define x6 ((sc)->state[ 6])
|
|
150
|
+
#define x7 ((sc)->state[ 7])
|
|
151
|
+
#define x8 ((sc)->state[ 8])
|
|
152
|
+
#define x9 ((sc)->state[ 9])
|
|
153
|
+
#define xa ((sc)->state[10])
|
|
154
|
+
#define xb ((sc)->state[11])
|
|
155
|
+
#define xc ((sc)->state[12])
|
|
156
|
+
#define xd ((sc)->state[13])
|
|
157
|
+
#define xe ((sc)->state[14])
|
|
158
|
+
#define xf ((sc)->state[15])
|
|
159
|
+
#define xg ((sc)->state[16])
|
|
160
|
+
#define xh ((sc)->state[17])
|
|
161
|
+
#define xi ((sc)->state[18])
|
|
162
|
+
#define xj ((sc)->state[19])
|
|
163
|
+
#define xk ((sc)->state[20])
|
|
164
|
+
#define xl ((sc)->state[21])
|
|
165
|
+
#define xm ((sc)->state[22])
|
|
166
|
+
#define xn ((sc)->state[23])
|
|
167
|
+
#define xo ((sc)->state[24])
|
|
168
|
+
#define xp ((sc)->state[25])
|
|
169
|
+
#define xq ((sc)->state[26])
|
|
170
|
+
#define xr ((sc)->state[27])
|
|
171
|
+
#define xs ((sc)->state[28])
|
|
172
|
+
#define xt ((sc)->state[29])
|
|
173
|
+
#define xu ((sc)->state[30])
|
|
174
|
+
#define xv ((sc)->state[31])
|
|
175
|
+
|
|
176
|
+
#else
|
|
177
|
+
|
|
178
|
+
#define DECL_STATE \
|
|
179
|
+
sph_u32 x0, x1, x2, x3, x4, x5, x6, x7; \
|
|
180
|
+
sph_u32 x8, x9, xa, xb, xc, xd, xe, xf; \
|
|
181
|
+
sph_u32 xg, xh, xi, xj, xk, xl, xm, xn; \
|
|
182
|
+
sph_u32 xo, xp, xq, xr, xs, xt, xu, xv;
|
|
183
|
+
|
|
184
|
+
#define READ_STATE(cc) do { \
|
|
185
|
+
x0 = (cc)->state[ 0]; \
|
|
186
|
+
x1 = (cc)->state[ 1]; \
|
|
187
|
+
x2 = (cc)->state[ 2]; \
|
|
188
|
+
x3 = (cc)->state[ 3]; \
|
|
189
|
+
x4 = (cc)->state[ 4]; \
|
|
190
|
+
x5 = (cc)->state[ 5]; \
|
|
191
|
+
x6 = (cc)->state[ 6]; \
|
|
192
|
+
x7 = (cc)->state[ 7]; \
|
|
193
|
+
x8 = (cc)->state[ 8]; \
|
|
194
|
+
x9 = (cc)->state[ 9]; \
|
|
195
|
+
xa = (cc)->state[10]; \
|
|
196
|
+
xb = (cc)->state[11]; \
|
|
197
|
+
xc = (cc)->state[12]; \
|
|
198
|
+
xd = (cc)->state[13]; \
|
|
199
|
+
xe = (cc)->state[14]; \
|
|
200
|
+
xf = (cc)->state[15]; \
|
|
201
|
+
xg = (cc)->state[16]; \
|
|
202
|
+
xh = (cc)->state[17]; \
|
|
203
|
+
xi = (cc)->state[18]; \
|
|
204
|
+
xj = (cc)->state[19]; \
|
|
205
|
+
xk = (cc)->state[20]; \
|
|
206
|
+
xl = (cc)->state[21]; \
|
|
207
|
+
xm = (cc)->state[22]; \
|
|
208
|
+
xn = (cc)->state[23]; \
|
|
209
|
+
xo = (cc)->state[24]; \
|
|
210
|
+
xp = (cc)->state[25]; \
|
|
211
|
+
xq = (cc)->state[26]; \
|
|
212
|
+
xr = (cc)->state[27]; \
|
|
213
|
+
xs = (cc)->state[28]; \
|
|
214
|
+
xt = (cc)->state[29]; \
|
|
215
|
+
xu = (cc)->state[30]; \
|
|
216
|
+
xv = (cc)->state[31]; \
|
|
217
|
+
} while (0)
|
|
218
|
+
|
|
219
|
+
#define WRITE_STATE(cc) do { \
|
|
220
|
+
(cc)->state[ 0] = x0; \
|
|
221
|
+
(cc)->state[ 1] = x1; \
|
|
222
|
+
(cc)->state[ 2] = x2; \
|
|
223
|
+
(cc)->state[ 3] = x3; \
|
|
224
|
+
(cc)->state[ 4] = x4; \
|
|
225
|
+
(cc)->state[ 5] = x5; \
|
|
226
|
+
(cc)->state[ 6] = x6; \
|
|
227
|
+
(cc)->state[ 7] = x7; \
|
|
228
|
+
(cc)->state[ 8] = x8; \
|
|
229
|
+
(cc)->state[ 9] = x9; \
|
|
230
|
+
(cc)->state[10] = xa; \
|
|
231
|
+
(cc)->state[11] = xb; \
|
|
232
|
+
(cc)->state[12] = xc; \
|
|
233
|
+
(cc)->state[13] = xd; \
|
|
234
|
+
(cc)->state[14] = xe; \
|
|
235
|
+
(cc)->state[15] = xf; \
|
|
236
|
+
(cc)->state[16] = xg; \
|
|
237
|
+
(cc)->state[17] = xh; \
|
|
238
|
+
(cc)->state[18] = xi; \
|
|
239
|
+
(cc)->state[19] = xj; \
|
|
240
|
+
(cc)->state[20] = xk; \
|
|
241
|
+
(cc)->state[21] = xl; \
|
|
242
|
+
(cc)->state[22] = xm; \
|
|
243
|
+
(cc)->state[23] = xn; \
|
|
244
|
+
(cc)->state[24] = xo; \
|
|
245
|
+
(cc)->state[25] = xp; \
|
|
246
|
+
(cc)->state[26] = xq; \
|
|
247
|
+
(cc)->state[27] = xr; \
|
|
248
|
+
(cc)->state[28] = xs; \
|
|
249
|
+
(cc)->state[29] = xt; \
|
|
250
|
+
(cc)->state[30] = xu; \
|
|
251
|
+
(cc)->state[31] = xv; \
|
|
252
|
+
} while (0)
|
|
253
|
+
|
|
254
|
+
#endif
|
|
255
|
+
|
|
256
|
+
#define INPUT_BLOCK do { \
|
|
257
|
+
x0 ^= sph_dec32le_aligned(buf + 0); \
|
|
258
|
+
x1 ^= sph_dec32le_aligned(buf + 4); \
|
|
259
|
+
x2 ^= sph_dec32le_aligned(buf + 8); \
|
|
260
|
+
x3 ^= sph_dec32le_aligned(buf + 12); \
|
|
261
|
+
x4 ^= sph_dec32le_aligned(buf + 16); \
|
|
262
|
+
x5 ^= sph_dec32le_aligned(buf + 20); \
|
|
263
|
+
x6 ^= sph_dec32le_aligned(buf + 24); \
|
|
264
|
+
x7 ^= sph_dec32le_aligned(buf + 28); \
|
|
265
|
+
} while (0)
|
|
266
|
+
|
|
267
|
+
#define ROUND_EVEN do { \
|
|
268
|
+
xg = T32(x0 + xg); \
|
|
269
|
+
x0 = ROTL32(x0, 7); \
|
|
270
|
+
xh = T32(x1 + xh); \
|
|
271
|
+
x1 = ROTL32(x1, 7); \
|
|
272
|
+
xi = T32(x2 + xi); \
|
|
273
|
+
x2 = ROTL32(x2, 7); \
|
|
274
|
+
xj = T32(x3 + xj); \
|
|
275
|
+
x3 = ROTL32(x3, 7); \
|
|
276
|
+
xk = T32(x4 + xk); \
|
|
277
|
+
x4 = ROTL32(x4, 7); \
|
|
278
|
+
xl = T32(x5 + xl); \
|
|
279
|
+
x5 = ROTL32(x5, 7); \
|
|
280
|
+
xm = T32(x6 + xm); \
|
|
281
|
+
x6 = ROTL32(x6, 7); \
|
|
282
|
+
xn = T32(x7 + xn); \
|
|
283
|
+
x7 = ROTL32(x7, 7); \
|
|
284
|
+
xo = T32(x8 + xo); \
|
|
285
|
+
x8 = ROTL32(x8, 7); \
|
|
286
|
+
xp = T32(x9 + xp); \
|
|
287
|
+
x9 = ROTL32(x9, 7); \
|
|
288
|
+
xq = T32(xa + xq); \
|
|
289
|
+
xa = ROTL32(xa, 7); \
|
|
290
|
+
xr = T32(xb + xr); \
|
|
291
|
+
xb = ROTL32(xb, 7); \
|
|
292
|
+
xs = T32(xc + xs); \
|
|
293
|
+
xc = ROTL32(xc, 7); \
|
|
294
|
+
xt = T32(xd + xt); \
|
|
295
|
+
xd = ROTL32(xd, 7); \
|
|
296
|
+
xu = T32(xe + xu); \
|
|
297
|
+
xe = ROTL32(xe, 7); \
|
|
298
|
+
xv = T32(xf + xv); \
|
|
299
|
+
xf = ROTL32(xf, 7); \
|
|
300
|
+
x8 ^= xg; \
|
|
301
|
+
x9 ^= xh; \
|
|
302
|
+
xa ^= xi; \
|
|
303
|
+
xb ^= xj; \
|
|
304
|
+
xc ^= xk; \
|
|
305
|
+
xd ^= xl; \
|
|
306
|
+
xe ^= xm; \
|
|
307
|
+
xf ^= xn; \
|
|
308
|
+
x0 ^= xo; \
|
|
309
|
+
x1 ^= xp; \
|
|
310
|
+
x2 ^= xq; \
|
|
311
|
+
x3 ^= xr; \
|
|
312
|
+
x4 ^= xs; \
|
|
313
|
+
x5 ^= xt; \
|
|
314
|
+
x6 ^= xu; \
|
|
315
|
+
x7 ^= xv; \
|
|
316
|
+
xi = T32(x8 + xi); \
|
|
317
|
+
x8 = ROTL32(x8, 11); \
|
|
318
|
+
xj = T32(x9 + xj); \
|
|
319
|
+
x9 = ROTL32(x9, 11); \
|
|
320
|
+
xg = T32(xa + xg); \
|
|
321
|
+
xa = ROTL32(xa, 11); \
|
|
322
|
+
xh = T32(xb + xh); \
|
|
323
|
+
xb = ROTL32(xb, 11); \
|
|
324
|
+
xm = T32(xc + xm); \
|
|
325
|
+
xc = ROTL32(xc, 11); \
|
|
326
|
+
xn = T32(xd + xn); \
|
|
327
|
+
xd = ROTL32(xd, 11); \
|
|
328
|
+
xk = T32(xe + xk); \
|
|
329
|
+
xe = ROTL32(xe, 11); \
|
|
330
|
+
xl = T32(xf + xl); \
|
|
331
|
+
xf = ROTL32(xf, 11); \
|
|
332
|
+
xq = T32(x0 + xq); \
|
|
333
|
+
x0 = ROTL32(x0, 11); \
|
|
334
|
+
xr = T32(x1 + xr); \
|
|
335
|
+
x1 = ROTL32(x1, 11); \
|
|
336
|
+
xo = T32(x2 + xo); \
|
|
337
|
+
x2 = ROTL32(x2, 11); \
|
|
338
|
+
xp = T32(x3 + xp); \
|
|
339
|
+
x3 = ROTL32(x3, 11); \
|
|
340
|
+
xu = T32(x4 + xu); \
|
|
341
|
+
x4 = ROTL32(x4, 11); \
|
|
342
|
+
xv = T32(x5 + xv); \
|
|
343
|
+
x5 = ROTL32(x5, 11); \
|
|
344
|
+
xs = T32(x6 + xs); \
|
|
345
|
+
x6 = ROTL32(x6, 11); \
|
|
346
|
+
xt = T32(x7 + xt); \
|
|
347
|
+
x7 = ROTL32(x7, 11); \
|
|
348
|
+
xc ^= xi; \
|
|
349
|
+
xd ^= xj; \
|
|
350
|
+
xe ^= xg; \
|
|
351
|
+
xf ^= xh; \
|
|
352
|
+
x8 ^= xm; \
|
|
353
|
+
x9 ^= xn; \
|
|
354
|
+
xa ^= xk; \
|
|
355
|
+
xb ^= xl; \
|
|
356
|
+
x4 ^= xq; \
|
|
357
|
+
x5 ^= xr; \
|
|
358
|
+
x6 ^= xo; \
|
|
359
|
+
x7 ^= xp; \
|
|
360
|
+
x0 ^= xu; \
|
|
361
|
+
x1 ^= xv; \
|
|
362
|
+
x2 ^= xs; \
|
|
363
|
+
x3 ^= xt; \
|
|
364
|
+
} while (0)
|
|
365
|
+
|
|
366
|
+
#define ROUND_ODD do { \
|
|
367
|
+
xj = T32(xc + xj); \
|
|
368
|
+
xc = ROTL32(xc, 7); \
|
|
369
|
+
xi = T32(xd + xi); \
|
|
370
|
+
xd = ROTL32(xd, 7); \
|
|
371
|
+
xh = T32(xe + xh); \
|
|
372
|
+
xe = ROTL32(xe, 7); \
|
|
373
|
+
xg = T32(xf + xg); \
|
|
374
|
+
xf = ROTL32(xf, 7); \
|
|
375
|
+
xn = T32(x8 + xn); \
|
|
376
|
+
x8 = ROTL32(x8, 7); \
|
|
377
|
+
xm = T32(x9 + xm); \
|
|
378
|
+
x9 = ROTL32(x9, 7); \
|
|
379
|
+
xl = T32(xa + xl); \
|
|
380
|
+
xa = ROTL32(xa, 7); \
|
|
381
|
+
xk = T32(xb + xk); \
|
|
382
|
+
xb = ROTL32(xb, 7); \
|
|
383
|
+
xr = T32(x4 + xr); \
|
|
384
|
+
x4 = ROTL32(x4, 7); \
|
|
385
|
+
xq = T32(x5 + xq); \
|
|
386
|
+
x5 = ROTL32(x5, 7); \
|
|
387
|
+
xp = T32(x6 + xp); \
|
|
388
|
+
x6 = ROTL32(x6, 7); \
|
|
389
|
+
xo = T32(x7 + xo); \
|
|
390
|
+
x7 = ROTL32(x7, 7); \
|
|
391
|
+
xv = T32(x0 + xv); \
|
|
392
|
+
x0 = ROTL32(x0, 7); \
|
|
393
|
+
xu = T32(x1 + xu); \
|
|
394
|
+
x1 = ROTL32(x1, 7); \
|
|
395
|
+
xt = T32(x2 + xt); \
|
|
396
|
+
x2 = ROTL32(x2, 7); \
|
|
397
|
+
xs = T32(x3 + xs); \
|
|
398
|
+
x3 = ROTL32(x3, 7); \
|
|
399
|
+
x4 ^= xj; \
|
|
400
|
+
x5 ^= xi; \
|
|
401
|
+
x6 ^= xh; \
|
|
402
|
+
x7 ^= xg; \
|
|
403
|
+
x0 ^= xn; \
|
|
404
|
+
x1 ^= xm; \
|
|
405
|
+
x2 ^= xl; \
|
|
406
|
+
x3 ^= xk; \
|
|
407
|
+
xc ^= xr; \
|
|
408
|
+
xd ^= xq; \
|
|
409
|
+
xe ^= xp; \
|
|
410
|
+
xf ^= xo; \
|
|
411
|
+
x8 ^= xv; \
|
|
412
|
+
x9 ^= xu; \
|
|
413
|
+
xa ^= xt; \
|
|
414
|
+
xb ^= xs; \
|
|
415
|
+
xh = T32(x4 + xh); \
|
|
416
|
+
x4 = ROTL32(x4, 11); \
|
|
417
|
+
xg = T32(x5 + xg); \
|
|
418
|
+
x5 = ROTL32(x5, 11); \
|
|
419
|
+
xj = T32(x6 + xj); \
|
|
420
|
+
x6 = ROTL32(x6, 11); \
|
|
421
|
+
xi = T32(x7 + xi); \
|
|
422
|
+
x7 = ROTL32(x7, 11); \
|
|
423
|
+
xl = T32(x0 + xl); \
|
|
424
|
+
x0 = ROTL32(x0, 11); \
|
|
425
|
+
xk = T32(x1 + xk); \
|
|
426
|
+
x1 = ROTL32(x1, 11); \
|
|
427
|
+
xn = T32(x2 + xn); \
|
|
428
|
+
x2 = ROTL32(x2, 11); \
|
|
429
|
+
xm = T32(x3 + xm); \
|
|
430
|
+
x3 = ROTL32(x3, 11); \
|
|
431
|
+
xp = T32(xc + xp); \
|
|
432
|
+
xc = ROTL32(xc, 11); \
|
|
433
|
+
xo = T32(xd + xo); \
|
|
434
|
+
xd = ROTL32(xd, 11); \
|
|
435
|
+
xr = T32(xe + xr); \
|
|
436
|
+
xe = ROTL32(xe, 11); \
|
|
437
|
+
xq = T32(xf + xq); \
|
|
438
|
+
xf = ROTL32(xf, 11); \
|
|
439
|
+
xt = T32(x8 + xt); \
|
|
440
|
+
x8 = ROTL32(x8, 11); \
|
|
441
|
+
xs = T32(x9 + xs); \
|
|
442
|
+
x9 = ROTL32(x9, 11); \
|
|
443
|
+
xv = T32(xa + xv); \
|
|
444
|
+
xa = ROTL32(xa, 11); \
|
|
445
|
+
xu = T32(xb + xu); \
|
|
446
|
+
xb = ROTL32(xb, 11); \
|
|
447
|
+
x0 ^= xh; \
|
|
448
|
+
x1 ^= xg; \
|
|
449
|
+
x2 ^= xj; \
|
|
450
|
+
x3 ^= xi; \
|
|
451
|
+
x4 ^= xl; \
|
|
452
|
+
x5 ^= xk; \
|
|
453
|
+
x6 ^= xn; \
|
|
454
|
+
x7 ^= xm; \
|
|
455
|
+
x8 ^= xp; \
|
|
456
|
+
x9 ^= xo; \
|
|
457
|
+
xa ^= xr; \
|
|
458
|
+
xb ^= xq; \
|
|
459
|
+
xc ^= xt; \
|
|
460
|
+
xd ^= xs; \
|
|
461
|
+
xe ^= xv; \
|
|
462
|
+
xf ^= xu; \
|
|
463
|
+
} while (0)
|
|
464
|
+
|
|
465
|
+
/*
|
|
466
|
+
* There is no need to unroll all 16 rounds. The word-swapping permutation
|
|
467
|
+
* is an involution, so we need to unroll an even number of rounds. On
|
|
468
|
+
* "big" systems, unrolling 4 rounds yields about 97% of the speed
|
|
469
|
+
* achieved with full unrolling; and it keeps the code more compact
|
|
470
|
+
* for small architectures.
|
|
471
|
+
*/
|
|
472
|
+
|
|
473
|
+
#if SPH_CUBEHASH_UNROLL == 2
|
|
474
|
+
|
|
475
|
+
#define SIXTEEN_ROUNDS do { \
|
|
476
|
+
int j; \
|
|
477
|
+
for (j = 0; j < 8; j ++) { \
|
|
478
|
+
ROUND_EVEN; \
|
|
479
|
+
ROUND_ODD; \
|
|
480
|
+
} \
|
|
481
|
+
} while (0)
|
|
482
|
+
|
|
483
|
+
#elif SPH_CUBEHASH_UNROLL == 4
|
|
484
|
+
|
|
485
|
+
#define SIXTEEN_ROUNDS do { \
|
|
486
|
+
int j; \
|
|
487
|
+
for (j = 0; j < 4; j ++) { \
|
|
488
|
+
ROUND_EVEN; \
|
|
489
|
+
ROUND_ODD; \
|
|
490
|
+
ROUND_EVEN; \
|
|
491
|
+
ROUND_ODD; \
|
|
492
|
+
} \
|
|
493
|
+
} while (0)
|
|
494
|
+
|
|
495
|
+
#elif SPH_CUBEHASH_UNROLL == 8
|
|
496
|
+
|
|
497
|
+
#define SIXTEEN_ROUNDS do { \
|
|
498
|
+
int j; \
|
|
499
|
+
for (j = 0; j < 2; j ++) { \
|
|
500
|
+
ROUND_EVEN; \
|
|
501
|
+
ROUND_ODD; \
|
|
502
|
+
ROUND_EVEN; \
|
|
503
|
+
ROUND_ODD; \
|
|
504
|
+
ROUND_EVEN; \
|
|
505
|
+
ROUND_ODD; \
|
|
506
|
+
ROUND_EVEN; \
|
|
507
|
+
ROUND_ODD; \
|
|
508
|
+
} \
|
|
509
|
+
} while (0)
|
|
510
|
+
|
|
511
|
+
#else
|
|
512
|
+
|
|
513
|
+
#define SIXTEEN_ROUNDS do { \
|
|
514
|
+
ROUND_EVEN; \
|
|
515
|
+
ROUND_ODD; \
|
|
516
|
+
ROUND_EVEN; \
|
|
517
|
+
ROUND_ODD; \
|
|
518
|
+
ROUND_EVEN; \
|
|
519
|
+
ROUND_ODD; \
|
|
520
|
+
ROUND_EVEN; \
|
|
521
|
+
ROUND_ODD; \
|
|
522
|
+
ROUND_EVEN; \
|
|
523
|
+
ROUND_ODD; \
|
|
524
|
+
ROUND_EVEN; \
|
|
525
|
+
ROUND_ODD; \
|
|
526
|
+
ROUND_EVEN; \
|
|
527
|
+
ROUND_ODD; \
|
|
528
|
+
ROUND_EVEN; \
|
|
529
|
+
ROUND_ODD; \
|
|
530
|
+
} while (0)
|
|
531
|
+
|
|
532
|
+
#endif
|
|
533
|
+
|
|
534
|
+
static void
|
|
535
|
+
cubehash_init(sph_cubehash_context *sc, const sph_u32 *iv)
|
|
536
|
+
{
|
|
537
|
+
memcpy(sc->state, iv, sizeof sc->state);
|
|
538
|
+
sc->ptr = 0;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
static void
|
|
542
|
+
cubehash_core(sph_cubehash_context *sc, const void *data, size_t len)
|
|
543
|
+
{
|
|
544
|
+
unsigned char *buf;
|
|
545
|
+
size_t ptr;
|
|
546
|
+
DECL_STATE
|
|
547
|
+
|
|
548
|
+
buf = sc->buf;
|
|
549
|
+
ptr = sc->ptr;
|
|
550
|
+
if (len < (sizeof sc->buf) - ptr) {
|
|
551
|
+
memcpy(buf + ptr, data, len);
|
|
552
|
+
ptr += len;
|
|
553
|
+
sc->ptr = ptr;
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
READ_STATE(sc);
|
|
558
|
+
while (len > 0) {
|
|
559
|
+
size_t clen;
|
|
560
|
+
|
|
561
|
+
clen = (sizeof sc->buf) - ptr;
|
|
562
|
+
if (clen > len)
|
|
563
|
+
clen = len;
|
|
564
|
+
memcpy(buf + ptr, data, clen);
|
|
565
|
+
ptr += clen;
|
|
566
|
+
data = (const unsigned char *)data + clen;
|
|
567
|
+
len -= clen;
|
|
568
|
+
if (ptr == sizeof sc->buf) {
|
|
569
|
+
INPUT_BLOCK;
|
|
570
|
+
SIXTEEN_ROUNDS;
|
|
571
|
+
ptr = 0;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
WRITE_STATE(sc);
|
|
575
|
+
sc->ptr = ptr;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
static void
|
|
579
|
+
cubehash_close(sph_cubehash_context *sc, unsigned ub, unsigned n,
|
|
580
|
+
void *dst, size_t out_size_w32)
|
|
581
|
+
{
|
|
582
|
+
unsigned char *buf, *out;
|
|
583
|
+
size_t ptr;
|
|
584
|
+
unsigned z;
|
|
585
|
+
int i;
|
|
586
|
+
DECL_STATE
|
|
587
|
+
|
|
588
|
+
buf = sc->buf;
|
|
589
|
+
ptr = sc->ptr;
|
|
590
|
+
z = 0x80 >> n;
|
|
591
|
+
buf[ptr ++] = ((ub & -z) | z) & 0xFF;
|
|
592
|
+
memset(buf + ptr, 0, (sizeof sc->buf) - ptr);
|
|
593
|
+
READ_STATE(sc);
|
|
594
|
+
INPUT_BLOCK;
|
|
595
|
+
for (i = 0; i < 11; i ++) {
|
|
596
|
+
SIXTEEN_ROUNDS;
|
|
597
|
+
if (i == 0)
|
|
598
|
+
xv ^= SPH_C32(1);
|
|
599
|
+
}
|
|
600
|
+
WRITE_STATE(sc);
|
|
601
|
+
out = dst;
|
|
602
|
+
for (z = 0; z < out_size_w32; z ++)
|
|
603
|
+
sph_enc32le(out + (z << 2), sc->state[z]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/* see sph_cubehash.h */
|
|
607
|
+
void
|
|
608
|
+
sph_cubehash224_init(void *cc)
|
|
609
|
+
{
|
|
610
|
+
cubehash_init(cc, IV224);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/* see sph_cubehash.h */
|
|
614
|
+
void
|
|
615
|
+
sph_cubehash224(void *cc, const void *data, size_t len)
|
|
616
|
+
{
|
|
617
|
+
cubehash_core(cc, data, len);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* see sph_cubehash.h */
|
|
621
|
+
void
|
|
622
|
+
sph_cubehash224_close(void *cc, void *dst)
|
|
623
|
+
{
|
|
624
|
+
sph_cubehash224_addbits_and_close(cc, 0, 0, dst);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/* see sph_cubehash.h */
|
|
628
|
+
void
|
|
629
|
+
sph_cubehash224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
|
|
630
|
+
{
|
|
631
|
+
cubehash_close(cc, ub, n, dst, 7);
|
|
632
|
+
sph_cubehash224_init(cc);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/* see sph_cubehash.h */
|
|
636
|
+
void
|
|
637
|
+
sph_cubehash256_init(void *cc)
|
|
638
|
+
{
|
|
639
|
+
cubehash_init(cc, IV256);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/* see sph_cubehash.h */
|
|
643
|
+
void
|
|
644
|
+
sph_cubehash256(void *cc, const void *data, size_t len)
|
|
645
|
+
{
|
|
646
|
+
cubehash_core(cc, data, len);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/* see sph_cubehash.h */
|
|
650
|
+
void
|
|
651
|
+
sph_cubehash256_close(void *cc, void *dst)
|
|
652
|
+
{
|
|
653
|
+
sph_cubehash256_addbits_and_close(cc, 0, 0, dst);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/* see sph_cubehash.h */
|
|
657
|
+
void
|
|
658
|
+
sph_cubehash256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
|
|
659
|
+
{
|
|
660
|
+
cubehash_close(cc, ub, n, dst, 8);
|
|
661
|
+
sph_cubehash256_init(cc);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/* see sph_cubehash.h */
|
|
665
|
+
void
|
|
666
|
+
sph_cubehash384_init(void *cc)
|
|
667
|
+
{
|
|
668
|
+
cubehash_init(cc, IV384);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/* see sph_cubehash.h */
|
|
672
|
+
void
|
|
673
|
+
sph_cubehash384(void *cc, const void *data, size_t len)
|
|
674
|
+
{
|
|
675
|
+
cubehash_core(cc, data, len);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/* see sph_cubehash.h */
|
|
679
|
+
void
|
|
680
|
+
sph_cubehash384_close(void *cc, void *dst)
|
|
681
|
+
{
|
|
682
|
+
sph_cubehash384_addbits_and_close(cc, 0, 0, dst);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/* see sph_cubehash.h */
|
|
686
|
+
void
|
|
687
|
+
sph_cubehash384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
|
|
688
|
+
{
|
|
689
|
+
cubehash_close(cc, ub, n, dst, 12);
|
|
690
|
+
sph_cubehash384_init(cc);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/* see sph_cubehash.h */
|
|
694
|
+
void
|
|
695
|
+
sph_cubehash512_init(void *cc)
|
|
696
|
+
{
|
|
697
|
+
cubehash_init(cc, IV512);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/* see sph_cubehash.h */
|
|
701
|
+
void
|
|
702
|
+
sph_cubehash512(void *cc, const void *data, size_t len)
|
|
703
|
+
{
|
|
704
|
+
cubehash_core(cc, data, len);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/* see sph_cubehash.h */
|
|
708
|
+
void
|
|
709
|
+
sph_cubehash512_close(void *cc, void *dst)
|
|
710
|
+
{
|
|
711
|
+
sph_cubehash512_addbits_and_close(cc, 0, 0, dst);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/* see sph_cubehash.h */
|
|
715
|
+
void
|
|
716
|
+
sph_cubehash512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
|
|
717
|
+
{
|
|
718
|
+
cubehash_close(cc, ub, n, dst, 16);
|
|
719
|
+
sph_cubehash512_init(cc);
|
|
720
|
+
}
|
|
721
|
+
#ifdef __cplusplus
|
|
722
|
+
}
|
|
723
|
+
#endif
|