diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2020-07-01 16:13:01 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2020-12-21 19:57:33 +0100 |
commit | b111410914041b72961536c3e4037eba103a8085 (patch) | |
tree | a594eb7ffc6ca5f879ad5b2f09873ca9db4425b1 /src/test/fuzz/crypto.cpp | |
parent | c1225273857f9fa2e2276396e3f8b3ea48306df3 (diff) | |
download | bitcoin-b111410914041b72961536c3e4037eba103a8085.tar.xz |
test: Add MuHash3072 fuzz test
Diffstat (limited to 'src/test/fuzz/crypto.cpp')
-rw-r--r-- | src/test/fuzz/crypto.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/test/fuzz/crypto.cpp b/src/test/fuzz/crypto.cpp index 4783cc1c43..9668b84e7b 100644 --- a/src/test/fuzz/crypto.cpp +++ b/src/test/fuzz/crypto.cpp @@ -4,6 +4,7 @@ #include <crypto/hmac_sha256.h> #include <crypto/hmac_sha512.h> +#include <crypto/muhash.h> #include <crypto/ripemd160.h> #include <crypto/sha1.h> #include <crypto/sha256.h> @@ -35,6 +36,7 @@ FUZZ_TARGET(crypto) CSHA512 sha512; SHA3_256 sha3; CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()}; + MuHash3072 muhash; while (fuzzed_data_provider.ConsumeBool()) { switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 2)) { @@ -60,6 +62,12 @@ FUZZ_TARGET(crypto) (void)Hash(data); (void)Hash160(data); (void)sha512.Size(); + + if (fuzzed_data_provider.ConsumeBool()) { + muhash *= MuHash3072(data); + } else { + muhash /= MuHash3072(data); + } break; } case 1: { @@ -70,10 +78,11 @@ FUZZ_TARGET(crypto) (void)sha256.Reset(); (void)sha3.Reset(); (void)sha512.Reset(); + muhash = MuHash3072(); break; } case 2: { - switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 9)) { + switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 10)) { case 0: { data.resize(CHash160::OUTPUT_SIZE); hash160.Finalize(data); @@ -124,6 +133,11 @@ FUZZ_TARGET(crypto) sha3.Finalize(data); break; } + case 10: { + uint256 out; + muhash.Finalize(out); + break; + } } break; } |