diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-06-17 09:47:42 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-06-25 15:06:13 +0000 |
commit | ec86ca1aaae388cefa2da9904785cee2d550b3d1 (patch) | |
tree | 981b9ff7bdbd258a0e24f1a86497dde058221b9e /src/test/fuzz/crypto_poly1305.cpp | |
parent | 4cee53bba722a480ccd6472d2ffe9b0001394dd9 (diff) |
tests: Add fuzzing harness for poly1305_auth(...)
Diffstat (limited to 'src/test/fuzz/crypto_poly1305.cpp')
-rw-r--r-- | src/test/fuzz/crypto_poly1305.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/fuzz/crypto_poly1305.cpp b/src/test/fuzz/crypto_poly1305.cpp new file mode 100644 index 0000000000..5681e6a693 --- /dev/null +++ b/src/test/fuzz/crypto_poly1305.cpp @@ -0,0 +1,22 @@ +// 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/poly1305.h> +#include <test/fuzz/FuzzedDataProvider.h> +#include <test/fuzz/fuzz.h> +#include <test/fuzz/util.h> + +#include <cstdint> +#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> key = ConsumeFixedLengthByteVector(fuzzed_data_provider, POLY1305_KEYLEN); + const std::vector<uint8_t> in = ConsumeRandomLengthByteVector(fuzzed_data_provider); + + std::vector<uint8_t> tag_out(POLY1305_TAGLEN); + poly1305_auth(tag_out.data(), in.data(), in.size(), key.data()); +} |