Botan  1.11.10
x919_mac.h
Go to the documentation of this file.
1 /*
2 * ANSI X9.19 MAC
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_ANSI_X919_MAC_H__
9 #define BOTAN_ANSI_X919_MAC_H__
10 
11 #include <botan/mac.h>
12 #include <botan/block_cipher.h>
13 
14 namespace Botan {
15 
16 /**
17 * DES/3DES-based MAC from ANSI X9.19
18 */
19 class BOTAN_DLL ANSI_X919_MAC : public MessageAuthenticationCode
20  {
21  public:
22  void clear();
23  std::string name() const;
24  size_t output_length() const { return 8; }
25 
26  MessageAuthenticationCode* clone() const;
27 
29  {
30  return Key_Length_Specification(8, 16, 8);
31  }
32 
33  /**
34  * @param cipher the underlying block cipher to use
35  */
36  ANSI_X919_MAC(BlockCipher* cipher);
37 
38  ANSI_X919_MAC(const ANSI_X919_MAC&) = delete;
39  ANSI_X919_MAC& operator=(const ANSI_X919_MAC&) = delete;
40  private:
41  void add_data(const byte[], size_t);
42  void final_result(byte[]);
43  void key_schedule(const byte[], size_t);
44 
45  std::unique_ptr<BlockCipher> m_des1, m_des2;
46  secure_vector<byte> m_state;
47  size_t m_position;
48  };
49 
50 }
51 
52 #endif
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:92
uint8_t byte
Definition: types.h:30
size_t output_length() const
Definition: x919_mac.h:24
Key_Length_Specification key_spec() const
Definition: x919_mac.h:28