25 uint64_t seqnr_payload = 0;
26 uint64_t seqnr_aad = 0;
28 size_t buffer_size = fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 4096);
31 bool is_encrypt = fuzzed_data_provider.ConsumeBool();
36 buffer_size = fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(64, 4096);
41 (void)
aead.
Crypt(seqnr_payload, seqnr_aad, aad_pos,
out.data(),
out.size(), in.data(), buffer_size, is_encrypt);
45 const bool ok =
aead.
GetLength(&len, seqnr_aad, aad_pos, in.data());
63 seqnr_payload = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
66 seqnr_aad = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
69 is_encrypt = fuzzed_data_provider.ConsumeBool();
static const unsigned char k1[32]
static ChaCha20Poly1305AEAD aead(k1, 32, k2, 32)
static const unsigned char k2[32]
static constexpr int CHACHA20_POLY1305_AEAD_KEY_LEN
static constexpr int CHACHA20_POLY1305_AEAD_AAD_LEN
static constexpr int CHACHA20_ROUND_OUTPUT
bool Crypt(uint64_t seqnr_payload, uint64_t seqnr_aad, int aad_pos, unsigned char *dest, size_t dest_len, const unsigned char *src, size_t src_len, bool is_encrypt)
Encrypts/decrypts a packet seqnr_payload, the message sequence number seqnr_aad, the messages AAD seq...
bool GetLength(uint32_t *len24_out, uint64_t seqnr_aad, int aad_pos, const uint8_t *ciphertext)
decrypts the 3 bytes AAD data and decodes it into a uint32_t field
static constexpr unsigned TAGLEN
Length of the output produced by Finalize().
FUZZ_TARGET(crypto_chacha20_poly1305_aead)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
bool AdditionOverflow(const T i, const T j) noexcept
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...
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)