Botan  1.10.9
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::EAX_Encryption Class Reference

#include <eax.h>

Inheritance diagram for Botan::EAX_Encryption:
Botan::EAX_Base Botan::Keyed_Filter Botan::Filter

Public Member Functions

virtual bool attachable ()
 
 EAX_Encryption (BlockCipher *ciph, size_t tag_size=0)
 
 EAX_Encryption (BlockCipher *ciph, const SymmetricKey &key, const InitializationVector &iv, size_t tag_size)
 
std::string name () const
 
void set_header (const byte header[], size_t header_len)
 
void set_iv (const InitializationVector &iv)
 
void set_key (const SymmetricKey &key)
 
bool valid_iv_length (size_t) const
 
bool valid_keylength (size_t key_len) const
 

Protected Member Functions

void send (const byte in[], size_t length)
 
void send (byte in)
 
void send (const MemoryRegion< byte > &in)
 
void send (const MemoryRegion< byte > &in, size_t length)
 
void start_msg ()
 

Protected Attributes

const size_t BLOCK_SIZE
 
std::string cipher_name
 
MessageAuthenticationCodecmac
 
StreamCipherctr
 
SecureVector< bytectr_buf
 
SecureVector< byteheader_mac
 
SecureVector< bytenonce_mac
 
const size_t TAG_SIZE
 

Detailed Description

EAX Encryption

Definition at line 100 of file eax.h.

Constructor & Destructor Documentation

Botan::EAX_Encryption::EAX_Encryption ( BlockCipher ciph,
size_t  tag_size = 0 
)
inline
Parameters
ciphthe cipher to use
tag_sizeis how big the auth tag will be

Definition at line 107 of file eax.h.

107  :
108  EAX_Base(ciph, tag_size) {}
EAX_Base(BlockCipher *cipher, size_t tag_size)
Definition: eax.cpp:38
Botan::EAX_Encryption::EAX_Encryption ( BlockCipher ciph,
const SymmetricKey key,
const InitializationVector iv,
size_t  tag_size 
)
inline
Parameters
ciphthe cipher to use
keythe key to use
ivthe initially set IV
tag_sizeis how big the auth tag will be

Definition at line 116 of file eax.h.

118  : EAX_Base(ciph, tag_size)
119  {
120  set_key(key);
121  set_iv(iv);
122  }
void set_iv(const InitializationVector &iv)
Definition: eax.cpp:89
EAX_Base(BlockCipher *cipher, size_t tag_size)
Definition: eax.cpp:38
void set_key(const SymmetricKey &key)
Definition: eax.cpp:64

Member Function Documentation

virtual bool Botan::Filter::attachable ( )
inlinevirtualinherited

Check whether this filter is an attachable filter.

Returns
true if this filter is attachable, false otherwise

Reimplemented in Botan::SecureQueue, and Botan::DataSink.

Definition at line 50 of file filter.h.

50 { return true; }
std::string Botan::EAX_Base::name ( ) const
virtualinherited
Returns
name of this mode

Implements Botan::Filter.

Definition at line 106 of file eax.cpp.

References Botan::EAX_Base::cipher_name.

Referenced by Botan::EAX_Base::EAX_Base().

107  {
108  return (cipher_name + "/EAX");
109  }
std::string cipher_name
Definition: eax.h:69
void Botan::Filter::send ( const byte  in[],
size_t  length 
)
protectedinherited
Parameters
insome input for the filter
lengththe length of in

Definition at line 28 of file filter.cpp.

References Botan::MemoryRegion< T >::clear(), Botan::MemoryRegion< T >::size(), and Botan::Filter::write().

Referenced by Botan::PK_Encryptor_Filter::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Zlib_Decompression::end_msg(), Botan::PK_Signer_Filter::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::Hash_Filter::end_msg(), Botan::MAC_Filter::end_msg(), Botan::Bzip_Compression::flush(), Botan::Zlib_Compression::flush(), Botan::Zlib_Compression::write(), Botan::Bzip_Compression::write(), Botan::StreamCipher_Filter::write(), Botan::Bzip_Decompression::write(), Botan::Zlib_Decompression::write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

