Botan: Botan::EAX_Encryption Class Reference

Botan 1.10.17

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:

## 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
MessageAuthenticationCode * | cmac
StreamCipher * | ctr
SecureVector< byte > | ctr_buf
SecureVector< byte > | header_mac
SecureVector< byte > | nonce_mac
const size_t | TAG_SIZE

## Detailed Description

EAX Encryption

Definition at line 100 of file eax.h.

## Constructor & Destructor Documentation

## ◆ EAX_Encryption() [1/2]

Botan::EAX_Encryption::EAX_Encryption | ( | BlockCipher * | ciph,
|  | size_t | tag_size = `0`
| ) |  |
| inline

Parameters

  ciph | the cipher to use
  tag_size | is how big the auth tag will be

Definition at line 107 of file eax.h.

107 :
108 EAX_Base(ciph, tag_size) {}
Botan::EAX_Base::EAX_Base
EAX_Base(BlockCipher *cipher, size_t tag_size)
Definition: eax.cpp:38

## ◆ EAX_Encryption() [2/2]

Botan::EAX_Encryption::EAX_Encryption | ( | BlockCipher * | ciph,
|  | const SymmetricKey & | key,
|  | const InitializationVector & | iv,
|  | size_t | tag_size
| ) |  |
| inline

Parameters

  ciph | the cipher to use
  key | the key to use
  iv | the initially set IV
  tag_size | is 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 }
Botan::EAX_Base::set_iv
void set_iv(const InitializationVector &iv)
Definition: eax.cpp:89
Botan::EAX_Base::EAX_Base
EAX_Base(BlockCipher *cipher, size_t tag_size)
Definition: eax.cpp:38
Botan::EAX_Base::set_key
void set_key(const SymmetricKey &key)
Definition: eax.cpp:64

## Member Function Documentation

## ◆ attachable()

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; }

## ◆ name()

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.

107 {
108 return (cipher_name + "/EAX");
109 }
Botan::EAX_Base::cipher_name
std::string cipher_name
Definition: eax.h:69

## ◆ send() [1/4]

void Botan::Filter::send | ( | const byte | in[],
|  | size_t | length
| ) |  |
| protectedinherited

Parameters

  in | some input for the filter
  length | the 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 }
Botan::Filter::write
virtual void write(const byte input[], size_t length)=0
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:158
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

## ◆ send() [2/4]

void Botan::Filter::send | ( | byte | in | ) |
| inlineprotectedinherited

Parameters

  in | some 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); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28

## ◆ send() [3/4]

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in | ) |
| inlineprotectedinherited

Parameters

  in | some 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()); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

## ◆ send() [4/4]

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in,
|  | size_t | length
| ) |  |
| inlineprotectedinherited

Parameters

  in | some input for the filter
  length | the number of bytes of in to send

Definition at line 74 of file filter.h.

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

## ◆ set_header()

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

  header | the header contents
  header_len | length of header in bytes

Definition at line 98 of file eax.cpp.

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

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

## ◆ set_iv()

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

  iv | the initialization vector to use

Reimplemented from Botan::Keyed_Filter.

Definition at line 89 of file eax.cpp.

References Botan::OctetString::begin(), Botan::EAX_Base::BLOCK_SIZE, 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());
92 ctr->set_iv(&nonce_mac[0], nonce_mac.size());
93 }
Botan::StreamCipher::set_iv
virtual void set_iv(const byte iv[], size_t iv_len)
Definition: stream_cipher.cpp:12
Botan::EAX_Base::ctr
StreamCipher * ctr
Definition: eax.h:74
Botan::EAX_Base::cmac
MessageAuthenticationCode * cmac
Definition: eax.h:79
Botan::EAX_Base::BLOCK_SIZE
const size_t BLOCK_SIZE
Definition: eax.h:59
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::EAX_Base::nonce_mac
SecureVector< byte > nonce_mac
Definition: eax.h:84

## ◆ set_key()

void Botan::EAX_Base::set_key | ( | const SymmetricKey & | key | ) |
| virtualinherited

Set the key of this filter

Parameters

  key | the key to use

Implements Botan::Keyed_Filter.

Definition at line 64 of file eax.cpp.

References Botan::EAX_Base::BLOCK_SIZE, 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 }
Botan::EAX_Base::ctr
StreamCipher * ctr
Definition: eax.h:74
Botan::EAX_Base::header_mac
SecureVector< byte > header_mac
Definition: eax.h:89
Botan::EAX_Base::cmac
MessageAuthenticationCode * cmac
Definition: eax.h:79
Botan::SymmetricAlgorithm::set_key
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:60
Botan::EAX_Base::BLOCK_SIZE
const size_t BLOCK_SIZE
Definition: eax.h:59

## ◆ start_msg()

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::BLOCK_SIZE, 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 }
Botan::EAX_Base::cmac
MessageAuthenticationCode * cmac
Definition: eax.h:79
Botan::Buffered_Computation::update
void update(const byte in[], size_t length)
Definition: buf_comp.h:33
Botan::EAX_Base::BLOCK_SIZE
const size_t BLOCK_SIZE
Definition: eax.h:59

## ◆ valid_iv_length()

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; }

## ◆ valid_keylength()

bool Botan::EAX_Base::valid_keylength | ( | size_t | length | ) | const
| virtualinherited

Check whether a key length is valid for this filter

Parameters

  length | the 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.

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

## Member Data Documentation

## ◆ BLOCK_SIZE

const size_t Botan::EAX_Base::BLOCK_SIZE
| protectedinherited

The block size of the underlying cipher

Definition at line 59 of file eax.h.

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

## ◆ cipher_name

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().

## ◆ cmac

MessageAuthenticationCode* Botan::EAX_Base::cmac
| protectedinherited

The MAC (CMAC)

Definition at line 79 of file eax.h.

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

## ◆ ctr

StreamCipher* Botan::EAX_Base::ctr
| protectedinherited

The stream cipher (CTR mode)

Definition at line 74 of file eax.h.

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

## ◆ ctr_buf

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

A buffer for CTR mode encryption

Definition at line 94 of file eax.h.

## ◆ header_mac

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().

## ◆ nonce_mac

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().

## ◆ TAG_SIZE

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_Decryption::EAX_Decryption().

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

- src/filters/modes/eax/eax.h
- src/filters/modes/eax/eax.cpp