Botan  2.17.3
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 
15 
16 namespace Botan {
17 
18 class BlockCipher;
19 class GHASH;
20 
21 /**
22 * GMAC
23 *
24 * GMAC requires a unique initialization vector be used for each message.
25 * This must be provided via the MessageAuthenticationCode::start() API
26 */
28  {
29  public:
30  void clear() override;
31  std::string name() const override;
32  size_t output_length() const override;
33  MessageAuthenticationCode* clone() const override;
34 
35  Key_Length_Specification key_spec() const override;
36 
37  /**
38  * Creates a new GMAC instance.
39  *
40  * @param cipher the underlying block cipher to use
41  */
42  explicit GMAC(BlockCipher* cipher);
43 
44  GMAC(const GMAC&) = delete;
45  GMAC& operator=(const GMAC&) = delete;
46 
47  ~GMAC();
48 
49  private:
50  void add_data(const uint8_t[], size_t) override;
51  void final_result(uint8_t[]) override;
52  void start_msg(const uint8_t nonce[], size_t nonce_len) override;
53  void key_schedule(const uint8_t key[], size_t size) override;
54 
55  static const size_t GCM_BS = 16;
56  std::unique_ptr<BlockCipher> m_cipher;
57  std::unique_ptr<GHASH> m_ghash;
58  secure_vector<uint8_t> m_aad_buf;
59  size_t m_aad_buf_pos;
60  bool m_initialized;
61  };
62 
63 }
64 #endif
virtual void start_msg(const uint8_t nonce[], size_t nonce_len)
Definition: mac.cpp:151
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
virtual std::string name() const =0
virtual void clear()=0
Definition: alg_id.cpp:13
virtual Key_Length_Specification key_spec() const =0
virtual MessageAuthenticationCode * clone() const =0
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
virtual size_t output_length() const =0