9 #include <botan/chacha20poly1305.h>
23 return (n == 8 || n == 12);
40 void ChaCha20Poly1305_Mode::key_schedule(
const uint8_t key[],
size_t length)
48 throw Exception(
"Too late to set AD for ChaCha20Poly1305");
49 m_ad.assign(ad, ad + length);
54 uint8_t len8[8] = { 0 };
55 store_le(static_cast<uint64_t>(len), len8);
59 void ChaCha20Poly1305_Mode::start_msg(
const uint8_t nonce[],
size_t nonce_len)
81 const uint8_t zeros[16] = { 0 };
106 const uint8_t zeros[16] = { 0 };
114 buffer += std::make_pair(mac.data(),
tag_size());
128 BOTAN_ASSERT(buffer.size() >= offset,
"Offset is sane");
129 const size_t sz = buffer.size() - offset;
130 uint8_t* buf = buffer.data() + offset;
134 const size_t remaining = sz -
tag_size();
147 const uint8_t zeros[16] = { 0 };
156 const uint8_t* included_tag = &buf[remaining];
162 buffer.resize(offset + remaining);
size_t process(uint8_t buf[], size_t size) override
void finish(secure_vector< uint8_t > &final_block, size_t offset=0) override
bool same_mem(const T *p1, const T *p2, size_t n)
size_t process(uint8_t buf[], size_t size) override
std::unique_ptr< MessageAuthenticationCode > m_poly1305
void finish(secure_vector< uint8_t > &final_block, size_t offset=0) override
void update(secure_vector< uint8_t > &buffer, size_t offset=0)
std::unique_ptr< StreamCipher > m_chacha
#define BOTAN_ASSERT(expr, assertion_made)
std::vector< T, secure_allocator< T >> secure_vector
size_t tag_size() const override
secure_vector< uint8_t > m_ad
bool cfrg_version() const
void set_associated_data(const uint8_t ad[], size_t ad_len) override
void update_len(size_t len)
bool valid_nonce_length(size_t n) const override
std::string name() const override
void store_le(uint16_t in, uint8_t out[2])