Bitcoin Core  22.99.0
P2P Digital Currency
crypto_poly1305.cpp
Go to the documentation of this file.
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>
7 #include <test/fuzz/fuzz.h>
8 #include <test/fuzz/util.h>
9 
10 #include <cstdint>
11 #include <vector>
12 
13 FUZZ_TARGET(crypto_poly1305)
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 }
poly1305_auth
void poly1305_auth(unsigned char out[POLY1305_TAGLEN], const unsigned char *m, size_t inlen, const unsigned char key[POLY1305_KEYLEN])
Definition: poly1305.cpp:15
util.h
FUZZ_TARGET
FUZZ_TARGET(crypto_poly1305)
Definition: crypto_poly1305.cpp:13
poly1305.h
FuzzedDataProvider.h
ConsumeRandomLengthByteVector
std::vector< uint8_t > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
Definition: util.h:61
POLY1305_TAGLEN
#define POLY1305_TAGLEN
Definition: poly1305.h:12
POLY1305_KEYLEN
#define POLY1305_KEYLEN
Definition: poly1305.h:11
fuzz.h
FuzzedDataProvider
Definition: FuzzedDataProvider.h:31
ConsumeFixedLengthByteVector
std::vector< uint8_t > ConsumeFixedLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const size_t length) noexcept
Returns a byte vector of specified size regardless of the number of remaining bytes available from th...
Definition: util.h:230