diff options
| author | practicalswift <[email protected]> | 2020-06-17 09:49:09 +0000 |
|---|---|---|
| committer | practicalswift <[email protected]> | 2020-06-25 15:06:13 +0000 |
| commit | e9e8aac029acffb5e4cc5c2556f23cdfdcf9bb09 (patch) | |
| tree | 4f0e490bbf197ab8038aaca7b589ad67d4f124f6 /src/test/fuzz | |
| parent | tests: Add fuzzing harness for poly1305_auth(...) (diff) | |
| download | discoin-e9e8aac029acffb5e4cc5c2556f23cdfdcf9bb09.tar.xz discoin-e9e8aac029acffb5e4cc5c2556f23cdfdcf9bb09.zip | |
tests: Add fuzzing harness for CHKDF_HMAC_SHA256_L32
Diffstat (limited to 'src/test/fuzz')
| -rw-r--r-- | src/test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp b/src/test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp new file mode 100644 index 000000000..e0a4e90c1 --- /dev/null +++ b/src/test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <crypto/hkdf_sha256_32.h> +#include <test/fuzz/FuzzedDataProvider.h> +#include <test/fuzz/fuzz.h> +#include <test/fuzz/util.h> + +#include <cstdint> +#include <string> +#include <vector> + +void test_one_input(const std::vector<uint8_t>& buffer) +{ + FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; + + const std::vector<uint8_t> initial_key_material = ConsumeRandomLengthByteVector(fuzzed_data_provider); + + CHKDF_HMAC_SHA256_L32 hkdf_hmac_sha256_l32(initial_key_material.data(), initial_key_material.size(), fuzzed_data_provider.ConsumeRandomLengthString(1024)); + while (fuzzed_data_provider.ConsumeBool()) { + std::vector<uint8_t> out(32); + hkdf_hmac_sha256_l32.Expand32(fuzzed_data_provider.ConsumeRandomLengthString(128), out.data()); + } +} |