@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,30 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#include "../hash.h"
|
|
7
|
+
#include "../wild_keccak.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
namespace cryptonote
|
|
11
|
+
{
|
|
12
|
+
template<typename callback_t>
|
|
13
|
+
bool get_blob_longhash_bb(const blobdata& bd, crypto::hash& res, uint64_t height, callback_t accessor)
|
|
14
|
+
{
|
|
15
|
+
crypto::wild_keccak_dbl<crypto::mul_f>(reinterpret_cast<const uint8_t*>(bd.data()), bd.size(), reinterpret_cast<uint8_t*>(&res), sizeof(res), [&](crypto::state_t_m& st, crypto::mixin_t& mix)
|
|
16
|
+
{
|
|
17
|
+
if(!height)
|
|
18
|
+
{
|
|
19
|
+
memset(&mix, 0, sizeof(mix));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
#define GET_H(index) accessor(st[index])
|
|
23
|
+
for(size_t i = 0; i!=6; i++)
|
|
24
|
+
{
|
|
25
|
+
*(crypto::hash*)&mix[i*4] = XOR_4(GET_H(i*4), GET_H(i*4+1), GET_H(i*4+2), GET_H(i*4+3));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <list>
|
|
8
|
+
#include "serialization/keyvalue_serialization.h"
|
|
9
|
+
#include "cryptonote_core/cryptonote_basic.h"
|
|
10
|
+
#include "cryptonote_protocol/blobdatatype.h"
|
|
11
|
+
namespace cryptonote
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#define BC_COMMANDS_POOL_BASE 2000
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/************************************************************************/
|
|
19
|
+
/* */
|
|
20
|
+
/************************************************************************/
|
|
21
|
+
struct block_complete_entry
|
|
22
|
+
{
|
|
23
|
+
blobdata block;
|
|
24
|
+
std::list<blobdata> txs;
|
|
25
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
26
|
+
KV_SERIALIZE(block)
|
|
27
|
+
KV_SERIALIZE(txs)
|
|
28
|
+
END_KV_SERIALIZE_MAP()
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/************************************************************************/
|
|
33
|
+
/* */
|
|
34
|
+
/************************************************************************/
|
|
35
|
+
struct NOTIFY_NEW_BLOCK
|
|
36
|
+
{
|
|
37
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 1;
|
|
38
|
+
|
|
39
|
+
struct request
|
|
40
|
+
{
|
|
41
|
+
block_complete_entry b;
|
|
42
|
+
uint64_t current_blockchain_height;
|
|
43
|
+
uint32_t hop;
|
|
44
|
+
|
|
45
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
46
|
+
KV_SERIALIZE(b)
|
|
47
|
+
KV_SERIALIZE(current_blockchain_height)
|
|
48
|
+
KV_SERIALIZE(hop)
|
|
49
|
+
END_KV_SERIALIZE_MAP()
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/************************************************************************/
|
|
54
|
+
/* */
|
|
55
|
+
/************************************************************************/
|
|
56
|
+
struct NOTIFY_NEW_TRANSACTIONS
|
|
57
|
+
{
|
|
58
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 2;
|
|
59
|
+
|
|
60
|
+
struct request
|
|
61
|
+
{
|
|
62
|
+
std::list<blobdata> txs;
|
|
63
|
+
|
|
64
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
65
|
+
KV_SERIALIZE(txs)
|
|
66
|
+
END_KV_SERIALIZE_MAP()
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/************************************************************************/
|
|
70
|
+
/* */
|
|
71
|
+
/************************************************************************/
|
|
72
|
+
struct NOTIFY_REQUEST_GET_OBJECTS
|
|
73
|
+
{
|
|
74
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 3;
|
|
75
|
+
|
|
76
|
+
struct request
|
|
77
|
+
{
|
|
78
|
+
std::list<crypto::hash> txs;
|
|
79
|
+
std::list<crypto::hash> blocks;
|
|
80
|
+
|
|
81
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
82
|
+
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(txs)
|
|
83
|
+
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(blocks)
|
|
84
|
+
END_KV_SERIALIZE_MAP()
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
struct NOTIFY_RESPONSE_GET_OBJECTS
|
|
89
|
+
{
|
|
90
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 4;
|
|
91
|
+
|
|
92
|
+
struct request
|
|
93
|
+
{
|
|
94
|
+
std::list<blobdata> txs;
|
|
95
|
+
std::list<block_complete_entry> blocks;
|
|
96
|
+
std::list<crypto::hash> missed_ids;
|
|
97
|
+
uint64_t current_blockchain_height;
|
|
98
|
+
|
|
99
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
100
|
+
KV_SERIALIZE(txs)
|
|
101
|
+
KV_SERIALIZE(blocks)
|
|
102
|
+
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(missed_ids)
|
|
103
|
+
KV_SERIALIZE(current_blockchain_height)
|
|
104
|
+
END_KV_SERIALIZE_MAP()
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
struct CORE_SYNC_DATA
|
|
110
|
+
{
|
|
111
|
+
uint64_t current_height;
|
|
112
|
+
crypto::hash top_id;
|
|
113
|
+
|
|
114
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
115
|
+
KV_SERIALIZE(current_height)
|
|
116
|
+
KV_SERIALIZE_VAL_POD_AS_BLOB(top_id)
|
|
117
|
+
END_KV_SERIALIZE_MAP()
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
struct NOTIFY_REQUEST_CHAIN
|
|
121
|
+
{
|
|
122
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 6;
|
|
123
|
+
|
|
124
|
+
struct request
|
|
125
|
+
{
|
|
126
|
+
std::list<crypto::hash> block_ids; /*IDs of the first 10 blocks are sequential, next goes with pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
|
|
127
|
+
|
|
128
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
129
|
+
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(block_ids)
|
|
130
|
+
END_KV_SERIALIZE_MAP()
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
struct NOTIFY_RESPONSE_CHAIN_ENTRY
|
|
135
|
+
{
|
|
136
|
+
const static int ID = BC_COMMANDS_POOL_BASE + 7;
|
|
137
|
+
|
|
138
|
+
struct request
|
|
139
|
+
{
|
|
140
|
+
uint64_t start_height;
|
|
141
|
+
uint64_t total_height;
|
|
142
|
+
std::list<crypto::hash> m_block_ids;
|
|
143
|
+
|
|
144
|
+
BEGIN_KV_SERIALIZE_MAP()
|
|
145
|
+
KV_SERIALIZE(start_height)
|
|
146
|
+
KV_SERIALIZE(total_height)
|
|
147
|
+
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_ids)
|
|
148
|
+
END_KV_SERIALIZE_MAP()
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#ifndef __tables_h
|
|
2
|
+
#define __tables_h
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const uint32_t T[512] = {0xa5f432c6, 0xc6a597f4, 0x84976ff8, 0xf884eb97, 0x99b05eee, 0xee99c7b0, 0x8d8c7af6, 0xf68df78c, 0xd17e8ff, 0xff0de517, 0xbddc0ad6, 0xd6bdb7dc, 0xb1c816de, 0xdeb1a7c8, 0x54fc6d91, 0x915439fc
|
|
6
|
+
, 0x50f09060, 0x6050c0f0, 0x3050702, 0x2030405, 0xa9e02ece, 0xcea987e0, 0x7d87d156, 0x567dac87, 0x192bcce7, 0xe719d52b, 0x62a613b5, 0xb56271a6, 0xe6317c4d, 0x4de69a31, 0x9ab559ec, 0xec9ac3b5
|
|
7
|
+
, 0x45cf408f, 0x8f4505cf, 0x9dbca31f, 0x1f9d3ebc, 0x40c04989, 0x894009c0, 0x879268fa, 0xfa87ef92, 0x153fd0ef, 0xef15c53f, 0xeb2694b2, 0xb2eb7f26, 0xc940ce8e, 0x8ec90740, 0xb1de6fb, 0xfb0bed1d
|
|
8
|
+
, 0xec2f6e41, 0x41ec822f, 0x67a91ab3, 0xb3677da9, 0xfd1c435f, 0x5ffdbe1c, 0xea256045, 0x45ea8a25, 0xbfdaf923, 0x23bf46da, 0xf7025153, 0x53f7a602, 0x96a145e4, 0xe496d3a1, 0x5bed769b, 0x9b5b2ded
|
|
9
|
+
, 0xc25d2875, 0x75c2ea5d, 0x1c24c5e1, 0xe11cd924, 0xaee9d43d, 0x3dae7ae9, 0x6abef24c, 0x4c6a98be, 0x5aee826c, 0x6c5ad8ee, 0x41c3bd7e, 0x7e41fcc3, 0x206f3f5, 0xf502f106, 0x4fd15283, 0x834f1dd1
|
|
10
|
+
, 0x5ce48c68, 0x685cd0e4, 0xf4075651, 0x51f4a207, 0x345c8dd1, 0xd134b95c, 0x818e1f9, 0xf908e918, 0x93ae4ce2, 0xe293dfae, 0x73953eab, 0xab734d95, 0x53f59762, 0x6253c4f5, 0x3f416b2a, 0x2a3f5441
|
|
11
|
+
, 0xc141c08, 0x80c1014, 0x52f66395, 0x955231f6, 0x65afe946, 0x46658caf, 0x5ee27f9d, 0x9d5e21e2, 0x28784830, 0x30286078, 0xa1f8cf37, 0x37a16ef8, 0xf111b0a, 0xa0f1411, 0xb5c4eb2f, 0x2fb55ec4
|
|
12
|
+
, 0x91b150e, 0xe091c1b, 0x365a7e24, 0x2436485a, 0x9bb6ad1b, 0x1b9b36b6, 0x3d4798df, 0xdf3da547, 0x266aa7cd, 0xcd26816a, 0x69bbf54e, 0x4e699cbb, 0xcd4c337f, 0x7fcdfe4c, 0x9fba50ea, 0xea9fcfba
|
|
13
|
+
, 0x1b2d3f12, 0x121b242d, 0x9eb9a41d, 0x1d9e3ab9, 0x749cc458, 0x5874b09c, 0x2e724634, 0x342e6872, 0x2d774136, 0x362d6c77, 0xb2cd11dc, 0xdcb2a3cd, 0xee299db4, 0xb4ee7329, 0xfb164d5b, 0x5bfbb616
|
|
14
|
+
, 0xf601a5a4, 0xa4f65301, 0x4dd7a176, 0x764decd7, 0x61a314b7, 0xb76175a3, 0xce49347d, 0x7dcefa49, 0x7b8ddf52, 0x527ba48d, 0x3e429fdd, 0xdd3ea142, 0x7193cd5e, 0x5e71bc93, 0x97a2b113, 0x139726a2
|
|
15
|
+
, 0xf504a2a6, 0xa6f55704, 0x68b801b9, 0xb96869b8, 0x0, 0x0, 0x2c74b5c1, 0xc12c9974, 0x60a0e040, 0x406080a0, 0x1f21c2e3, 0xe31fdd21, 0xc8433a79, 0x79c8f243, 0xed2c9ab6, 0xb6ed772c
|
|
16
|
+
, 0xbed90dd4, 0xd4beb3d9, 0x46ca478d, 0x8d4601ca, 0xd9701767, 0x67d9ce70, 0x4bddaf72, 0x724be4dd, 0xde79ed94, 0x94de3379, 0xd467ff98, 0x98d42b67, 0xe82393b0, 0xb0e87b23, 0x4ade5b85, 0x854a11de
|
|
17
|
+
, 0x6bbd06bb, 0xbb6b6dbd, 0x2a7ebbc5, 0xc52a917e, 0xe5347b4f, 0x4fe59e34, 0x163ad7ed, 0xed16c13a, 0xc554d286, 0x86c51754, 0xd762f89a, 0x9ad72f62, 0x55ff9966, 0x6655ccff, 0x94a7b611, 0x119422a7
|
|
18
|
+
, 0xcf4ac08a, 0x8acf0f4a, 0x1030d9e9, 0xe910c930, 0x60a0e04, 0x406080a, 0x819866fe, 0xfe81e798, 0xf00baba0, 0xa0f05b0b, 0x44ccb478, 0x7844f0cc, 0xbad5f025, 0x25ba4ad5, 0xe33e754b, 0x4be3963e
|
|
19
|
+
, 0xf30eaca2, 0xa2f35f0e, 0xfe19445d, 0x5dfeba19, 0xc05bdb80, 0x80c01b5b, 0x8a858005, 0x58a0a85, 0xadecd33f, 0x3fad7eec, 0xbcdffe21, 0x21bc42df, 0x48d8a870, 0x7048e0d8, 0x40cfdf1, 0xf104f90c
|
|
20
|
+
, 0xdf7a1963, 0x63dfc67a, 0xc1582f77, 0x77c1ee58, 0x759f30af, 0xaf75459f, 0x63a5e742, 0x426384a5, 0x30507020, 0x20304050, 0x1a2ecbe5, 0xe51ad12e, 0xe12effd, 0xfd0ee112, 0x6db708bf, 0xbf6d65b7
|
|
21
|
+
, 0x4cd45581, 0x814c19d4, 0x143c2418, 0x1814303c, 0x355f7926, 0x26354c5f, 0x2f71b2c3, 0xc32f9d71, 0xe13886be, 0xbee16738, 0xa2fdc835, 0x35a26afd, 0xcc4fc788, 0x88cc0b4f, 0x394b652e, 0x2e395c4b
|
|
22
|
+
, 0x57f96a93, 0x93573df9, 0xf20d5855, 0x55f2aa0d, 0x829d61fc, 0xfc82e39d, 0x47c9b37a, 0x7a47f4c9, 0xacef27c8, 0xc8ac8bef, 0xe73288ba, 0xbae76f32, 0x2b7d4f32, 0x322b647d, 0x95a442e6, 0xe695d7a4
|
|
23
|
+
, 0xa0fb3bc0, 0xc0a09bfb, 0x98b3aa19, 0x199832b3, 0xd168f69e, 0x9ed12768, 0x7f8122a3, 0xa37f5d81, 0x66aaee44, 0x446688aa, 0x7e82d654, 0x547ea882, 0xabe6dd3b, 0x3bab76e6, 0x839e950b, 0xb83169e
|
|
24
|
+
, 0xca45c98c, 0x8cca0345, 0x297bbcc7, 0xc729957b, 0xd36e056b, 0x6bd3d66e, 0x3c446c28, 0x283c5044, 0x798b2ca7, 0xa779558b, 0xe23d81bc, 0xbce2633d, 0x1d273116, 0x161d2c27, 0x769a37ad, 0xad76419a
|
|
25
|
+
, 0x3b4d96db, 0xdb3bad4d, 0x56fa9e64, 0x6456c8fa, 0x4ed2a674, 0x744ee8d2, 0x1e223614, 0x141e2822, 0xdb76e492, 0x92db3f76, 0xa1e120c, 0xc0a181e, 0x6cb4fc48, 0x486c90b4, 0xe4378fb8, 0xb8e46b37
|
|
26
|
+
, 0x5de7789f, 0x9f5d25e7, 0x6eb20fbd, 0xbd6e61b2, 0xef2a6943, 0x43ef862a, 0xa6f135c4, 0xc4a693f1, 0xa8e3da39, 0x39a872e3, 0xa4f7c631, 0x31a462f7, 0x37598ad3, 0xd337bd59, 0x8b8674f2, 0xf28bff86
|
|
27
|
+
, 0x325683d5, 0xd532b156, 0x43c54e8b, 0x8b430dc5, 0x59eb856e, 0x6e59dceb, 0xb7c218da, 0xdab7afc2, 0x8c8f8e01, 0x18c028f, 0x64ac1db1, 0xb16479ac, 0xd26df19c, 0x9cd2236d, 0xe03b7249, 0x49e0923b
|
|
28
|
+
, 0xb4c71fd8, 0xd8b4abc7, 0xfa15b9ac, 0xacfa4315, 0x709faf3, 0xf307fd09, 0x256fa0cf, 0xcf25856f, 0xafea20ca, 0xcaaf8fea, 0x8e897df4, 0xf48ef389, 0xe9206747, 0x47e98e20, 0x18283810, 0x10182028
|
|
29
|
+
, 0xd5640b6f, 0x6fd5de64, 0x888373f0, 0xf088fb83, 0x6fb1fb4a, 0x4a6f94b1, 0x7296ca5c, 0x5c72b896, 0x246c5438, 0x3824706c, 0xf1085f57, 0x57f1ae08, 0xc7522173, 0x73c7e652, 0x51f36497, 0x975135f3
|
|
30
|
+
, 0x2365aecb, 0xcb238d65, 0x7c8425a1, 0xa17c5984, 0x9cbf57e8, 0xe89ccbbf, 0x21635d3e, 0x3e217c63, 0xdd7cea96, 0x96dd377c, 0xdc7f1e61, 0x61dcc27f, 0x86919c0d, 0xd861a91, 0x85949b0f, 0xf851e94
|
|
31
|
+
, 0x90ab4be0, 0xe090dbab, 0x42c6ba7c, 0x7c42f8c6, 0xc4572671, 0x71c4e257, 0xaae529cc, 0xccaa83e5, 0xd873e390, 0x90d83b73, 0x50f0906, 0x6050c0f, 0x103f4f7, 0xf701f503, 0x12362a1c, 0x1c123836
|
|
32
|
+
, 0xa3fe3cc2, 0xc2a39ffe, 0x5fe18b6a, 0x6a5fd4e1, 0xf910beae, 0xaef94710, 0xd06b0269, 0x69d0d26b, 0x91a8bf17, 0x17912ea8, 0x58e87199, 0x995829e8, 0x2769533a, 0x3a277469, 0xb9d0f727, 0x27b94ed0
|
|
33
|
+
, 0x384891d9, 0xd938a948, 0x1335deeb, 0xeb13cd35, 0xb3cee52b, 0x2bb356ce, 0x33557722, 0x22334455, 0xbbd604d2, 0xd2bbbfd6, 0x709039a9, 0xa9704990, 0x89808707, 0x7890e80, 0xa7f2c133, 0x33a766f2
|
|
34
|
+
, 0xb6c1ec2d, 0x2db65ac1, 0x22665a3c, 0x3c227866, 0x92adb815, 0x15922aad, 0x2060a9c9, 0xc9208960, 0x49db5c87, 0x874915db, 0xff1ab0aa, 0xaaff4f1a, 0x7888d850, 0x5078a088, 0x7a8e2ba5, 0xa57a518e
|
|
35
|
+
, 0x8f8a8903, 0x38f068a, 0xf8134a59, 0x59f8b213, 0x809b9209, 0x980129b, 0x1739231a, 0x1a173439, 0xda751065, 0x65daca75, 0x315384d7, 0xd731b553, 0xc651d584, 0x84c61351, 0xb8d303d0, 0xd0b8bbd3
|
|
36
|
+
, 0xc35edc82, 0x82c31f5e, 0xb0cbe229, 0x29b052cb, 0x7799c35a, 0x5a77b499, 0x11332d1e, 0x1e113c33, 0xcb463d7b, 0x7bcbf646, 0xfc1fb7a8, 0xa8fc4b1f, 0xd6610c6d, 0x6dd6da61, 0x3a4e622c, 0x2c3a584e};
|
|
37
|
+
|
|
38
|
+
#endif /* __tables_h */
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#if !defined(__cplusplus)
|
|
8
|
+
|
|
9
|
+
#include <assert.h>
|
|
10
|
+
#include <stdbool.h>
|
|
11
|
+
#include <stddef.h>
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
|
|
14
|
+
#include "int-util.h"
|
|
15
|
+
|
|
16
|
+
static inline void *padd(void *p, size_t i) {
|
|
17
|
+
return (char *) p + i;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static inline const void *cpadd(const void *p, size_t i) {
|
|
21
|
+
return (const char *) p + i;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) {
|
|
25
|
+
if (sizeof(size_t) == 4) {
|
|
26
|
+
*(uint32_t *) padd(buffer, bufsize - 4) = swap32be(length);
|
|
27
|
+
} else {
|
|
28
|
+
*(uint64_t *) padd(buffer, bufsize - 8) = swap64be(length);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#pragma pack(push, 1)
|
|
33
|
+
union hash_state {
|
|
34
|
+
uint8_t b[200];
|
|
35
|
+
uint64_t w[25];
|
|
36
|
+
};
|
|
37
|
+
#pragma pack(pop)
|
|
38
|
+
|
|
39
|
+
void hash_permutation(union hash_state *state);
|
|
40
|
+
void hash_process(union hash_state *state, const uint8_t *buf, size_t count);
|
|
41
|
+
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
enum {
|
|
45
|
+
HASH_SIZE = 32,
|
|
46
|
+
HASH_DATA_AREA = 136
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
void cn_fast_hash(const void *data, size_t length, char *hash);
|
|
50
|
+
void cn_slow_hash(const void *data, size_t length, char *hash);
|
|
51
|
+
|
|
52
|
+
void hash_extra_blake(const void *data, size_t length, char *hash);
|
|
53
|
+
void hash_extra_groestl(const void *data, size_t length, char *hash);
|
|
54
|
+
void hash_extra_jh(const void *data, size_t length, char *hash);
|
|
55
|
+
void hash_extra_skein(const void *data, size_t length, char *hash);
|
|
56
|
+
|
|
57
|
+
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);
|
package/crypto/hash.c
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#include <stddef.h>
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
|
|
9
|
+
#include "hash-ops.h"
|
|
10
|
+
#include "c_keccak.h"
|
|
11
|
+
|
|
12
|
+
void hash_permutation(union hash_state *state) {
|
|
13
|
+
keccakf((uint64_t*)state, 24);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void hash_process(union hash_state *state, const uint8_t *buf, size_t count) {
|
|
17
|
+
keccak1600(buf, count, (uint8_t*)state);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void cn_fast_hash(const void *data, size_t length, char *hash) {
|
|
21
|
+
union hash_state state;
|
|
22
|
+
hash_process(&state, data, length);
|
|
23
|
+
memcpy(hash, &state, HASH_SIZE);
|
|
24
|
+
}
|
package/crypto/hash.h
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "hash-ops.h"
|
|
4
|
+
|
|
5
|
+
typedef unsigned char BitSequence;
|
|
6
|
+
typedef unsigned long long DataLength;
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
|
|
12
|
+
typedef std::string blobdata;
|
|
13
|
+
|
|
14
|
+
namespace crypto {
|
|
15
|
+
#pragma pack(push, 1)
|
|
16
|
+
class hash {
|
|
17
|
+
char data[HASH_SIZE];
|
|
18
|
+
};
|
|
19
|
+
#pragma pack(pop)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#endif
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <assert.h>
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Create GNU compatible endian macros. We use the values for __LITTLE_ENDIAN
|
|
14
|
+
* and __BIG_ENDIAN based on endian.h.
|
|
15
|
+
*/
|
|
16
|
+
#ifdef __sun
|
|
17
|
+
#include <sys/byteorder.h>
|
|
18
|
+
#define LITTLE_ENDIAN 1234
|
|
19
|
+
#define BIG_ENDIAN 4321
|
|
20
|
+
#ifdef _LITTLE_ENDIAN
|
|
21
|
+
#define BYTE_ORDER LITTLE_ENDIAN
|
|
22
|
+
#else
|
|
23
|
+
#define BYTE_ORDER BIG_ENDIAN
|
|
24
|
+
#endif /* _LITTLE_ENDIAN */
|
|
25
|
+
#endif /* __sun */
|
|
26
|
+
|
|
27
|
+
#if defined(_MSC_VER)
|
|
28
|
+
#include <stdlib.h>
|
|
29
|
+
|
|
30
|
+
//instead of #include <sys/param.h>
|
|
31
|
+
// assume little-endian on Windows
|
|
32
|
+
#define LITTLE_ENDIAN 1234
|
|
33
|
+
#define BIG_ENDIAN 4321
|
|
34
|
+
#define BYTE_ORDER LITTLE_ENDIAN
|
|
35
|
+
|
|
36
|
+
static inline uint32_t rol32(uint32_t x, int r) {
|
|
37
|
+
static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers");
|
|
38
|
+
return _rotl(x, r);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static inline uint64_t rol64(uint64_t x, int r) {
|
|
42
|
+
return _rotl64(x, r);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#else
|
|
46
|
+
#include <sys/param.h>
|
|
47
|
+
|
|
48
|
+
static inline uint32_t rol32(uint32_t x, int r) {
|
|
49
|
+
return (x << (r & 31)) | (x >> (-r & 31));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static inline uint64_t rol64(uint64_t x, int r) {
|
|
53
|
+
return (x << (r & 63)) | (x >> (-r & 63));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
static inline uint64_t hi_dword(uint64_t val) {
|
|
59
|
+
return val >> 32;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static inline uint64_t lo_dword(uint64_t val) {
|
|
63
|
+
return val & 0xFFFFFFFF;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi) {
|
|
67
|
+
// multiplier = ab = a * 2^32 + b
|
|
68
|
+
// multiplicand = cd = c * 2^32 + d
|
|
69
|
+
// ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d
|
|
70
|
+
uint64_t a = hi_dword(multiplier);
|
|
71
|
+
uint64_t b = lo_dword(multiplier);
|
|
72
|
+
uint64_t c = hi_dword(multiplicand);
|
|
73
|
+
uint64_t d = lo_dword(multiplicand);
|
|
74
|
+
|
|
75
|
+
uint64_t ac = a * c;
|
|
76
|
+
uint64_t ad = a * d;
|
|
77
|
+
uint64_t bc = b * c;
|
|
78
|
+
uint64_t bd = b * d;
|
|
79
|
+
|
|
80
|
+
uint64_t adbc = ad + bc;
|
|
81
|
+
uint64_t adbc_carry = adbc < ad ? 1 : 0;
|
|
82
|
+
|
|
83
|
+
// multiplier * multiplicand = product_hi * 2^64 + product_lo
|
|
84
|
+
uint64_t product_lo = bd + (adbc << 32);
|
|
85
|
+
uint64_t product_lo_carry = product_lo < bd ? 1 : 0;
|
|
86
|
+
*product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;
|
|
87
|
+
assert(ac <= *product_hi);
|
|
88
|
+
|
|
89
|
+
return product_lo;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t* remainder) {
|
|
93
|
+
dividend |= ((uint64_t)*remainder) << 32;
|
|
94
|
+
*remainder = dividend % divisor;
|
|
95
|
+
return dividend / divisor;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Long division with 2^32 base
|
|
99
|
+
static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t* quotient_hi, uint64_t* quotient_lo) {
|
|
100
|
+
uint64_t dividend_dwords[4];
|
|
101
|
+
uint32_t remainder = 0;
|
|
102
|
+
|
|
103
|
+
dividend_dwords[3] = hi_dword(dividend_hi);
|
|
104
|
+
dividend_dwords[2] = lo_dword(dividend_hi);
|
|
105
|
+
dividend_dwords[1] = hi_dword(dividend_lo);
|
|
106
|
+
dividend_dwords[0] = lo_dword(dividend_lo);
|
|
107
|
+
|
|
108
|
+
*quotient_hi = div_with_reminder(dividend_dwords[3], divisor, &remainder) << 32;
|
|
109
|
+
*quotient_hi |= div_with_reminder(dividend_dwords[2], divisor, &remainder);
|
|
110
|
+
*quotient_lo = div_with_reminder(dividend_dwords[1], divisor, &remainder) << 32;
|
|
111
|
+
*quotient_lo |= div_with_reminder(dividend_dwords[0], divisor, &remainder);
|
|
112
|
+
|
|
113
|
+
return remainder;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#define IDENT32(x) ((uint32_t) (x))
|
|
117
|
+
#define IDENT64(x) ((uint64_t) (x))
|
|
118
|
+
|
|
119
|
+
#define SWAP32(x) ((((uint32_t) (x) & 0x000000ff) << 24) | \
|
|
120
|
+
(((uint32_t) (x) & 0x0000ff00) << 8) | \
|
|
121
|
+
(((uint32_t) (x) & 0x00ff0000) >> 8) | \
|
|
122
|
+
(((uint32_t) (x) & 0xff000000) >> 24))
|
|
123
|
+
#define SWAP64(x) ((((uint64_t) (x) & 0x00000000000000ff) << 56) | \
|
|
124
|
+
(((uint64_t) (x) & 0x000000000000ff00) << 40) | \
|
|
125
|
+
(((uint64_t) (x) & 0x0000000000ff0000) << 24) | \
|
|
126
|
+
(((uint64_t) (x) & 0x00000000ff000000) << 8) | \
|
|
127
|
+
(((uint64_t) (x) & 0x000000ff00000000) >> 8) | \
|
|
128
|
+
(((uint64_t) (x) & 0x0000ff0000000000) >> 24) | \
|
|
129
|
+
(((uint64_t) (x) & 0x00ff000000000000) >> 40) | \
|
|
130
|
+
(((uint64_t) (x) & 0xff00000000000000) >> 56))
|
|
131
|
+
|
|
132
|
+
static inline uint32_t ident32(uint32_t x) { return x; }
|
|
133
|
+
static inline uint64_t ident64(uint64_t x) { return x; }
|
|
134
|
+
|
|
135
|
+
static inline uint32_t swap32(uint32_t x) {
|
|
136
|
+
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
|
|
137
|
+
return (x << 16) | (x >> 16);
|
|
138
|
+
}
|
|
139
|
+
static inline uint64_t swap64(uint64_t x) {
|
|
140
|
+
x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8);
|
|
141
|
+
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
|
|
142
|
+
return (x << 32) | (x >> 32);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#if defined(__GNUC__)
|
|
146
|
+
#define UNUSED __attribute__((unused))
|
|
147
|
+
#else
|
|
148
|
+
#define UNUSED
|
|
149
|
+
#endif
|
|
150
|
+
static inline void mem_inplace_ident(void *mem UNUSED, size_t n UNUSED) { }
|
|
151
|
+
#undef UNUSED
|
|
152
|
+
|
|
153
|
+
static inline void mem_inplace_swap32(void *mem, size_t n) {
|
|
154
|
+
size_t i;
|
|
155
|
+
for (i = 0; i < n; i++) {
|
|
156
|
+
((uint32_t *) mem)[i] = swap32(((const uint32_t *) mem)[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
static inline void mem_inplace_swap64(void *mem, size_t n) {
|
|
160
|
+
size_t i;
|
|
161
|
+
for (i = 0; i < n; i++) {
|
|
162
|
+
((uint64_t *) mem)[i] = swap64(((const uint64_t *) mem)[i]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static inline void memcpy_ident32(void *dst, const void *src, size_t n) {
|
|
167
|
+
memcpy(dst, src, 4 * n);
|
|
168
|
+
}
|
|
169
|
+
static inline void memcpy_ident64(void *dst, const void *src, size_t n) {
|
|
170
|
+
memcpy(dst, src, 8 * n);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static inline void memcpy_swap32(void *dst, const void *src, size_t n) {
|
|
174
|
+
size_t i;
|
|
175
|
+
for (i = 0; i < n; i++) {
|
|
176
|
+
((uint32_t *) dst)[i] = swap32(((const uint32_t *) src)[i]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
|
|
180
|
+
size_t i;
|
|
181
|
+
for (i = 0; i < n; i++) {
|
|
182
|
+
((uint64_t *) dst)[i] = swap64(((const uint64_t *) src)[i]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
|
|
187
|
+
#if __STDC_VERSION__ - 0 >= 201112L
|
|
188
|
+
static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
|
|
189
|
+
#else
|
|
190
|
+
#error "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled"
|
|
191
|
+
#endif
|
|
192
|
+
#endif
|
|
193
|
+
|
|
194
|
+
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
195
|
+
#define SWAP32LE IDENT32
|
|
196
|
+
#define SWAP32BE SWAP32
|
|
197
|
+
#define swap32le ident32
|
|
198
|
+
#define swap32be swap32
|
|
199
|
+
#define mem_inplace_swap32le mem_inplace_ident
|
|
200
|
+
#define mem_inplace_swap32be mem_inplace_swap32
|
|
201
|
+
#define memcpy_swap32le memcpy_ident32
|
|
202
|
+
#define memcpy_swap32be memcpy_swap32
|
|
203
|
+
#define SWAP64LE IDENT64
|
|
204
|
+
#define SWAP64BE SWAP64
|
|
205
|
+
#define swap64le ident64
|
|
206
|
+
#define swap64be swap64
|
|
207
|
+
#define mem_inplace_swap64le mem_inplace_ident
|
|
208
|
+
#define mem_inplace_swap64be mem_inplace_swap64
|
|
209
|
+
#define memcpy_swap64le memcpy_ident64
|
|
210
|
+
#define memcpy_swap64be memcpy_swap64
|
|
211
|
+
#endif
|
|
212
|
+
|
|
213
|
+
#if BYTE_ORDER == BIG_ENDIAN
|
|
214
|
+
#define SWAP32BE IDENT32
|
|
215
|
+
#define SWAP32LE SWAP32
|
|
216
|
+
#define swap32be ident32
|
|
217
|
+
#define swap32le swap32
|
|
218
|
+
#define mem_inplace_swap32be mem_inplace_ident
|
|
219
|
+
#define mem_inplace_swap32le mem_inplace_swap32
|
|
220
|
+
#define memcpy_swap32be memcpy_ident32
|
|
221
|
+
#define memcpy_swap32le memcpy_swap32
|
|
222
|
+
#define SWAP64BE IDENT64
|
|
223
|
+
#define SWAP64LE SWAP64
|
|
224
|
+
#define swap64be ident64
|
|
225
|
+
#define swap64le swap64
|
|
226
|
+
#define mem_inplace_swap64be mem_inplace_ident
|
|
227
|
+
#define mem_inplace_swap64le mem_inplace_swap64
|
|
228
|
+
#define memcpy_swap64be memcpy_ident64
|
|
229
|
+
#define memcpy_swap64le memcpy_swap64
|
|
230
|
+
#endif
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ---------------------------------------------------------------------------
|
|
3
|
+
* OpenAES License
|
|
4
|
+
* ---------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* - Redistributions of source code must retain the above copyright notice,
|
|
12
|
+
* this list of conditions and the following disclaimer.
|
|
13
|
+
* - Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
21
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
* ---------------------------------------------------------------------------
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
#ifndef _OAES_CONFIG_H
|
|
32
|
+
#define _OAES_CONFIG_H
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
extern "C" {
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
//#ifndef OAES_HAVE_ISAAC
|
|
39
|
+
//#define OAES_HAVE_ISAAC 1
|
|
40
|
+
//#endif // OAES_HAVE_ISAAC
|
|
41
|
+
|
|
42
|
+
//#ifndef OAES_DEBUG
|
|
43
|
+
//#define OAES_DEBUG 0
|
|
44
|
+
//#endif // OAES_DEBUG
|
|
45
|
+
|
|
46
|
+
#ifdef __cplusplus
|
|
47
|
+
}
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#endif // _OAES_CONFIG_H
|