Botan  1.11.10
Public Member Functions | Protected Member Functions | List of all members
Botan::MAC_Filter Class Reference

#include <filters.h>

Inheritance diagram for Botan::MAC_Filter:
Botan::Keyed_Filter Botan::Filter

Public Member Functions

virtual bool attachable ()
 
void end_msg ()
 
Key_Length_Specification key_spec () const override
 
 MAC_Filter (MessageAuthenticationCode *mac, size_t out_len=0)
 
 MAC_Filter (MessageAuthenticationCode *mac, const SymmetricKey &key, size_t out_len=0)
 
 MAC_Filter (const std::string &mac, size_t len=0)
 
 MAC_Filter (const std::string &mac, const SymmetricKey &key, size_t len=0)
 
std::string name () const
 
virtual void set_iv (const InitializationVector &iv)
 
void set_key (const SymmetricKey &key)
 
virtual void start_msg ()
 
virtual bool valid_iv_length (size_t length) const
 
bool valid_keylength (size_t length) const
 
void write (const byte input[], size_t len)
 

Protected Member Functions

virtual void send (const byte in[], size_t length)
 
void send (byte in)
 
void send (const secure_vector< byte > &in)
 
void send (const std::vector< byte > &in)
 
void send (const secure_vector< byte > &in, size_t length)
 
void send (const std::vector< byte > &in, size_t length)
 

Detailed Description

MessageAuthenticationCode Filter.

Definition at line 133 of file filters.h.

Constructor & Destructor Documentation

Botan::MAC_Filter::MAC_Filter ( MessageAuthenticationCode mac,
size_t  out_len = 0 
)
inline

Construct a MAC filter. The MAC key will be left empty.

Parameters
macthe MAC to use
out_lenthe output length of this filter. Leave the default value 0 if you want to use the full output of the MAC. Otherwise, specify a smaller value here so that the output of the MAC will be cut off.

Definition at line 157 of file filters.h.

158  :
159  OUTPUT_LENGTH(out_len),
160  m_mac(mac)
161  {
162  }
std::unique_ptr< MessageAuthenticationCode > mac
Definition: fpe_fe1.cpp:89
Botan::MAC_Filter::MAC_Filter ( MessageAuthenticationCode mac,
const SymmetricKey key,
size_t  out_len = 0 
)
inline

Construct a MAC filter.

Parameters
macthe MAC to use
keythe MAC key to use
out_lenthe output length of this filter. Leave the default value 0 if you want to use the full output of the MAC. Otherwise, specify a smaller value here so that the output of the MAC will be cut off.

Definition at line 173 of file filters.h.

175  :
176  OUTPUT_LENGTH(out_len),
177  m_mac(mac)
178  {
179  m_mac->set_key(key);
180  }
std::unique_ptr< MessageAuthenticationCode > mac
Definition: fpe_fe1.cpp:89
Botan::MAC_Filter::MAC_Filter ( const std::string &  mac,
size_t  len = 0 
)

Construct a MAC filter. The MAC key will be left empty.

Parameters
macthe name of the MAC to use
lenthe output length of this filter. Leave the default value 0 if you want to use the full output of the MAC. Otherwise, specify a smaller value here so that the output of the MAC will be cut off.

Definition at line 104 of file algo_filt.cpp.

References Botan::Library_State::algorithm_factory(), Botan::Global_State_Management::global_state(), and Botan::Algorithm_Factory::make_mac().

104  :
105  OUTPUT_LENGTH(len)
106  {
107  Algorithm_Factory& af = global_state().algorithm_factory();
108  m_mac.reset(af.make_mac(mac_name));
109  }
Algorithm_Factory & algorithm_factory() const
Definition: libstate.cpp:46
Library_State & global_state()
Botan::MAC_Filter::MAC_Filter ( const std::string &  mac,
const SymmetricKey key,
size_t  len = 0 
)

Construct a MAC filter.

Parameters
macthe name of the MAC to use
keythe MAC key to use
lenthe output length of this filter. Leave the default value 0 if you want to use the full output of the MAC. Otherwise, specify a smaller value here so that the output of the MAC will be cut off.

Definition at line 114 of file algo_filt.cpp.

References Botan::Library_State::algorithm_factory(), Botan::Global_State_Management::global_state(), and Botan::Algorithm_Factory::make_mac().