29  {
30  bool nothing_attached = true;
31  for(size_t j = 0; j != total_ports(); ++j)
32  if(next[j])
33  {
34  if(write_queue.size())
35  next[j]->write(&write_queue[0], write_queue.size());
36  next[j]->write(input, length);
37  nothing_attached = false;
38  }
39 
40  if(nothing_attached)
41  write_queue += std::make_pair(input, length);
42  else
43  write_queue.clear();
44  }
virtual void write(const byte input[], size_t length)=0
size_t size() const
Definition: secmem.h:29
void Botan::Filter::send ( byte  in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 63 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

63 { send(&in, 1); }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::Filter::send ( const MemoryRegion< byte > &  in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 68 of file filter.h.

References Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::Filter::send().

68 { send(&in[0], in.size()); }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
size_t size() const
Definition: secmem.h:29
void Botan::Filter::send ( const MemoryRegion< byte > &  in,
size_t  length 
)
inlineprotectedinherited
Parameters
insome input for the filter
lengththe number of bytes of in to send

Definition at line 74 of file filter.h.

75  {
76  send(&in[0], length);
77  }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::EAX_Base::set_header ( const byte  header[],
size_t  header_len 
)
inherited

Set some additional data that is not included in the ciphertext but that will be authenticated.

Parameters
headerthe header contents
header_lenlength of header in bytes

Definition at line 98 of file eax.cpp.

References Botan::EAX_Base::cmac, and Botan::EAX_Base::header_mac.

99  {
100  header_mac = eax_prf(1, BLOCK_SIZE, cmac, header, length);
101  }
SecureVector< byte > header_mac
Definition: eax.h:89
MessageAuthenticationCode * cmac
Definition: eax.h:79
const size_t BLOCK_SIZE
Definition: eax.h:59
void Botan::EAX_Base::set_iv ( const InitializationVector iv)
virtualinherited

Set the initialization vector of this filter. Note: you should call set_iv() only after you have called set_key()

Parameters
ivthe initialization vector to use

Reimplemented from Botan::Keyed_Filter.

Definition at line 89 of file eax.cpp.

References Botan::OctetString::begin(), Botan::EAX_Base::cmac, Botan::EAX_Base::ctr, Botan::OctetString::length(), Botan::EAX_Base::nonce_mac, Botan::StreamCipher::set_iv(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::EAX_Decryption::EAX_Decryption().

90  {
91  nonce_mac = eax_prf(0, BLOCK_SIZE, cmac, iv.begin(), iv.length());
93  }
virtual void set_iv(const byte iv[], size_t iv_len)
StreamCipher * ctr
Definition: eax.h:74
MessageAuthenticationCode * cmac
Definition: eax.h:79
size_t size() const
Definition: secmem.h:29
const size_t BLOCK_SIZE
Definition: eax.h:59
SecureVector< byte > nonce_mac
Definition: eax.h:84
void Botan::EAX_Base::set_key ( const SymmetricKey key)
virtualinherited

Set the key of this filter

Parameters
keythe key to use

Implements Botan::Keyed_Filter.

Definition at line 64 of file eax.cpp.

References Botan::EAX_Base::cmac, Botan::EAX_Base::ctr, Botan::EAX_Base::header_mac, and Botan::SymmetricAlgorithm::set_key().

Referenced by Botan::EAX_Decryption::EAX_Decryption().

65  {
66  /*
67  * These could share the key schedule, which is one nice part of EAX,
68  * but it's much easier to ignore that here...
69  */
70  ctr->set_key(key);
71  cmac->set_key(key);
72 
73  header_mac = eax_prf(1, BLOCK_SIZE, cmac, 0, 0);
74  }
StreamCipher * ctr
Definition: eax.h:74
SecureVector< byte > header_mac
Definition: eax.h:89
MessageAuthenticationCode * cmac
Definition: eax.h:79
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:60
const size_t BLOCK_SIZE
Definition: eax.h:59
void Botan::EAX_Base::start_msg ( )
protectedvirtualinherited

Start a new message. Must be closed by end_msg() before another message can be started.

Reimplemented from Botan::Filter.

Definition at line 79 of file eax.cpp.

References Botan::EAX_Base::cmac, and Botan::Buffered_Computation::update().

80  {
81  for(size_t i = 0; i != BLOCK_SIZE - 1; ++i)
82  cmac->update(0);
83  cmac->update(2);
84  }
MessageAuthenticationCode * cmac
Definition: eax.h:79
void update(const byte in[], size_t length)
Definition: buf_comp.h:33
const size_t BLOCK_SIZE
Definition: eax.h:59
bool Botan::EAX_Base::valid_iv_length ( size_t  ) const
inlinevirtualinherited

EAX supports arbitrary IV lengths

Reimplemented from Botan::Keyed_Filter.

Definition at line 45 of file eax.h.

45 { return true; }
bool Botan::EAX_Base::valid_keylength ( size_t  length) const
virtualinherited

Check whether a key length is valid for this filter

Parameters
lengththe key length to be checked for validity
Returns
true if the key length is valid, false otherwise

Implements Botan::Keyed_Filter.

Definition at line 54 of file eax.cpp.

References Botan::EAX_Base::ctr, and Botan::SymmetricAlgorithm::valid_keylength().

55  {
56  if(!ctr->valid_keylength(n))
57  return false;
58  return true;
59  }
StreamCipher * ctr
Definition: eax.h:74
BigInt n
Definition: numthry.cpp:26
bool valid_keylength(size_t length) const
Definition: sym_algo.h:51

Member Data Documentation

const size_t Botan::EAX_Base::BLOCK_SIZE
protectedinherited

The block size of the underlying cipher

Definition at line 59 of file eax.h.

std::string Botan::EAX_Base::cipher_name
protectedinherited

The name of the cipher

Definition at line 69 of file eax.h.

Referenced by Botan::EAX_Base::name().

MessageAuthenticationCode* Botan::EAX_Base::cmac
protectedinherited
StreamCipher* Botan::EAX_Base::ctr
protectedinherited

The stream cipher (CTR mode)

Definition at line 74 of file eax.h.

Referenced by Botan::EAX_Base::EAX_Base(), Botan::EAX_Base::set_iv(), Botan::EAX_Base::set_key(), and Botan::EAX_Base::valid_keylength().

SecureVector<byte> Botan::EAX_Base::ctr_buf
protectedinherited

A buffer for CTR mode encryption

Definition at line 94 of file eax.h.

SecureVector<byte> Botan::EAX_Base::header_mac
protectedinherited

The MAC of the header

Definition at line 89 of file eax.h.

Referenced by Botan::EAX_Base::set_header(), and Botan::EAX_Base::set_key().

SecureVector<byte> Botan::EAX_Base::nonce_mac
protectedinherited

The MAC of the nonce

Definition at line 84 of file eax.h.

Referenced by Botan::EAX_Base::set_iv().

const size_t Botan::EAX_Base::TAG_SIZE
protectedinherited

The requested tag name

Definition at line 64 of file eax.h.

Referenced by Botan::EAX_Base::EAX_Base(), and Botan::EAX_Decryption::EAX_Decryption().


The documentation for this class was generated from the following files: