Botan  1.11.15
src/lib/mac/cbc_mac/cbc_mac.h
Go to the documentation of this file.
00001 /*
00002 * CBC-MAC
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_CBC_MAC_H__
00009 #define BOTAN_CBC_MAC_H__
00010 
00011 #include <botan/mac.h>
00012 #include <botan/block_cipher.h>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * CBC-MAC
00018 */
00019 class BOTAN_DLL CBC_MAC : public MessageAuthenticationCode
00020    {
00021    public:
00022       std::string name() const;
00023       MessageAuthenticationCode* clone() const;
00024       size_t output_length() const { return m_cipher->block_size(); }
00025       void clear();
00026 
00027       Key_Length_Specification key_spec() const
00028          {
00029          return m_cipher->key_spec();
00030          }
00031 
00032       /**
00033       * @param cipher the underlying block cipher to use
00034       */
00035       CBC_MAC(BlockCipher* cipher);
00036 
00037       static CBC_MAC* make(const Spec& spec);
00038    private:
00039       void add_data(const byte[], size_t);
00040       void final_result(byte[]);
00041       void key_schedule(const byte[], size_t);
00042 
00043       std::unique_ptr<BlockCipher> m_cipher;
00044       secure_vector<byte> m_state;
00045       size_t m_position = 0;
00046    };
00047 
00048 }
00049 
00050 #endif