115  : OUTPUT_LENGTH(len)
116  {
117  Algorithm_Factory& af = global_state().algorithm_factory();
118  m_mac.reset(af.make_mac(mac_name));
119  m_mac->set_key(key);
120  }
Algorithm_Factory & algorithm_factory() const
Definition: libstate.cpp:46
Library_State & global_state()

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 52 of file filter.h.

52 { return true; }
void Botan::MAC_Filter::end_msg ( )
virtual

Notify that the current message is finished; flush buffers and do end-of-message processing (if any).

Reimplemented from Botan::Filter.

Definition at line 125 of file algo_filt.cpp.

References Botan::Filter::send().

126  {
127  secure_vector<byte> output = m_mac->final();
128  if(OUTPUT_LENGTH)
129  send(output, std::min<size_t>(OUTPUT_LENGTH, output.size()));
130  else
131  send(output);
132  }
virtual void send(const byte in[], size_t length)
Definition: filter.cpp:28
Key_Length_Specification Botan::MAC_Filter::key_spec ( ) const
inlineoverridevirtual
Returns
object describing limits on key size

Implements Botan::Keyed_Filter.

Definition at line 147 of file filters.h.

147 { return m_mac->key_spec(); }
std::string Botan::MAC_Filter::name ( ) const
inlinevirtual
Returns
descriptive name for this filter

Implements Botan::Filter.

Definition at line 139 of file filters.h.

139 { return m_mac->name(); }
void Botan::Filter::send ( const byte  in[],
size_t  length 
)
protectedvirtualinherited
Parameters
insome input for the filter
lengththe length of in

Reimplemented in Botan::Threaded_Fork.

Definition at line 28 of file filter.cpp.

References Botan::Filter::write().

Referenced by Botan::Compression_Decompression_Filter::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::Hash_Filter::end_msg(), end_msg(), Botan::Compression_Decompression_Filter::flush(), Botan::Compression_Decompression_Filter::start_msg(), Botan::Compression_Decompression_Filter::write(), Botan::StreamCipher_Filter::write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

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

Definition at line 65 of file filter.h.

References Botan::Filter::send().

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

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

Definition at line 70 of file filter.h.

References Botan::Filter::send().

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

70 { send(&in[0], in.size()); }
virtual void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::Filter::send ( const std::vector< byte > &  in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 75 of file filter.h.

References Botan::Filter::send().

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

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

Definition at line 81 of file filter.h.

82  {
83  send(&in[0], length);
84  }
virtual void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::Filter::send ( const std::vector< byte > &  in,
size_t  length 
)
inlineprotectedinherited
Parameters
insome input for the filter
lengththe number of bytes of in to send

Definition at line 90 of file filter.h.

91  {
92  send(&in[0], length);
93  }
virtual void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::Keyed_Filter::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 in Botan::StreamCipher_Filter, and Botan::Transformation_Filter.

Definition at line 13 of file basefilt.cpp.

References Botan::OctetString::length(), and Botan::Filter::name().

Referenced by Botan::algorithm_kat_detailed(), and Botan::get_cipher().

14  {
15  if(iv.length() != 0)
16  throw Invalid_IV_Length(name(), iv.length());
17  }
virtual std::string name() const =0
void Botan::MAC_Filter::set_key ( const SymmetricKey key)
inlinevirtual

Set the key of this filter.

Parameters
keythe key to set

Implements Botan::Keyed_Filter.

Definition at line 145 of file filters.h.

145 { m_mac->set_key(key); }
virtual void Botan::Filter::start_msg ( )
inlinevirtualinherited

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

Reimplemented in Botan::Compression_Decompression_Filter.

Definition at line 40 of file filter.h.

40 {}
virtual bool Botan::Keyed_Filter::valid_iv_length ( size_t  length) const
inlinevirtualinherited

Check whether an IV length is valid for this filter

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

Reimplemented in Botan::StreamCipher_Filter, and Botan::Transformation_Filter.

Definition at line 56 of file key_filt.h.

57  { return (length == 0); }
bool Botan::Keyed_Filter::valid_keylength ( size_t  length) const
inlineinherited

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

Definition at line 41 of file key_filt.h.

42  {
43  return key_spec().valid_keylength(length);
44  }
bool valid_keylength(size_t length) const
Definition: key_spec.h:51
virtual Key_Length_Specification key_spec() const =0
void Botan::MAC_Filter::write ( const byte  input[],
size_t  length 
)
inlinevirtual

Write a portion of a message to this filter.

Parameters
inputthe input as a byte array
lengththe length of the byte array input

Implements Botan::Filter.

Definition at line 136 of file filters.h.

136 { m_mac->update(input, len); }

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