Botan::ANSI_X919_MAC Class Reference

#include <x919_mac.h>

Inheritance diagram for Botan::ANSI_X919_MAC:

Botan::MessageAuthenticationCode Botan::BufferedComputation Botan::SymmetricAlgorithm

List of all members.

Public Member Functions

 ANSI_X919_MAC (BlockCipher *cipher)
void clear ()
MessageAuthenticationCodeclone () const
SecureVector< bytefinal ()
void final (byte out[])
std::string name () const
SecureVector< byteprocess (const std::string &in)
SecureVector< byteprocess (const MemoryRegion< byte > &in)
SecureVector< byteprocess (const byte in[], u32bit length)
void set_key (const byte key[], u32bit length)
void set_key (const SymmetricKey &key)
void update (byte in)
void update (const std::string &str)
void update (const MemoryRegion< byte > &in)
void update (const byte in[], u32bit length)
bool valid_keylength (u32bit length) const
virtual bool verify_mac (const byte in[], u32bit length)
 ~ANSI_X919_MAC ()

Public Attributes

const u32bit KEYLENGTH_MULTIPLE
const u32bit MAXIMUM_KEYLENGTH
const u32bit MINIMUM_KEYLENGTH
const u32bit OUTPUT_LENGTH


Detailed Description

DES/3DES-based MAC from ANSI X9.19

Definition at line 19 of file x919_mac.h.


Constructor & Destructor Documentation

Botan::ANSI_X919_MAC::ANSI_X919_MAC ( BlockCipher cipher  ) 

Parameters:
cipher the underlying block cipher to use

Definition at line 87 of file x919_mac.cpp.

References Botan::SymmetricAlgorithm::name().

Referenced by clone().

00087                                               :
00088    MessageAuthenticationCode(e_in->BLOCK_SIZE,
00089                              e_in->MINIMUM_KEYLENGTH,
00090                              2*e_in->MAXIMUM_KEYLENGTH,
00091                              2*e_in->KEYLENGTH_MULTIPLE),
00092    e(e_in), d(e->clone()), position(0)
00093    {
00094    if(e->name() != "DES")
00095       throw Invalid_Argument("ANSI X9.19 MAC only supports DES");
00096    }

Botan::ANSI_X919_MAC::~ANSI_X919_MAC (  ) 

Definition at line 101 of file x919_mac.cpp.

00102    {
00103    delete e;
00104    delete d;
00105    }


Member Function Documentation

void Botan::ANSI_X919_MAC::clear (  )  [virtual]

Reset the internal state of this object.

Implements Botan::MessageAuthenticationCode.

Definition at line 66 of file x919_mac.cpp.

References Botan::MemoryRegion< T >::clear(), and Botan::BlockCipher::clear().

00067    {
00068    e->clear();
00069    d->clear();
00070    state.clear();
00071    position = 0;
00072    }

MessageAuthenticationCode * Botan::ANSI_X919_MAC::clone (  )  const [virtual]

Get a new object representing the same algorithm as *this

Implements Botan::MessageAuthenticationCode.

Definition at line 79 of file x919_mac.cpp.

References ANSI_X919_MAC(), and Botan::BlockCipher::clone().

00080    {
00081    return new ANSI_X919_MAC(e->clone());
00082    }

SecureVector<byte> Botan::BufferedComputation::final (  )  [inline, inherited]

Complete the computation and retrieve the final result.

Returns:
SecureVector holding the result

Definition at line 72 of file buf_comp.h.

00073          {
00074          SecureVector<byte> output(OUTPUT_LENGTH);
00075          final_result(output);
00076          return output;
00077          }

void Botan::BufferedComputation::final ( byte  out[]  )  [inline, inherited]

std::string Botan::ANSI_X919_MAC::name (  )  const [virtual]

Get the name of this algorithm.

Returns:
name of this algorithm

Implements Botan::MessageAuthenticationCode.

Definition at line 74 of file x919_mac.cpp.

00075    {
00076    return "X9.19-MAC";
00077    }

SecureVector<byte> Botan::BufferedComputation::process ( const std::string &  in  )  [inline, inherited]

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters:
in the input to process as a string
Returns:
the result of the call to final()

Definition at line 110 of file buf_comp.h.

00111          {
00112          update(in);
00113          return final();
00114          }

