From 8f79831ab57b8fce48bb7b01fce86fac338755a5 Mon Sep 17 00:00:00 2001 From: stratospher <44024636+stratospher@users.noreply.github.com> Date: Fri, 17 Dec 2021 23:04:04 +0530 Subject: [PATCH] Refactor the chacha20 differential fuzz test --- src/test/fuzz/crypto_diff_fuzz_chacha20.cpp | 5 ++--- 1 file 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 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(0, 4096); @@ -325,6 +323,7 @@ FUZZ_TARGET(crypto_diff_fuzz_chacha20) chacha20.Crypt(input.data(), output.data(), input.size()); std::vector djb_output(integralInRange); ECRYPT_encrypt_bytes(&ctx, input.data(), djb_output.data(), input.size()); + assert(output == djb_output); }); } }