@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,443 @@
|
|
|
1
|
+
/* x86 */
|
|
2
|
+
#if defined(X86ASM_SSE2) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
|
|
3
|
+
|
|
4
|
+
#define SCRYPT_SALSA_SSE2
|
|
5
|
+
|
|
6
|
+
asm_naked_fn_proto(void, scrypt_ChunkMix_sse2)(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r)
|
|
7
|
+
asm_naked_fn(scrypt_ChunkMix_sse2)
|
|
8
|
+
a1(push ebx)
|
|
9
|
+
a1(push edi)
|
|
10
|
+
a1(push esi)
|
|
11
|
+
a1(push ebp)
|
|
12
|
+
a2(mov ebp,esp)
|
|
13
|
+
a2(mov edi,[ebp+20])
|
|
14
|
+
a2(mov esi,[ebp+24])
|
|
15
|
+
a2(mov eax,[ebp+28])
|
|
16
|
+
a2(mov ebx,[ebp+32])
|
|
17
|
+
a2(sub esp,32)
|
|
18
|
+
a2(and esp,~63)
|
|
19
|
+
a2(lea edx,[ebx*2])
|
|
20
|
+
a2(shl edx,6)
|
|
21
|
+
a2(lea ecx,[edx-64])
|
|
22
|
+
a2(and eax, eax)
|
|
23
|
+
a2(movdqa xmm0,[ecx+esi+0])
|
|
24
|
+
a2(movdqa xmm1,[ecx+esi+16])
|
|
25
|
+
a2(movdqa xmm2,[ecx+esi+32])
|
|
26
|
+
a2(movdqa xmm3,[ecx+esi+48])
|
|
27
|
+
a1(jz scrypt_ChunkMix_sse2_no_xor1)
|
|
28
|
+
a2(pxor xmm0,[ecx+eax+0])
|
|
29
|
+
a2(pxor xmm1,[ecx+eax+16])
|
|
30
|
+
a2(pxor xmm2,[ecx+eax+32])
|
|
31
|
+
a2(pxor xmm3,[ecx+eax+48])
|
|
32
|
+
a1(scrypt_ChunkMix_sse2_no_xor1:)
|
|
33
|
+
a2(xor ecx,ecx)
|
|
34
|
+
a2(xor ebx,ebx)
|
|
35
|
+
a1(scrypt_ChunkMix_sse2_loop:)
|
|
36
|
+
a2(and eax, eax)
|
|
37
|
+
a2(pxor xmm0,[esi+ecx+0])
|
|
38
|
+
a2(pxor xmm1,[esi+ecx+16])
|
|
39
|
+
a2(pxor xmm2,[esi+ecx+32])
|
|
40
|
+
a2(pxor xmm3,[esi+ecx+48])
|
|
41
|
+
a1(jz scrypt_ChunkMix_sse2_no_xor2)
|
|
42
|
+
a2(pxor xmm0,[eax+ecx+0])
|
|
43
|
+
a2(pxor xmm1,[eax+ecx+16])
|
|
44
|
+
a2(pxor xmm2,[eax+ecx+32])
|
|
45
|
+
a2(pxor xmm3,[eax+ecx+48])
|
|
46
|
+
a1(scrypt_ChunkMix_sse2_no_xor2:)
|
|
47
|
+
a2(movdqa [esp+0],xmm0)
|
|
48
|
+
a2(movdqa [esp+16],xmm1)
|
|
49
|
+
a2(movdqa xmm6,xmm2)
|
|
50
|
+
a2(movdqa xmm7,xmm3)
|
|
51
|
+
a2(mov eax,8)
|
|
52
|
+
a1(scrypt_salsa_sse2_loop: )
|
|
53
|
+
a2(movdqa xmm4, xmm1)
|
|
54
|
+
a2(paddd xmm4, xmm0)
|
|
55
|
+
a2(movdqa xmm5, xmm4)
|
|
56
|
+
a2(pslld xmm4, 7)
|
|
57
|
+
a2(psrld xmm5, 25)
|
|
58
|
+
a2(pxor xmm3, xmm4)
|
|
59
|
+
a2(movdqa xmm4, xmm0)
|
|
60
|
+
a2(pxor xmm3, xmm5)
|
|
61
|
+
a2(paddd xmm4, xmm3)
|
|
62
|
+
a2(movdqa xmm5, xmm4)
|
|
63
|
+
a2(pslld xmm4, 9)
|
|
64
|
+
a2(psrld xmm5, 23)
|
|
65
|
+
a2(pxor xmm2, xmm4)
|
|
66
|
+
a2(movdqa xmm4, xmm3)
|
|
67
|
+
a2(pxor xmm2, xmm5)
|
|
68
|
+
a3(pshufd xmm3, xmm3, 0x93)
|
|
69
|
+
a2(paddd xmm4, xmm2)
|
|
70
|
+
a2(movdqa xmm5, xmm4)
|
|
71
|
+
a2(pslld xmm4, 13)
|
|
72
|
+
a2(psrld xmm5, 19)
|
|
73
|
+
a2(pxor xmm1, xmm4)
|
|
74
|
+
a2(movdqa xmm4, xmm2)
|
|
75
|
+
a2(pxor xmm1, xmm5)
|
|
76
|
+
a3(pshufd xmm2, xmm2, 0x4e)
|
|
77
|
+
a2(paddd xmm4, xmm1)
|
|
78
|
+
a2(movdqa xmm5, xmm4)
|
|
79
|
+
a2(pslld xmm4, 18)
|
|
80
|
+
a2(psrld xmm5, 14)
|
|
81
|
+
a2(pxor xmm0, xmm4)
|
|
82
|
+
a2(movdqa xmm4, xmm3)
|
|
83
|
+
a2(pxor xmm0, xmm5)
|
|
84
|
+
a3(pshufd xmm1, xmm1, 0x39)
|
|
85
|
+
a2(paddd xmm4, xmm0)
|
|
86
|
+
a2(movdqa xmm5, xmm4)
|
|
87
|
+
a2(pslld xmm4, 7)
|
|
88
|
+
a2(psrld xmm5, 25)
|
|
89
|
+
a2(pxor xmm1, xmm4)
|
|
90
|
+
a2(movdqa xmm4, xmm0)
|
|
91
|
+
a2(pxor xmm1, xmm5)
|
|
92
|
+
a2(paddd xmm4, xmm1)
|
|
93
|
+
a2(movdqa xmm5, xmm4)
|
|
94
|
+
a2(pslld xmm4, 9)
|
|
95
|
+
a2(psrld xmm5, 23)
|
|
96
|
+
a2(pxor xmm2, xmm4)
|
|
97
|
+
a2(movdqa xmm4, xmm1)
|
|
98
|
+
a2(pxor xmm2, xmm5)
|
|
99
|
+
a3(pshufd xmm1, xmm1, 0x93)
|
|
100
|
+
a2(paddd xmm4, xmm2)
|
|
101
|
+
a2(movdqa xmm5, xmm4)
|
|
102
|
+
a2(pslld xmm4, 13)
|
|
103
|
+
a2(psrld xmm5, 19)
|
|
104
|
+
a2(pxor xmm3, xmm4)
|
|
105
|
+
a2(movdqa xmm4, xmm2)
|
|
106
|
+
a2(pxor xmm3, xmm5)
|
|
107
|
+
a3(pshufd xmm2, xmm2, 0x4e)
|
|
108
|
+
a2(paddd xmm4, xmm3)
|
|
109
|
+
a2(sub eax, 2)
|
|
110
|
+
a2(movdqa xmm5, xmm4)
|
|
111
|
+
a2(pslld xmm4, 18)
|
|
112
|
+
a2(psrld xmm5, 14)
|
|
113
|
+
a2(pxor xmm0, xmm4)
|
|
114
|
+
a3(pshufd xmm3, xmm3, 0x39)
|
|
115
|
+
a2(pxor xmm0, xmm5)
|
|
116
|
+
a1(ja scrypt_salsa_sse2_loop)
|
|
117
|
+
a2(paddd xmm0,[esp+0])
|
|
118
|
+
a2(paddd xmm1,[esp+16])
|
|
119
|
+
a2(paddd xmm2,xmm6)
|
|
120
|
+
a2(paddd xmm3,xmm7)
|
|
121
|
+
a2(lea eax,[ebx+ecx])
|
|
122
|
+
a2(xor ebx,edx)
|
|
123
|
+
a2(and eax,~0x7f)
|
|
124
|
+
a2(add ecx,64)
|
|
125
|
+
a2(shr eax,1)
|
|
126
|
+
a2(add eax, edi)
|
|
127
|
+
a2(cmp ecx,edx)
|
|
128
|
+
a2(movdqa [eax+0],xmm0)
|
|
129
|
+
a2(movdqa [eax+16],xmm1)
|
|
130
|
+
a2(movdqa [eax+32],xmm2)
|
|
131
|
+
a2(movdqa [eax+48],xmm3)
|
|
132
|
+
a2(mov eax,[ebp+28])
|
|
133
|
+
a1(jne scrypt_ChunkMix_sse2_loop)
|
|
134
|
+
a2(mov esp,ebp)
|
|
135
|
+
a1(pop ebp)
|
|
136
|
+
a1(pop esi)
|
|
137
|
+
a1(pop edi)
|
|
138
|
+
a1(pop ebx)
|
|
139
|
+
a1(ret 16)
|
|
140
|
+
asm_naked_fn_end(scrypt_ChunkMix_sse2)
|
|
141
|
+
|
|
142
|
+
#endif
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
/* x64 */
|
|
147
|
+
#if defined(X86_64ASM_SSE2) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
|
|
148
|
+
|
|
149
|
+
#define SCRYPT_SALSA_SSE2
|
|
150
|
+
|
|
151
|
+
asm_naked_fn_proto(void, scrypt_ChunkMix_sse2)(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r)
|
|
152
|
+
asm_naked_fn(scrypt_ChunkMix_sse2)
|
|
153
|
+
a2(lea rcx,[rcx*2])
|
|
154
|
+
a2(shl rcx,6)
|
|
155
|
+
a2(lea r9,[rcx-64])
|
|
156
|
+
a2(lea rax,[rsi+r9])
|
|
157
|
+
a2(lea r9,[rdx+r9])
|
|
158
|
+
a2(and rdx, rdx)
|
|
159
|
+
a2(movdqa xmm0,[rax+0])
|
|
160
|
+
a2(movdqa xmm1,[rax+16])
|
|
161
|
+
a2(movdqa xmm2,[rax+32])
|
|
162
|
+
a2(movdqa xmm3,[rax+48])
|
|
163
|
+
a1(jz scrypt_ChunkMix_sse2_no_xor1)
|
|
164
|
+
a2(pxor xmm0,[r9+0])
|
|
165
|
+
a2(pxor xmm1,[r9+16])
|
|
166
|
+
a2(pxor xmm2,[r9+32])
|
|
167
|
+
a2(pxor xmm3,[r9+48])
|
|
168
|
+
a1(scrypt_ChunkMix_sse2_no_xor1:)
|
|
169
|
+
a2(xor r9,r9)
|
|
170
|
+
a2(xor r8,r8)
|
|
171
|
+
a1(scrypt_ChunkMix_sse2_loop:)
|
|
172
|
+
a2(and rdx, rdx)
|
|
173
|
+
a2(pxor xmm0,[rsi+r9+0])
|
|
174
|
+
a2(pxor xmm1,[rsi+r9+16])
|
|
175
|
+
a2(pxor xmm2,[rsi+r9+32])
|
|
176
|
+
a2(pxor xmm3,[rsi+r9+48])
|
|
177
|
+
a1(jz scrypt_ChunkMix_sse2_no_xor2)
|
|
178
|
+
a2(pxor xmm0,[rdx+r9+0])
|
|
179
|
+
a2(pxor xmm1,[rdx+r9+16])
|
|
180
|
+
a2(pxor xmm2,[rdx+r9+32])
|
|
181
|
+
a2(pxor xmm3,[rdx+r9+48])
|
|
182
|
+
a1(scrypt_ChunkMix_sse2_no_xor2:)
|
|
183
|
+
a2(movdqa xmm8,xmm0)
|
|
184
|
+
a2(movdqa xmm9,xmm1)
|
|
185
|
+
a2(movdqa xmm10,xmm2)
|
|
186
|
+
a2(movdqa xmm11,xmm3)
|
|
187
|
+
a2(mov rax,8)
|
|
188
|
+
a1(scrypt_salsa_sse2_loop: )
|
|
189
|
+
a2(movdqa xmm4, xmm1)
|
|
190
|
+
a2(paddd xmm4, xmm0)
|
|
191
|
+
a2(movdqa xmm5, xmm4)
|
|
192
|
+
a2(pslld xmm4, 7)
|
|
193
|
+
a2(psrld xmm5, 25)
|
|
194
|
+
a2(pxor xmm3, xmm4)
|
|
195
|
+
a2(movdqa xmm4, xmm0)
|
|
196
|
+
a2(pxor xmm3, xmm5)
|
|
197
|
+
a2(paddd xmm4, xmm3)
|
|
198
|
+
a2(movdqa xmm5, xmm4)
|
|
199
|
+
a2(pslld xmm4, 9)
|
|
200
|
+
a2(psrld xmm5, 23)
|
|
201
|
+
a2(pxor xmm2, xmm4)
|
|
202
|
+
a2(movdqa xmm4, xmm3)
|
|
203
|
+
a2(pxor xmm2, xmm5)
|
|
204
|
+
a3(pshufd xmm3, xmm3, 0x93)
|
|
205
|
+
a2(paddd xmm4, xmm2)
|
|
206
|
+
a2(movdqa xmm5, xmm4)
|
|
207
|
+
a2(pslld xmm4, 13)
|
|
208
|
+
a2(psrld xmm5, 19)
|
|
209
|
+
a2(pxor xmm1, xmm4)
|
|
210
|
+
a2(movdqa xmm4, xmm2)
|
|
211
|
+
a2(pxor xmm1, xmm5)
|
|
212
|
+
a3(pshufd xmm2, xmm2, 0x4e)
|
|
213
|
+
a2(paddd xmm4, xmm1)
|
|
214
|
+
a2(movdqa xmm5, xmm4)
|
|
215
|
+
a2(pslld xmm4, 18)
|
|
216
|
+
a2(psrld xmm5, 14)
|
|
217
|
+
a2(pxor xmm0, xmm4)
|
|
218
|
+
a2(movdqa xmm4, xmm3)
|
|
219
|
+
a2(pxor xmm0, xmm5)
|
|
220
|
+
a3(pshufd xmm1, xmm1, 0x39)
|
|
221
|
+
a2(paddd xmm4, xmm0)
|
|
222
|
+
a2(movdqa xmm5, xmm4)
|
|
223
|
+
a2(pslld xmm4, 7)
|
|
224
|
+
a2(psrld xmm5, 25)
|
|
225
|
+
a2(pxor xmm1, xmm4)
|
|
226
|
+
a2(movdqa xmm4, xmm0)
|
|
227
|
+
a2(pxor xmm1, xmm5)
|
|
228
|
+
a2(paddd xmm4, xmm1)
|
|
229
|
+
a2(movdqa xmm5, xmm4)
|
|
230
|
+
a2(pslld xmm4, 9)
|
|
231
|
+
a2(psrld xmm5, 23)
|
|
232
|
+
a2(pxor xmm2, xmm4)
|
|
233
|
+
a2(movdqa xmm4, xmm1)
|
|
234
|
+
a2(pxor xmm2, xmm5)
|
|
235
|
+
a3(pshufd xmm1, xmm1, 0x93)
|
|
236
|
+
a2(paddd xmm4, xmm2)
|
|
237
|
+
a2(movdqa xmm5, xmm4)
|
|
238
|
+
a2(pslld xmm4, 13)
|
|
239
|
+
a2(psrld xmm5, 19)
|
|
240
|
+
a2(pxor xmm3, xmm4)
|
|
241
|
+
a2(movdqa xmm4, xmm2)
|
|
242
|
+
a2(pxor xmm3, xmm5)
|
|
243
|
+
a3(pshufd xmm2, xmm2, 0x4e)
|
|
244
|
+
a2(paddd xmm4, xmm3)
|
|
245
|
+
a2(sub rax, 2)
|
|
246
|
+
a2(movdqa xmm5, xmm4)
|
|
247
|
+
a2(pslld xmm4, 18)
|
|
248
|
+
a2(psrld xmm5, 14)
|
|
249
|
+
a2(pxor xmm0, xmm4)
|
|
250
|
+
a3(pshufd xmm3, xmm3, 0x39)
|
|
251
|
+
a2(pxor xmm0, xmm5)
|
|
252
|
+
a1(ja scrypt_salsa_sse2_loop)
|
|
253
|
+
a2(paddd xmm0,xmm8)
|
|
254
|
+
a2(paddd xmm1,xmm9)
|
|
255
|
+
a2(paddd xmm2,xmm10)
|
|
256
|
+
a2(paddd xmm3,xmm11)
|
|
257
|
+
a2(lea rax,[r8+r9])
|
|
258
|
+
a2(xor r8,rcx)
|
|
259
|
+
a2(and rax,~0x7f)
|
|
260
|
+
a2(add r9,64)
|
|
261
|
+
a2(shr rax,1)
|
|
262
|
+
a2(add rax, rdi)
|
|
263
|
+
a2(cmp r9,rcx)
|
|
264
|
+
a2(movdqa [rax+0],xmm0)
|
|
265
|
+
a2(movdqa [rax+16],xmm1)
|
|
266
|
+
a2(movdqa [rax+32],xmm2)
|
|
267
|
+
a2(movdqa [rax+48],xmm3)
|
|
268
|
+
a1(jne scrypt_ChunkMix_sse2_loop)
|
|
269
|
+
a1(ret)
|
|
270
|
+
asm_naked_fn_end(scrypt_ChunkMix_sse2)
|
|
271
|
+
|
|
272
|
+
#endif
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
/* intrinsic */
|
|
276
|
+
#if defined(X86_INTRINSIC_SSE2) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
|
|
277
|
+
|
|
278
|
+
#define SCRYPT_SALSA_SSE2
|
|
279
|
+
|
|
280
|
+
static void NOINLINE
|
|
281
|
+
scrypt_ChunkMix_sse2(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r) {
|
|
282
|
+
uint32_t i, blocksPerChunk = r * 2, half = 0;
|
|
283
|
+
xmmi *xmmp,x0,x1,x2,x3,x4,x5,t0,t1,t2,t3;
|
|
284
|
+
size_t rounds;
|
|
285
|
+
|
|
286
|
+
/* 1: X = B_{2r - 1} */
|
|
287
|
+
xmmp = (xmmi *)scrypt_block(Bin, blocksPerChunk - 1);
|
|
288
|
+
x0 = xmmp[0];
|
|
289
|
+
x1 = xmmp[1];
|
|
290
|
+
x2 = xmmp[2];
|
|
291
|
+
x3 = xmmp[3];
|
|
292
|
+
|
|
293
|
+
if (Bxor) {
|
|
294
|
+
xmmp = (xmmi *)scrypt_block(Bxor, blocksPerChunk - 1);
|
|
295
|
+
x0 = _mm_xor_si128(x0, xmmp[0]);
|
|
296
|
+
x1 = _mm_xor_si128(x1, xmmp[1]);
|
|
297
|
+
x2 = _mm_xor_si128(x2, xmmp[2]);
|
|
298
|
+
x3 = _mm_xor_si128(x3, xmmp[3]);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* 2: for i = 0 to 2r - 1 do */
|
|
302
|
+
for (i = 0; i < blocksPerChunk; i++, half ^= r) {
|
|
303
|
+
/* 3: X = H(X ^ B_i) */
|
|
304
|
+
xmmp = (xmmi *)scrypt_block(Bin, i);
|
|
305
|
+
x0 = _mm_xor_si128(x0, xmmp[0]);
|
|
306
|
+
x1 = _mm_xor_si128(x1, xmmp[1]);
|
|
307
|
+
x2 = _mm_xor_si128(x2, xmmp[2]);
|
|
308
|
+
x3 = _mm_xor_si128(x3, xmmp[3]);
|
|
309
|
+
|
|
310
|
+
if (Bxor) {
|
|
311
|
+
xmmp = (xmmi *)scrypt_block(Bxor, i);
|
|
312
|
+
x0 = _mm_xor_si128(x0, xmmp[0]);
|
|
313
|
+
x1 = _mm_xor_si128(x1, xmmp[1]);
|
|
314
|
+
x2 = _mm_xor_si128(x2, xmmp[2]);
|
|
315
|
+
x3 = _mm_xor_si128(x3, xmmp[3]);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
t0 = x0;
|
|
319
|
+
t1 = x1;
|
|
320
|
+
t2 = x2;
|
|
321
|
+
t3 = x3;
|
|
322
|
+
|
|
323
|
+
for (rounds = 8; rounds; rounds -= 2) {
|
|
324
|
+
x4 = x1;
|
|
325
|
+
x4 = _mm_add_epi32(x4, x0);
|
|
326
|
+
x5 = x4;
|
|
327
|
+
x4 = _mm_slli_epi32(x4, 7);
|
|
328
|
+
x5 = _mm_srli_epi32(x5, 25);
|
|
329
|
+
x3 = _mm_xor_si128(x3, x4);
|
|
330
|
+
x4 = x0;
|
|
331
|
+
x3 = _mm_xor_si128(x3, x5);
|
|
332
|
+
x4 = _mm_add_epi32(x4, x3);
|
|
333
|
+
x5 = x4;
|
|
334
|
+
x4 = _mm_slli_epi32(x4, 9);
|
|
335
|
+
x5 = _mm_srli_epi32(x5, 23);
|
|
336
|
+
x2 = _mm_xor_si128(x2, x4);
|
|
337
|
+
x4 = x3;
|
|
338
|
+
x2 = _mm_xor_si128(x2, x5);
|
|
339
|
+
x3 = _mm_shuffle_epi32(x3, 0x93);
|
|
340
|
+
x4 = _mm_add_epi32(x4, x2);
|
|
341
|
+
x5 = x4;
|
|
342
|
+
x4 = _mm_slli_epi32(x4, 13);
|
|
343
|
+
x5 = _mm_srli_epi32(x5, 19);
|
|
344
|
+
x1 = _mm_xor_si128(x1, x4);
|
|
345
|
+
x4 = x2;
|
|
346
|
+
x1 = _mm_xor_si128(x1, x5);
|
|
347
|
+
x2 = _mm_shuffle_epi32(x2, 0x4e);
|
|
348
|
+
x4 = _mm_add_epi32(x4, x1);
|
|
349
|
+
x5 = x4;
|
|
350
|
+
x4 = _mm_slli_epi32(x4, 18);
|
|
351
|
+
x5 = _mm_srli_epi32(x5, 14);
|
|
352
|
+
x0 = _mm_xor_si128(x0, x4);
|
|
353
|
+
x4 = x3;
|
|
354
|
+
x0 = _mm_xor_si128(x0, x5);
|
|
355
|
+
x1 = _mm_shuffle_epi32(x1, 0x39);
|
|
356
|
+
x4 = _mm_add_epi32(x4, x0);
|
|
357
|
+
x5 = x4;
|
|
358
|
+
x4 = _mm_slli_epi32(x4, 7);
|
|
359
|
+
x5 = _mm_srli_epi32(x5, 25);
|
|
360
|
+
x1 = _mm_xor_si128(x1, x4);
|
|
361
|
+
x4 = x0;
|
|
362
|
+
x1 = _mm_xor_si128(x1, x5);
|
|
363
|
+
x4 = _mm_add_epi32(x4, x1);
|
|
364
|
+
x5 = x4;
|
|
365
|
+
x4 = _mm_slli_epi32(x4, 9);
|
|
366
|
+
x5 = _mm_srli_epi32(x5, 23);
|
|
367
|
+
x2 = _mm_xor_si128(x2, x4);
|
|
368
|
+
x4 = x1;
|
|
369
|
+
x2 = _mm_xor_si128(x2, x5);
|
|
370
|
+
x1 = _mm_shuffle_epi32(x1, 0x93);
|
|
371
|
+
x4 = _mm_add_epi32(x4, x2);
|
|
372
|
+
x5 = x4;
|
|
373
|
+
x4 = _mm_slli_epi32(x4, 13);
|
|
374
|
+
x5 = _mm_srli_epi32(x5, 19);
|
|
375
|
+
x3 = _mm_xor_si128(x3, x4);
|
|
376
|
+
x4 = x2;
|
|
377
|
+
x3 = _mm_xor_si128(x3, x5);
|
|
378
|
+
x2 = _mm_shuffle_epi32(x2, 0x4e);
|
|
379
|
+
x4 = _mm_add_epi32(x4, x3);
|
|
380
|
+
x5 = x4;
|
|
381
|
+
x4 = _mm_slli_epi32(x4, 18);
|
|
382
|
+
x5 = _mm_srli_epi32(x5, 14);
|
|
383
|
+
x0 = _mm_xor_si128(x0, x4);
|
|
384
|
+
x3 = _mm_shuffle_epi32(x3, 0x39);
|
|
385
|
+
x0 = _mm_xor_si128(x0, x5);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
x0 = _mm_add_epi32(x0, t0);
|
|
389
|
+
x1 = _mm_add_epi32(x1, t1);
|
|
390
|
+
x2 = _mm_add_epi32(x2, t2);
|
|
391
|
+
x3 = _mm_add_epi32(x3, t3);
|
|
392
|
+
|
|
393
|
+
/* 4: Y_i = X */
|
|
394
|
+
/* 6: B'[0..r-1] = Y_even */
|
|
395
|
+
/* 6: B'[r..2r-1] = Y_odd */
|
|
396
|
+
xmmp = (xmmi *)scrypt_block(Bout, (i / 2) + half);
|
|
397
|
+
xmmp[0] = x0;
|
|
398
|
+
xmmp[1] = x1;
|
|
399
|
+
xmmp[2] = x2;
|
|
400
|
+
xmmp[3] = x3;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
#endif
|
|
405
|
+
|
|
406
|
+
#if defined(SCRYPT_SALSA_SSE2)
|
|
407
|
+
#undef SCRYPT_MIX
|
|
408
|
+
#define SCRYPT_MIX "Salsa/8-SSE2"
|
|
409
|
+
#undef SCRYPT_SALSA_INCLUDED
|
|
410
|
+
#define SCRYPT_SALSA_INCLUDED
|
|
411
|
+
#endif
|
|
412
|
+
|
|
413
|
+
/* used by avx,etc as well */
|
|
414
|
+
#if defined(SCRYPT_SALSA_INCLUDED)
|
|
415
|
+
/*
|
|
416
|
+
Default layout:
|
|
417
|
+
0 1 2 3
|
|
418
|
+
4 5 6 7
|
|
419
|
+
8 9 10 11
|
|
420
|
+
12 13 14 15
|
|
421
|
+
|
|
422
|
+
SSE2 layout:
|
|
423
|
+
0 5 10 15
|
|
424
|
+
12 1 6 11
|
|
425
|
+
8 13 2 7
|
|
426
|
+
4 9 14 3
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
static void STDCALL
|
|
430
|
+
salsa_core_tangle_sse2(uint32_t *blocks, size_t count) {
|
|
431
|
+
uint32_t t;
|
|
432
|
+
while (count--) {
|
|
433
|
+
t = blocks[1]; blocks[1] = blocks[5]; blocks[5] = t;
|
|
434
|
+
t = blocks[2]; blocks[2] = blocks[10]; blocks[10] = t;
|
|
435
|
+
t = blocks[3]; blocks[3] = blocks[15]; blocks[15] = t;
|
|
436
|
+
t = blocks[4]; blocks[4] = blocks[12]; blocks[12] = t;
|
|
437
|
+
t = blocks[7]; blocks[7] = blocks[11]; blocks[11] = t;
|
|
438
|
+
t = blocks[9]; blocks[9] = blocks[13]; blocks[13] = t;
|
|
439
|
+
blocks += 16;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
#endif
|
|
443
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED)
|
|
2
|
+
|
|
3
|
+
#undef SCRYPT_MIX
|
|
4
|
+
#define SCRYPT_MIX "Salsa20/8 Ref"
|
|
5
|
+
|
|
6
|
+
#undef SCRYPT_SALSA_INCLUDED
|
|
7
|
+
#define SCRYPT_SALSA_INCLUDED
|
|
8
|
+
#define SCRYPT_SALSA_BASIC
|
|
9
|
+
|
|
10
|
+
static void
|
|
11
|
+
salsa_core_basic(uint32_t state[16]) {
|
|
12
|
+
size_t rounds = 8;
|
|
13
|
+
uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t;
|
|
14
|
+
|
|
15
|
+
x0 = state[0];
|
|
16
|
+
x1 = state[1];
|
|
17
|
+
x2 = state[2];
|
|
18
|
+
x3 = state[3];
|
|
19
|
+
x4 = state[4];
|
|
20
|
+
x5 = state[5];
|
|
21
|
+
x6 = state[6];
|
|
22
|
+
x7 = state[7];
|
|
23
|
+
x8 = state[8];
|
|
24
|
+
x9 = state[9];
|
|
25
|
+
x10 = state[10];
|
|
26
|
+
x11 = state[11];
|
|
27
|
+
x12 = state[12];
|
|
28
|
+
x13 = state[13];
|
|
29
|
+
x14 = state[14];
|
|
30
|
+
x15 = state[15];
|
|
31
|
+
|
|
32
|
+
#define quarter(a,b,c,d) \
|
|
33
|
+
t = a+d; t = ROTL32(t, 7); b ^= t; \
|
|
34
|
+
t = b+a; t = ROTL32(t, 9); c ^= t; \
|
|
35
|
+
t = c+b; t = ROTL32(t, 13); d ^= t; \
|
|
36
|
+
t = d+c; t = ROTL32(t, 18); a ^= t; \
|
|
37
|
+
|
|
38
|
+
for (; rounds; rounds -= 2) {
|
|
39
|
+
quarter( x0, x4, x8,x12)
|
|
40
|
+
quarter( x5, x9,x13, x1)
|
|
41
|
+
quarter(x10,x14, x2, x6)
|
|
42
|
+
quarter(x15, x3, x7,x11)
|
|
43
|
+
quarter( x0, x1, x2, x3)
|
|
44
|
+
quarter( x5, x6, x7, x4)
|
|
45
|
+
quarter(x10,x11, x8, x9)
|
|
46
|
+
quarter(x15,x12,x13,x14)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
state[0] += x0;
|
|
50
|
+
state[1] += x1;
|
|
51
|
+
state[2] += x2;
|
|
52
|
+
state[3] += x3;
|
|
53
|
+
state[4] += x4;
|
|
54
|
+
state[5] += x5;
|
|
55
|
+
state[6] += x6;
|
|
56
|
+
state[7] += x7;
|
|
57
|
+
state[8] += x8;
|
|
58
|
+
state[9] += x9;
|
|
59
|
+
state[10] += x10;
|
|
60
|
+
state[11] += x11;
|
|
61
|
+
state[12] += x12;
|
|
62
|
+
state[13] += x13;
|
|
63
|
+
state[14] += x14;
|
|
64
|
+
state[15] += x15;
|
|
65
|
+
|
|
66
|
+
#undef quarter
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#endif
|
|
70
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
typedef struct scrypt_hmac_state_t {
|
|
2
|
+
scrypt_hash_state inner, outer;
|
|
3
|
+
} scrypt_hmac_state;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
static void
|
|
7
|
+
scrypt_hash(scrypt_hash_digest hash, const uint8_t *m, size_t mlen) {
|
|
8
|
+
scrypt_hash_state st;
|
|
9
|
+
scrypt_hash_init(&st);
|
|
10
|
+
scrypt_hash_update(&st, m, mlen);
|
|
11
|
+
scrypt_hash_finish(&st, hash);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* hmac */
|
|
15
|
+
static void
|
|
16
|
+
scrypt_hmac_init(scrypt_hmac_state *st, const uint8_t *key, size_t keylen) {
|
|
17
|
+
uint8_t pad[SCRYPT_HASH_BLOCK_SIZE] = {0};
|
|
18
|
+
size_t i;
|
|
19
|
+
|
|
20
|
+
scrypt_hash_init(&st->inner);
|
|
21
|
+
scrypt_hash_init(&st->outer);
|
|
22
|
+
|
|
23
|
+
if (keylen <= SCRYPT_HASH_BLOCK_SIZE) {
|
|
24
|
+
/* use the key directly if it's <= blocksize bytes */
|
|
25
|
+
memcpy(pad, key, keylen);
|
|
26
|
+
} else {
|
|
27
|
+
/* if it's > blocksize bytes, hash it */
|
|
28
|
+
scrypt_hash(pad, key, keylen);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* inner = (key ^ 0x36) */
|
|
32
|
+
/* h(inner || ...) */
|
|
33
|
+
for (i = 0; i < SCRYPT_HASH_BLOCK_SIZE; i++)
|
|
34
|
+
pad[i] ^= 0x36;
|
|
35
|
+
scrypt_hash_update(&st->inner, pad, SCRYPT_HASH_BLOCK_SIZE);
|
|
36
|
+
|
|
37
|
+
/* outer = (key ^ 0x5c) */
|
|
38
|
+
/* h(outer || ...) */
|
|
39
|
+
for (i = 0; i < SCRYPT_HASH_BLOCK_SIZE; i++)
|
|
40
|
+
pad[i] ^= (0x5c ^ 0x36);
|
|
41
|
+
scrypt_hash_update(&st->outer, pad, SCRYPT_HASH_BLOCK_SIZE);
|
|
42
|
+
|
|
43
|
+
scrypt_ensure_zero(pad, sizeof(pad));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static void
|
|
47
|
+
scrypt_hmac_update(scrypt_hmac_state *st, const uint8_t *m, size_t mlen) {
|
|
48
|
+
/* h(inner || m...) */
|
|
49
|
+
scrypt_hash_update(&st->inner, m, mlen);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static void
|
|
53
|
+
scrypt_hmac_finish(scrypt_hmac_state *st, scrypt_hash_digest mac) {
|
|
54
|
+
/* h(inner || m) */
|
|
55
|
+
scrypt_hash_digest innerhash;
|
|
56
|
+
scrypt_hash_finish(&st->inner, innerhash);
|
|
57
|
+
|
|
58
|
+
/* h(outer || h(inner || m)) */
|
|
59
|
+
scrypt_hash_update(&st->outer, innerhash, sizeof(innerhash));
|
|
60
|
+
scrypt_hash_finish(&st->outer, mac);
|
|
61
|
+
|
|
62
|
+
scrypt_ensure_zero(st, sizeof(*st));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static void
|
|
66
|
+
scrypt_pbkdf2(const uint8_t *password, size_t password_len, const uint8_t *salt, size_t salt_len, uint64_t N, uint8_t *out, size_t bytes) {
|
|
67
|
+
scrypt_hmac_state hmac_pw, hmac_pw_salt, work;
|
|
68
|
+
scrypt_hash_digest ti, u;
|
|
69
|
+
uint8_t be[4];
|
|
70
|
+
uint32_t i, j, blocks;
|
|
71
|
+
uint64_t c;
|
|
72
|
+
|
|
73
|
+
/* bytes must be <= (0xffffffff - (SCRYPT_HASH_DIGEST_SIZE - 1)), which they will always be under scrypt */
|
|
74
|
+
|
|
75
|
+
/* hmac(password, ...) */
|
|
76
|
+
scrypt_hmac_init(&hmac_pw, password, password_len);
|
|
77
|
+
|
|
78
|
+
/* hmac(password, salt...) */
|
|
79
|
+
hmac_pw_salt = hmac_pw;
|
|
80
|
+
scrypt_hmac_update(&hmac_pw_salt, salt, salt_len);
|
|
81
|
+
|
|
82
|
+
blocks = ((uint32_t)bytes + (SCRYPT_HASH_DIGEST_SIZE - 1)) / SCRYPT_HASH_DIGEST_SIZE;
|
|
83
|
+
for (i = 1; i <= blocks; i++) {
|
|
84
|
+
/* U1 = hmac(password, salt || be(i)) */
|
|
85
|
+
U32TO8_BE(be, i);
|
|
86
|
+
work = hmac_pw_salt;
|
|
87
|
+
scrypt_hmac_update(&work, be, 4);
|
|
88
|
+
scrypt_hmac_finish(&work, ti);
|
|
89
|
+
memcpy(u, ti, sizeof(u));
|
|
90
|
+
|
|
91
|
+
/* T[i] = U1 ^ U2 ^ U3... */
|
|
92
|
+
for (c = 0; c < N - 1; c++) {
|
|
93
|
+
/* UX = hmac(password, U{X-1}) */
|
|
94
|
+
work = hmac_pw;
|
|
95
|
+
scrypt_hmac_update(&work, u, SCRYPT_HASH_DIGEST_SIZE);
|
|
96
|
+
scrypt_hmac_finish(&work, u);
|
|
97
|
+
|
|
98
|
+
/* T[i] ^= UX */
|
|
99
|
+
for (j = 0; j < sizeof(u); j++)
|
|
100
|
+
ti[j] ^= u[j];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
memcpy(out, ti, (bytes > SCRYPT_HASH_DIGEST_SIZE) ? SCRYPT_HASH_DIGEST_SIZE : bytes);
|
|
104
|
+
out += SCRYPT_HASH_DIGEST_SIZE;
|
|
105
|
+
bytes -= SCRYPT_HASH_DIGEST_SIZE;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
scrypt_ensure_zero(ti, sizeof(ti));
|
|
109
|
+
scrypt_ensure_zero(u, sizeof(u));
|
|
110
|
+
scrypt_ensure_zero(&hmac_pw, sizeof(hmac_pw));
|
|
111
|
+
scrypt_ensure_zero(&hmac_pw_salt, sizeof(hmac_pw_salt));
|
|
112
|
+
}
|