SecureVector<byte> Botan::BufferedComputation::process ( const MemoryRegion< byte > &  in  )  [inline, inherited]

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters:
in the input to process
Returns:
the result of the call to final()

Definition at line 98 of file buf_comp.h.

References Botan::MemoryRegion< T >::size().

00099          {
00100          add_data(in, in.size());
00101          return final();
00102          }

SecureVector<byte> Botan::BufferedComputation::process ( const byte  in[],
u32bit  length 
) [inline, inherited]

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters:
in the input to process as a byte array
length the length of the byte array
Returns:
the result of the call to final()

Definition at line 86 of file buf_comp.h.

Referenced by Botan::Randpool::add_entropy(), Botan::EME1::EME1(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().

00087          {
00088          add_data(in, length);
00089          return final();
00090          }

void Botan::SymmetricAlgorithm::set_key ( const byte  key[],
u32bit  length 
) [inline, inherited]

Set the symmetric key of this object.

Parameters:
key the to be set as a byte array.
length in bytes of key param

Definition at line 57 of file sym_algo.h.

00058          {
00059          if(!valid_keylength(length))
00060             throw Invalid_Key_Length(name(), length);
00061          key_schedule(key, length);
00062          }

void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key  )  [inline, inherited]

void Botan::BufferedComputation::update ( byte  in  )  [inline, inherited]

Process a single byte.

Parameters:
in the byte to process

Definition at line 57 of file buf_comp.h.

00057 { add_data(&in, 1); }

void Botan::BufferedComputation::update ( const std::string &  str  )  [inline, inherited]

Add new input to process.

Parameters:
str the input to process as a std::string. Will be interpreted as a byte array based on the strings encoding.

Definition at line 48 of file buf_comp.h.

00049          {
00050          add_data(reinterpret_cast<const byte*>(str.data()), str.size());
00051          }

void Botan::BufferedComputation::update ( const MemoryRegion< byte > &  in  )  [inline, inherited]

Add new input to process.

Parameters:
in the input to process as a MemoryRegion

Definition at line 40 of file buf_comp.h.

References Botan::MemoryRegion< T >::size().

00040 { add_data(in, in.size()); }

void Botan::BufferedComputation::update ( const byte  in[],
u32bit  length 
) [inline, inherited]

bool Botan::SymmetricAlgorithm::valid_keylength ( u32bit  length  )  const [inline, inherited]

Check whether a given key length is valid for this algorithm.

Parameters:
length the key length to be checked.
Returns:
true if the key length is valid.

Definition at line 69 of file sym_algo.h.

Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::HMAC_RNG::HMAC_RNG(), Botan::Lion::Lion(), Botan::Randpool::Randpool(), Botan::XTS_Decryption::set_key(), Botan::XTS_Encryption::set_key(), Botan::EAX_Base::valid_keylength(), Botan::MAC_Filter::valid_keylength(), and Botan::valid_keylength_for().

00070          {
00071          return ((length >= MINIMUM_KEYLENGTH) &&
00072                  (length <= MAXIMUM_KEYLENGTH) &&
00073                  (length % KEYLENGTH_MULTIPLE == 0));
00074          }

bool Botan::MessageAuthenticationCode::verify_mac ( const byte  in[],
u32bit  length 
) [virtual, inherited]

Verify a MAC.

Parameters:
in the MAC to verify as a byte array
length the length of param in
Returns:
true if the MAC is valid, false otherwise

Definition at line 15 of file mac.cpp.

References Botan::MemoryRegion< T >::size().

00016    {
00017    SecureVector<byte> our_mac = final();
00018    if(our_mac.size() != length)
00019       return false;
00020    for(u32bit j = 0; j != length; ++j)
00021       if(mac[j] != our_mac[j])
00022          return false;
00023    return true;
00024    }


Member Data Documentation

A valid keylength is a multiple of this value.

Definition at line 37 of file sym_algo.h.

Referenced by Botan::keylength_multiple_of().

The maximum allowed key length.

Definition at line 27 of file sym_algo.h.

Referenced by Botan::max_keylength_of().

The minimal allowed key length.

Definition at line 32 of file sym_algo.h.

Referenced by Botan::min_keylength_of().


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

Generated on Tue Jun 29 08:56:41 2010 for Botan by  doxygen 1.5.8