18    if (fuzzed_data_provider.ConsumeBool()) {
 
   19        const std::vector<unsigned char> key = 
ConsumeFixedLengthByteVector(fuzzed_data_provider, fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(16, 32));
 
   20        chacha20 = 
ChaCha20{key.data(), key.size()};
 
   22    while (fuzzed_data_provider.ConsumeBool()) {
 
   26                const std::vector<unsigned char> key = 
ConsumeFixedLengthByteVector(fuzzed_data_provider, fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(16, 32));
 
   27                chacha20.
SetKey(key.data(), key.size());
 
   30                chacha20.
SetIV(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
 
   33                chacha20.
Seek(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
 
   36                std::vector<uint8_t> output(fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 4096));
 
   37                chacha20.
Keystream(output.data(), output.size());
 
   40                std::vector<uint8_t> output(fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 4096));
 
   42                chacha20.
Crypt(input.data(), output.data(), input.size());
 
A class for ChaCha20 256-bit stream cipher developed by Daniel J.
void Keystream(unsigned char *c, size_t bytes)
outputs the keystream of size <bytes> into
void Crypt(const unsigned char *input, unsigned char *output, size_t bytes)
enciphers the message <input> of length <bytes> and write the enciphered representation into <output>...
void SetKey(const unsigned char *key, size_t keylen)
set key with flexible keylength; 256bit recommended */
FUZZ_TARGET(crypto_chacha20)
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
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...