Botan 2.13.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 * (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 BOTAN_FUTURE_INTERNAL_HEADER(gmac.h)
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 */
27 class BOTAN_PUBLIC_API(2,0) GMAC final : public MessageAuthenticationCode
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
Botan::MessageAuthenticationCode::start_msg
virtual void start_msg(const uint8_t nonce[], size_t nonce_len)
Definition: mac.cpp:151
m_cipher
CCCryptorRef m_cipher
Definition: commoncrypto_mode.cpp:50
Botan::Key_Length_Specification
Definition: key_spec.h:18
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan::MessageAuthenticationCode
Definition: mac.h:21
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
Botan::SymmetricAlgorithm::name
virtual std::string name() const =0
Botan::SymmetricAlgorithm::clear
virtual void clear()=0
Botan
Definition: alg_id.cpp:13
Botan::SymmetricAlgorithm::key_spec
virtual Key_Length_Specification key_spec() const =0
Botan::MessageAuthenticationCode::clone
virtual MessageAuthenticationCode * clone() const =0
Botan::GMAC
Definition: gmac.h:27
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0
Botan::BlockCipher
Definition: block_cipher.h:21