Botan  2.6.0
Crypto and TLS for C++11
gmac.h
Go to the documentation of this file.
1 /*
2  * GMAC
3  * (C) 2016 Matthias Gierlings, RenĂ© Korthaus
4  * (C) 2017 Jack Lloyd
5  *
6  * Botan is released under the Simplified BSD License (see license.txt)
7  */
8 
9 #ifndef BOTAN_GMAC_H_
10 #define BOTAN_GMAC_H_
11 
12 #include <botan/mac.h>
13 
14 namespace Botan {
15 
16 class BlockCipher;
17 class GHASH;
18 
19 /**
20 * GMAC
21 *
22 * GMAC requires a unique initialization vector be used for each message.
23 * This must be provided via the MessageAuthenticationCode::start() API
24 */
26  {
27  public:
28  void clear() override;
29  std::string name() const override;
30  size_t output_length() const override;
31  MessageAuthenticationCode* clone() const override;
32 
33  Key_Length_Specification key_spec() const override;
34 
35  /**
36  * Creates a new GMAC instance.
37  *
38  * @param cipher the underlying block cipher to use
39  */
40  explicit GMAC(BlockCipher* cipher);
41 
42  GMAC(const GMAC&) = delete;
43  GMAC& operator=(const GMAC&) = delete;
44 
45  ~GMAC();
46 
47  private:
48  void add_data(const uint8_t[], size_t) override;
49  void final_result(uint8_t[]) override;
50  void start_msg(const uint8_t nonce[], size_t nonce_len) override;
51  void key_schedule(const uint8_t key[], size_t size) override;
52 
53  static const size_t GCM_BS = 16;
54  std::unique_ptr<BlockCipher> m_cipher;
55  std::unique_ptr<GHASH> m_ghash;
56  secure_vector<uint8_t> m_aad_buf;
57  size_t m_aad_buf_pos;
58  bool m_initialized;
59  };
60 
61 }
62 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88