aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-12-18 10:08:58 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-12-18 10:09:01 +0100
commit98a2ddcd6ed01a38cd0dad7c1abc7023a60d3fd0 (patch)
treeffecf3619f82c7bc7b529830347357382c995db6
parentc06cda3e48e9826043ebc5790a7bb505bfbf368c (diff)
parent8f79831ab57b8fce48bb7b01fce86fac338755a5 (diff)
Merge bitcoin/bitcoin#23806: fuzz: follow up for #22704
8f79831ab57b8fce48bb7b01fce86fac338755a5 Refactor the chacha20 differential fuzz test (stratospher) Pull request description: This PR addresses [comments from #22704](https://github.com/bitcoin/bitcoin/pull/22704/files#discussion_r771510963) to make the following changes in `src/test/fuzz/crypto_diff_fuzz_chacha20.cpp`: - replace `memcmp()` with == - add a missing assert statement to compare the encrypted bytes Top commit has no ACKs. Tree-SHA512: 02338460fb3a89e732558bf00f3aebf8f04daba194e03ae0e3339bb2ff6ba35d06841452585b739047a29f8ec64f36b1b4ce2dfa39a08f6ad44a6a937e7b3acb
-rw-r--r--src/test/fuzz/crypto_diff_fuzz_chacha20.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/test/fuzz/crypto_diff_fuzz_chacha20.cpp b/src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
index 96681a121a..fcc96c6418 100644
--- a/src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
+++ b/src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
@@ -314,9 +314,7 @@ FUZZ_TARGET(crypto_diff_fuzz_chacha20)
chacha20.Keystream(output.data(), output.size());
std::vector<uint8_t> djb_output(integralInRange);
ECRYPT_keystream_bytes(&ctx, djb_output.data(), djb_output.size());
- if (output.data() != NULL && djb_output.data() != NULL) {
- assert(memcmp(output.data(), djb_output.data(), integralInRange) == 0);
- }
+ assert(output == djb_output);
},
[&] {
uint32_t integralInRange = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096);
@@ -325,6 +323,7 @@ FUZZ_TARGET(crypto_diff_fuzz_chacha20)
chacha20.Crypt(input.data(), output.data(), input.size());
std::vector<uint8_t> djb_output(integralInRange);
ECRYPT_encrypt_bytes(&ctx, input.data(), djb_output.data(), input.size());
+ assert(output == djb_output);
});
}
}