49 unsigned mode = provider.ConsumeIntegral<
uint8_t>();
55 unsigned length = provider.ConsumeIntegralInRange<
unsigned>(0, (1 <<
length_bits) - 1);
58 auto plain = rng.
randbytes<std::byte>(length);
64 size_t split_index = provider.ConsumeIntegralInRange<
size_t>(1, length);
73 for (
size_t i = 0; i < length; ++i) {
81 unsigned key_position = provider.ConsumeIntegralInRange<
unsigned>(0, 31);
83 std::vector<std::byte>
bad_key = key;
93 unsigned damage_bit = provider.ConsumeIntegralInRange<
unsigned>(0, (cipher.size() +
aad.size()) * 8U - 1U);
104 size_t split_index = provider.ConsumeIntegralInRange<
size_t>(1, length);
122 auto key = provider.ConsumeBytes<std::byte>(32);
140 unsigned mode = provider.ConsumeIntegral<
uint8_t>();
146 unsigned length = provider.ConsumeIntegralInRange<
unsigned>(0, (1 <<
length_bits) - 1);
149 auto plain = rng.
randbytes<std::byte>(length);
154 size_t split_index = provider.ConsumeIntegralInRange<
size_t>(1, length);
164 unsigned key_position = provider.ConsumeIntegralInRange<
unsigned>(0, 31);
166 std::vector<std::byte>
bad_key = key;
177 unsigned damage_bit = provider.ConsumeIntegralInRange<
unsigned>(0, (cipher.size() +
aad.size()) * 8U - 1U);
189 size_t split_index = provider.ConsumeIntegralInRange<
size_t>(1, length);
The AEAD_CHACHA20_POLY1305 authenticated encryption algorithm from RFC8439 section 2....
ChaCha20::Nonce96 Nonce96
96-bit nonce type.
static constexpr unsigned EXPANSION
Expansion when encrypting.
Forward-secure wrapper around AEADChaCha20Poly1305.
static constexpr auto EXPANSION
Expansion when encrypting.
std::vector< T > ConsumeBytes(size_t num_bytes)
T ConsumeIntegralInRange(T min, T max)
std::vector< B > randbytes(size_t len) noexcept
Generate random bytes.
static constexpr void crypt_till_rekey(FSChaCha20Poly1305 &aead, int rekey_interval, bool encrypt)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.