9 #include <botan/internal/xor_buf.h>
10 #include <botan/parsing.h>
23 queue_start = queue_end = 0;
38 queue_start = queue_end = 0;
44 void EAX_Decryption::write(
const byte input[],
size_t length)
48 const size_t copied = std::min<size_t>(length, queue.
size() - queue_end);
50 queue.
copy(queue_end, input, copied);
55 while((queue_end - queue_start) >
TAG_SIZE)
57 size_t removed = (queue_end - queue_start) -
TAG_SIZE;
58 do_write(&queue[queue_start], removed);
59 queue_start += removed;
62 if(queue_start +
TAG_SIZE == queue_end &&
63 queue_start >= queue.
size() / 2)
65 SecureVector<byte> queue_data(
TAG_SIZE);
66 queue_data.copy(&queue[queue_start],
TAG_SIZE);
77 void EAX_Decryption::do_write(
const byte input[],
size_t length)
81 size_t copied = std::min<size_t>(length,
ctr_buf.
size());
98 void EAX_Decryption::end_msg()
100 if((queue_end - queue_start) !=
TAG_SIZE)
101 throw Decoding_Error(
name() +
": Message authentication failure");
103 const byte* included_mac = &queue[queue_start];
105 SecureVector<byte> computed_mac =
cmac->
final();
111 throw Decoding_Error(
name() +
": Message authentication failure");
113 queue_start = queue_end = 0;
void set_iv(const InitializationVector &iv)
EAX_Decryption(BlockCipher *ciph, size_t tag_size=0)
bool same_mem(const T *p1, const T *p2, size_t n)
SecureVector< byte > ctr_buf
SecureVector< byte > header_mac
MessageAuthenticationCode * cmac
void copy(const T in[], size_t n)
void send(const byte in[], size_t length)
void update(const byte in[], size_t length)
virtual void cipher(const byte in[], byte out[], size_t len)=0
void set_key(const SymmetricKey &key)
void xor_buf(byte out[], const byte in[], size_t length)
SecureVector< byte > nonce_mac