Botan 3.7.1
Crypto and TLS for C&
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
14namespace Botan {
15
16class BlockCipher;
17class 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 public:
27 void clear() override;
28 std::string name() const override;
29 size_t output_length() const override;
30 std::unique_ptr<MessageAuthenticationCode> new_object() const override;
31
32 Key_Length_Specification key_spec() const override;
33
34 bool has_keying_material() const override;
35
36 /**
37 * Creates a new GMAC instance.
38 *
39 * @param cipher the underlying block cipher to use
40 */
41 explicit GMAC(std::unique_ptr<BlockCipher> cipher);
42
43 GMAC(const GMAC&) = delete;
44 GMAC& operator=(const GMAC&) = delete;
45
46 ~GMAC() override;
47
48 private:
49 void add_data(std::span<const uint8_t>) override;
50 void final_result(std::span<uint8_t>) override;
51 void start_msg(std::span<const uint8_t> nonce) override;
52 void key_schedule(std::span<const uint8_t> key) override;
53
54 static const size_t GCM_BS = 16;
55 std::unique_ptr<BlockCipher> m_cipher;
56 std::unique_ptr<GHASH> m_ghash;
58 bool m_initialized;
59};
60
61} // namespace Botan
62#endif
std::string name() const override
Definition gmac.cpp:34
GMAC(std::unique_ptr< BlockCipher > cipher)
Definition gmac.cpp:18
~GMAC() override
std::unique_ptr< MessageAuthenticationCode > new_object() const override
Definition gmac.cpp:86
Key_Length_Specification key_spec() const override
Definition gmac.cpp:30
bool has_keying_material() const override
Definition gmac.cpp:46
GMAC & operator=(const GMAC &)=delete
void clear() override
Definition gmac.cpp:21
size_t output_length() const override
Definition gmac.cpp:38
GMAC(const GMAC &)=delete
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61