Botan  1.11.15
src/lib/mac/x919_mac/x919_mac.h
Go to the documentation of this file.
00001 /*
00002 * ANSI X9.19 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_ANSI_X919_MAC_H__
00009 #define BOTAN_ANSI_X919_MAC_H__
00010 
00011 #include <botan/mac.h>
00012 #include <botan/block_cipher.h>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * DES/3DES-based MAC from ANSI X9.19
00018 */
00019 class BOTAN_DLL ANSI_X919_MAC : public MessageAuthenticationCode
00020    {
00021    public:
00022       void clear();
00023       std::string name() const;
00024       size_t output_length() const { return 8; }
00025 
00026       MessageAuthenticationCode* clone() const;
00027 
00028       Key_Length_Specification key_spec() const
00029          {
00030          return Key_Length_Specification(8, 16, 8);
00031          }
00032 
00033       ANSI_X919_MAC();
00034 
00035       ANSI_X919_MAC(const ANSI_X919_MAC&) = delete;
00036       ANSI_X919_MAC& operator=(const ANSI_X919_MAC&) = delete;
00037    private:
00038       void add_data(const byte[], size_t);
00039       void final_result(byte[]);
00040       void key_schedule(const byte[], size_t);
00041 
00042       std::unique_ptr<BlockCipher> m_des1, m_des2;
00043       secure_vector<byte> m_state;
00044       size_t m_position;
00045    };
00046 
00047 }
00048 
00049 #endif