Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gmac.h
Go to the documentation of this file.
1 /*
2 * GMAC
3 * (C) 2016 Matthias Gierlings, René Korthaus
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_GMAC_H__
9 #define BOTAN_GMAC_H__
10
11 #include <botan/gcm.h>
12 #include <botan/mac.h>
13 #include <botan/types.h>
14 #include <algorithm>
15
16 namespace Botan {
17
18 /**
19 * GMAC
20 */
21 class BOTAN_DLL GMAC : public MessageAuthenticationCode,
22 public GHASH
23
24 {
25 public:
26 void clear() override;
27 std::string name() const override;
28 size_t output_length() const override;
29 MessageAuthenticationCode* clone() const override;
30
31 /**
32 * Must be called to set the initialization vector prior to GMAC
33 * calculation.
34 *
35 * @param nonce Initialization vector.
36 * @param nonce_len size of initialization vector.
37 */
38 void start(const uint8_t nonce[], size_t nonce_len);
39
40 /**
41 * Must be called to set the initialization vector prior to GMAC
42 * calculation.
43 *
44 * @param nonce Initialization vector.
45 */
46 void start(const secure_vector<uint8_t>& nonce);
47
48 /**
49 * Must be called to set the initialization vector prior to GMAC
50 * calculation.
51 *
52 * @param nonce Initialization vector.
53 */
54 void start(const std::vector<uint8_t>& nonce);
55
56 Key_Length_Specification key_spec() const override
57 {
58 return m_cipher->key_spec();
59 }
60
61 /**
62 * Creates a new GMAC instance.
63 *
64 * @param cipher the underlying block cipher to use
65 */
66 explicit GMAC(BlockCipher* cipher);
67
68 GMAC(const GMAC&) = delete;
69 GMAC& operator=(const GMAC&) = delete;
70
71 private:
72 void add_data(const uint8_t[], size_t) override;
73 void final_result(uint8_t[]) override;
74 void start_msg(const uint8_t nonce[], size_t nonce_len) override;
75 void key_schedule(const uint8_t key[], size_t size) override;
76
77 static const size_t GCM_BS = 16;
78 secure_vector<uint8_t> m_aad_buf;
79 std::unique_ptr<BlockCipher> m_cipher;
80 bool m_initialized;
81 };
82
83 }
84 #endif
Botan::GHASH
Definition: gcm.h:113
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::MessageAuthenticationCode
Definition: mac.h:20
Botan::GMAC::key_spec
Key_Length_Specification key_spec() const override
Definition: gmac.h:56
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13
Botan::GMAC
Definition: gmac.h:21
Botan::BlockCipher
Definition: block_cipher.h:19