Merge bitcoin/bitcoin#23806: fuzz: follow up for #22704

8f79831ab5 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
pull/826/head
MarcoFalke 3 years ago
commit 98a2ddcd6e
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -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);
});
}
}

Loading…
Cancel
Save