1 // Copyright (c) 2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <crypto/poly1305.h>
6 #include <test/fuzz/FuzzedDataProvider.h>
7 #include <test/fuzz/fuzz.h>
8 #include <test/fuzz/util.h>
9 
10 #include <cstdint>
11 #include <vector>
12 
test_one_input(const std::vector<uint8_t> & buffer)13 void test_one_input(const std::vector<uint8_t>& buffer)
14 {
15     FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
16 
17     const std::vector<uint8_t> key = ConsumeFixedLengthByteVector(fuzzed_data_provider, POLY1305_KEYLEN);
18     const std::vector<uint8_t> in = ConsumeRandomLengthByteVector(fuzzed_data_provider);
19 
20     std::vector<uint8_t> tag_out(POLY1305_TAGLEN);
21     poly1305_auth(tag_out.data(), in.data(), in.size(), key.data());
22 }
23