@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,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#if !defined(ARGON2_NO_THREADS)
|
|
19
|
+
|
|
20
|
+
#include "thread.h"
|
|
21
|
+
#if defined(_WIN32)
|
|
22
|
+
#include <windows.h>
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
int argon2_thread_create(argon2_thread_handle_t *handle,
|
|
26
|
+
argon2_thread_func_t func, void *args) {
|
|
27
|
+
if (NULL == handle || func == NULL) {
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
#if defined(_WIN32)
|
|
31
|
+
*handle = _beginthreadex(NULL, 0, func, args, 0, NULL);
|
|
32
|
+
return *handle != 0 ? 0 : -1;
|
|
33
|
+
#else
|
|
34
|
+
return pthread_create(handle, NULL, func, args);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
int argon2_thread_join(argon2_thread_handle_t handle) {
|
|
39
|
+
#if defined(_WIN32)
|
|
40
|
+
if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) {
|
|
41
|
+
return CloseHandle((HANDLE)handle) != 0 ? 0 : -1;
|
|
42
|
+
}
|
|
43
|
+
return -1;
|
|
44
|
+
#else
|
|
45
|
+
return pthread_join(handle, NULL);
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void argon2_thread_exit(void) {
|
|
50
|
+
#if defined(_WIN32)
|
|
51
|
+
_endthreadex(0);
|
|
52
|
+
#else
|
|
53
|
+
pthread_exit(NULL);
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#endif /* ARGON2_NO_THREADS */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef ARGON2_THREAD_H
|
|
19
|
+
#define ARGON2_THREAD_H
|
|
20
|
+
|
|
21
|
+
#if !defined(ARGON2_NO_THREADS)
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
Here we implement an abstraction layer for the simpĺe requirements
|
|
25
|
+
of the Argon2 code. We only require 3 primitives---thread creation,
|
|
26
|
+
joining, and termination---so full emulation of the pthreads API
|
|
27
|
+
is unwarranted. Currently we wrap pthreads and Win32 threads.
|
|
28
|
+
|
|
29
|
+
The API defines 2 types: the function pointer type,
|
|
30
|
+
argon2_thread_func_t,
|
|
31
|
+
and the type of the thread handle---argon2_thread_handle_t.
|
|
32
|
+
*/
|
|
33
|
+
#if defined(_WIN32)
|
|
34
|
+
#include <process.h>
|
|
35
|
+
typedef unsigned(__stdcall *argon2_thread_func_t)(void *);
|
|
36
|
+
typedef uintptr_t argon2_thread_handle_t;
|
|
37
|
+
#else
|
|
38
|
+
#include <pthread.h>
|
|
39
|
+
typedef void *(*argon2_thread_func_t)(void *);
|
|
40
|
+
typedef pthread_t argon2_thread_handle_t;
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
/* Creates a thread
|
|
44
|
+
* @param handle pointer to a thread handle, which is the output of this
|
|
45
|
+
* function. Must not be NULL.
|
|
46
|
+
* @param func A function pointer for the thread's entry point. Must not be
|
|
47
|
+
* NULL.
|
|
48
|
+
* @param args Pointer that is passed as an argument to @func. May be NULL.
|
|
49
|
+
* @return 0 if @handle and @func are valid pointers and a thread is successfully
|
|
50
|
+
* created.
|
|
51
|
+
*/
|
|
52
|
+
int argon2_thread_create(argon2_thread_handle_t *handle,
|
|
53
|
+
argon2_thread_func_t func, void *args);
|
|
54
|
+
|
|
55
|
+
/* Waits for a thread to terminate
|
|
56
|
+
* @param handle Handle to a thread created with argon2_thread_create.
|
|
57
|
+
* @return 0 if @handle is a valid handle, and joining completed successfully.
|
|
58
|
+
*/
|
|
59
|
+
int argon2_thread_join(argon2_thread_handle_t handle);
|
|
60
|
+
|
|
61
|
+
/* Terminate the current thread. Must be run inside a thread created by
|
|
62
|
+
* argon2_thread_create.
|
|
63
|
+
*/
|
|
64
|
+
void argon2_thread_exit(void);
|
|
65
|
+
|
|
66
|
+
#endif /* ARGON2_NO_THREADS */
|
|
67
|
+
#endif
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#############
|
|
2
|
+
# UNITTESTS #
|
|
3
|
+
#############
|
|
4
|
+
|
|
5
|
+
add_executable(argon2-tests "test.c")
|
|
6
|
+
target_link_libraries(argon2-tests PRIVATE argon2-shared)
|
|
7
|
+
add_test(NAME argon2-tests
|
|
8
|
+
COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/argon2-tests")
|
|
9
|
+
|
|
10
|
+
##########
|
|
11
|
+
# GENKAT #
|
|
12
|
+
##########
|
|
13
|
+
|
|
14
|
+
add_executable(genkat "genkat.c")
|
|
15
|
+
target_link_libraries(genkat PRIVATE argon2-static-genkat)
|
|
16
|
+
|
|
17
|
+
if (WIN32)
|
|
18
|
+
add_test(NAME argon2-genkat
|
|
19
|
+
COMMAND "powershell" "-Command"
|
|
20
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/kats/test.ps1"
|
|
21
|
+
"--genkat" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/genkat")
|
|
22
|
+
else()
|
|
23
|
+
# Testing powershell on Linux
|
|
24
|
+
#add_test(NAME argon2-genkat
|
|
25
|
+
# COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/kats/test.ps1"
|
|
26
|
+
# "--genkat" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genkat")
|
|
27
|
+
|
|
28
|
+
add_test(NAME argon2-genkat
|
|
29
|
+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/kats/test.sh"
|
|
30
|
+
"--genkat=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genkat")
|
|
31
|
+
endif()
|
|
32
|
+
|
|
33
|
+
#############
|
|
34
|
+
# BENCHMARK #
|
|
35
|
+
#############
|
|
36
|
+
if (NOT BENCHMARKS)
|
|
37
|
+
message(STATUS "Skipping benchmarks")
|
|
38
|
+
else()
|
|
39
|
+
add_executable(benchmark "bench.c")
|
|
40
|
+
target_link_libraries(benchmark PRIVATE argon2-static ${THREADS_DEP})
|
|
41
|
+
add_custom_target(argon2-benchmark
|
|
42
|
+
COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmark")
|
|
43
|
+
endif()
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <stdint.h>
|
|
20
|
+
#include <stdlib.h>
|
|
21
|
+
#include <string.h>
|
|
22
|
+
#include <time.h>
|
|
23
|
+
#ifdef _MSC_VER
|
|
24
|
+
#include <intrin.h>
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#include "argon2.h"
|
|
28
|
+
|
|
29
|
+
static uint64_t rdtsc(void) {
|
|
30
|
+
#ifdef _MSC_VER
|
|
31
|
+
return __rdtsc();
|
|
32
|
+
#else
|
|
33
|
+
#if defined(__amd64__) || defined(__x86_64__)
|
|
34
|
+
uint64_t rax, rdx;
|
|
35
|
+
__asm__ __volatile__("rdtsc" : "=a"(rax), "=d"(rdx) : :);
|
|
36
|
+
return (rdx << 32) | rax;
|
|
37
|
+
#elif defined(__i386__) || defined(__i386) || defined(__X86__)
|
|
38
|
+
uint64_t rax;
|
|
39
|
+
__asm__ __volatile__("rdtsc" : "=A"(rax) : :);
|
|
40
|
+
return rax;
|
|
41
|
+
#else
|
|
42
|
+
#error "Not implemented!"
|
|
43
|
+
#endif
|
|
44
|
+
#endif
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Benchmarks Argon2 with salt length 16, password length 16, t_cost 3,
|
|
49
|
+
and different m_cost and threads
|
|
50
|
+
*/
|
|
51
|
+
static void benchmark() {
|
|
52
|
+
#define BENCH_OUTLEN 16
|
|
53
|
+
#define BENCH_INLEN 16
|
|
54
|
+
const uint32_t inlen = BENCH_INLEN;
|
|
55
|
+
const unsigned outlen = BENCH_OUTLEN;
|
|
56
|
+
unsigned char out[BENCH_OUTLEN];
|
|
57
|
+
unsigned char pwd_array[BENCH_INLEN];
|
|
58
|
+
unsigned char salt_array[BENCH_INLEN];
|
|
59
|
+
#undef BENCH_INLEN
|
|
60
|
+
#undef BENCH_OUTLEN
|
|
61
|
+
|
|
62
|
+
uint32_t t_cost = 3;
|
|
63
|
+
uint32_t m_cost;
|
|
64
|
+
uint32_t thread_test[4] = {1, 2, 4, 8};
|
|
65
|
+
argon2_type types[3] = {Argon2_i, Argon2_d, Argon2_id};
|
|
66
|
+
|
|
67
|
+
memset(pwd_array, 0, inlen);
|
|
68
|
+
memset(salt_array, 1, inlen);
|
|
69
|
+
|
|
70
|
+
for (m_cost = (uint32_t)1 << 10; m_cost <= (uint32_t)1 << 22; m_cost *= 2) {
|
|
71
|
+
unsigned i;
|
|
72
|
+
for (i = 0; i < 4; ++i) {
|
|
73
|
+
double run_time = 0;
|
|
74
|
+
uint32_t thread_n = thread_test[i];
|
|
75
|
+
|
|
76
|
+
unsigned j;
|
|
77
|
+
for (j = 0; j < 3; ++j) {
|
|
78
|
+
clock_t start_time, stop_time;
|
|
79
|
+
uint64_t start_cycles, stop_cycles;
|
|
80
|
+
uint64_t delta;
|
|
81
|
+
double mcycles;
|
|
82
|
+
|
|
83
|
+
argon2_type type = types[j];
|
|
84
|
+
start_time = clock();
|
|
85
|
+
start_cycles = rdtsc();
|
|
86
|
+
|
|
87
|
+
argon2_hash(t_cost, m_cost, thread_n, pwd_array, inlen,
|
|
88
|
+
salt_array, inlen, out, outlen, NULL, 0, type,
|
|
89
|
+
ARGON2_VERSION_NUMBER);
|
|
90
|
+
|
|
91
|
+
stop_cycles = rdtsc();
|
|
92
|
+
stop_time = clock();
|
|
93
|
+
|
|
94
|
+
delta = (stop_cycles - start_cycles) / (m_cost);
|
|
95
|
+
mcycles = (double)(stop_cycles - start_cycles) / (1UL << 20);
|
|
96
|
+
run_time += ((double)stop_time - start_time) / (CLOCKS_PER_SEC);
|
|
97
|
+
|
|
98
|
+
printf("%s %d iterations %d MiB %d threads: %2.2f cpb %2.2f "
|
|
99
|
+
"Mcycles \n", argon2_type2string(type, 1), t_cost,
|
|
100
|
+
m_cost >> 10, thread_n, (float)delta / 1024, mcycles);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
printf("%2.4f seconds\n\n", run_time);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
int main() {
|
|
109
|
+
benchmark();
|
|
110
|
+
return ARGON2_OK;
|
|
111
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
#include <string.h>
|
|
21
|
+
#include "argon2.h"
|
|
22
|
+
#include "core.h"
|
|
23
|
+
|
|
24
|
+
void initial_kat(const uint8_t *blockhash, const argon2_context *context,
|
|
25
|
+
argon2_type type) {
|
|
26
|
+
unsigned i;
|
|
27
|
+
|
|
28
|
+
if (blockhash != NULL && context != NULL) {
|
|
29
|
+
printf("=======================================\n");
|
|
30
|
+
|
|
31
|
+
printf("%s version number %d\n", argon2_type2string(type, 1),
|
|
32
|
+
context->version);
|
|
33
|
+
|
|
34
|
+
printf("=======================================\n");
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
printf("Memory: %u KiB, Iterations: %u, Parallelism: %u lanes, Tag "
|
|
38
|
+
"length: %u bytes\n",
|
|
39
|
+
context->m_cost, context->t_cost, context->lanes,
|
|
40
|
+
context->outlen);
|
|
41
|
+
|
|
42
|
+
printf("Password[%u]: ", context->pwdlen);
|
|
43
|
+
|
|
44
|
+
if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) {
|
|
45
|
+
printf("CLEARED\n");
|
|
46
|
+
} else {
|
|
47
|
+
for (i = 0; i < context->pwdlen; ++i) {
|
|
48
|
+
printf("%2.2x ", ((unsigned char *)context->pwd)[i]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
printf("\n");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
printf("Salt[%u]: ", context->saltlen);
|
|
55
|
+
|
|
56
|
+
for (i = 0; i < context->saltlen; ++i) {
|
|
57
|
+
printf("%2.2x ", ((unsigned char *)context->salt)[i]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
printf("\n");
|
|
61
|
+
|
|
62
|
+
printf("Secret[%u]: ", context->secretlen);
|
|
63
|
+
|
|
64
|
+
if (context->flags & ARGON2_FLAG_CLEAR_SECRET) {
|
|
65
|
+
printf("CLEARED\n");
|
|
66
|
+
} else {
|
|
67
|
+
for (i = 0; i < context->secretlen; ++i) {
|
|
68
|
+
printf("%2.2x ", ((unsigned char *)context->secret)[i]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
printf("\n");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
printf("Associated data[%u]: ", context->adlen);
|
|
75
|
+
|
|
76
|
+
for (i = 0; i < context->adlen; ++i) {
|
|
77
|
+
printf("%2.2x ", ((unsigned char *)context->ad)[i]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
printf("\n");
|
|
81
|
+
|
|
82
|
+
printf("Pre-hashing digest: ");
|
|
83
|
+
|
|
84
|
+
for (i = 0; i < ARGON2_PREHASH_DIGEST_LENGTH; ++i) {
|
|
85
|
+
printf("%2.2x ", ((unsigned char *)blockhash)[i]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
printf("\n");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void print_tag(const void *out, uint32_t outlen) {
|
|
93
|
+
unsigned i;
|
|
94
|
+
if (out != NULL) {
|
|
95
|
+
printf("Tag: ");
|
|
96
|
+
|
|
97
|
+
for (i = 0; i < outlen; ++i) {
|
|
98
|
+
printf("%2.2x ", ((uint8_t *)out)[i]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
printf("\n");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void internal_kat(const argon2_instance_t *instance, uint32_t pass) {
|
|
106
|
+
|
|
107
|
+
if (instance != NULL) {
|
|
108
|
+
uint32_t i, j;
|
|
109
|
+
printf("\n After pass %u:\n", pass);
|
|
110
|
+
|
|
111
|
+
for (i = 0; i < instance->memory_blocks; ++i) {
|
|
112
|
+
uint32_t how_many_words =
|
|
113
|
+
(instance->memory_blocks > ARGON2_QWORDS_IN_BLOCK)
|
|
114
|
+
? 1
|
|
115
|
+
: ARGON2_QWORDS_IN_BLOCK;
|
|
116
|
+
|
|
117
|
+
for (j = 0; j < how_many_words; ++j)
|
|
118
|
+
printf("Block %.4u [%3u]: %016llx\n", i, j,
|
|
119
|
+
(unsigned long long)instance->memory[i].v[j]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static void fatal(const char *error) {
|
|
125
|
+
fprintf(stderr, "Error: %s\n", error);
|
|
126
|
+
exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static void generate_testvectors(argon2_type type, const uint32_t version) {
|
|
130
|
+
#define TEST_OUTLEN 32
|
|
131
|
+
#define TEST_PWDLEN 32
|
|
132
|
+
#define TEST_SALTLEN 16
|
|
133
|
+
#define TEST_SECRETLEN 8
|
|
134
|
+
#define TEST_ADLEN 12
|
|
135
|
+
argon2_context context;
|
|
136
|
+
|
|
137
|
+
unsigned char out[TEST_OUTLEN];
|
|
138
|
+
unsigned char pwd[TEST_PWDLEN];
|
|
139
|
+
unsigned char salt[TEST_SALTLEN];
|
|
140
|
+
unsigned char secret[TEST_SECRETLEN];
|
|
141
|
+
unsigned char ad[TEST_ADLEN];
|
|
142
|
+
const allocate_fptr myown_allocator = NULL;
|
|
143
|
+
const deallocate_fptr myown_deallocator = NULL;
|
|
144
|
+
|
|
145
|
+
unsigned t_cost = 3;
|
|
146
|
+
unsigned m_cost = 32;
|
|
147
|
+
unsigned lanes = 4;
|
|
148
|
+
|
|
149
|
+
memset(pwd, 1, TEST_OUTLEN);
|
|
150
|
+
memset(salt, 2, TEST_SALTLEN);
|
|
151
|
+
memset(secret, 3, TEST_SECRETLEN);
|
|
152
|
+
memset(ad, 4, TEST_ADLEN);
|
|
153
|
+
|
|
154
|
+
context.out = out;
|
|
155
|
+
context.outlen = TEST_OUTLEN;
|
|
156
|
+
context.version = version;
|
|
157
|
+
context.pwd = pwd;
|
|
158
|
+
context.pwdlen = TEST_PWDLEN;
|
|
159
|
+
context.salt = salt;
|
|
160
|
+
context.saltlen = TEST_SALTLEN;
|
|
161
|
+
context.secret = secret;
|
|
162
|
+
context.secretlen = TEST_SECRETLEN;
|
|
163
|
+
context.ad = ad;
|
|
164
|
+
context.adlen = TEST_ADLEN;
|
|
165
|
+
context.t_cost = t_cost;
|
|
166
|
+
context.m_cost = m_cost;
|
|
167
|
+
context.lanes = lanes;
|
|
168
|
+
context.threads = lanes;
|
|
169
|
+
context.allocate_cbk = myown_allocator;
|
|
170
|
+
context.free_cbk = myown_deallocator;
|
|
171
|
+
context.flags = ARGON2_DEFAULT_FLAGS;
|
|
172
|
+
|
|
173
|
+
#undef TEST_OUTLEN
|
|
174
|
+
#undef TEST_PWDLEN
|
|
175
|
+
#undef TEST_SALTLEN
|
|
176
|
+
#undef TEST_SECRETLEN
|
|
177
|
+
#undef TEST_ADLEN
|
|
178
|
+
|
|
179
|
+
argon2_ctx(&context, type);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
int main(int argc, char *argv[]) {
|
|
183
|
+
/* Get and check Argon2 type */
|
|
184
|
+
const char *type_str = (argc > 1) ? argv[1] : "i";
|
|
185
|
+
argon2_type type = Argon2_i;
|
|
186
|
+
uint32_t version = ARGON2_VERSION_NUMBER;
|
|
187
|
+
if (!strcmp(type_str, "d")) {
|
|
188
|
+
type = Argon2_d;
|
|
189
|
+
} else if (!strcmp(type_str, "i")) {
|
|
190
|
+
type = Argon2_i;
|
|
191
|
+
} else if (!strcmp(type_str, "id")) {
|
|
192
|
+
type = Argon2_id;
|
|
193
|
+
} else {
|
|
194
|
+
fatal("wrong Argon2 type");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* Get and check Argon2 version number */
|
|
198
|
+
if (argc > 2) {
|
|
199
|
+
version = strtoul(argv[2], NULL, 10);
|
|
200
|
+
}
|
|
201
|
+
if (ARGON2_VERSION_10 != version && ARGON2_VERSION_NUMBER != version) {
|
|
202
|
+
fatal("wrong Argon2 version number");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
generate_testvectors(type, version);
|
|
206
|
+
return ARGON2_OK;
|
|
207
|
+
}
|