Skip to content

Commit b111410

Browse files
committed
test: Add MuHash3072 fuzz test
1 parent c122527 commit b111410

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/test/fuzz/crypto.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <crypto/hmac_sha256.h>
66
#include <crypto/hmac_sha512.h>
7+
#include <crypto/muhash.h>
78
#include <crypto/ripemd160.h>
89
#include <crypto/sha1.h>
910
#include <crypto/sha256.h>
@@ -35,6 +36,7 @@ FUZZ_TARGET(crypto)
3536
CSHA512 sha512;
3637
SHA3_256 sha3;
3738
CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
39+
MuHash3072 muhash;
3840

3941
while (fuzzed_data_provider.ConsumeBool()) {
4042
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 2)) {
@@ -60,6 +62,12 @@ FUZZ_TARGET(crypto)
6062
(void)Hash(data);
6163
(void)Hash160(data);
6264
(void)sha512.Size();
65+
66+
if (fuzzed_data_provider.ConsumeBool()) {
67+
muhash *= MuHash3072(data);
68+
} else {
69+
muhash /= MuHash3072(data);
70+
}
6371
break;
6472
}
6573
case 1: {
@@ -70,10 +78,11 @@ FUZZ_TARGET(crypto)
7078
(void)sha256.Reset();
7179
(void)sha3.Reset();
7280
(void)sha512.Reset();
81+
muhash = MuHash3072();
7382
break;
7483
}
7584
case 2: {
76-
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 9)) {
85+
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 10)) {
7786
case 0: {
7887
data.resize(CHash160::OUTPUT_SIZE);
7988
hash160.Finalize(data);
@@ -124,6 +133,11 @@ FUZZ_TARGET(crypto)
124133
sha3.Finalize(data);
125134
break;
126135
}
136+
case 10: {
137+
uint256 out;
138+
muhash.Finalize(out);
139+
break;
140+
}
127141
}
128142
break;
129143
}

0 commit comments

Comments
 (0)