Botan 3.11.0
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 std::string provider() const override;
30 size_t output_length() const override;
31 std::unique_ptr<MessageAuthenticationCode> new_object() const override;
32
33 Key_Length_Specification key_spec() const override;
34
35 bool has_keying_material() const override;
36
37 /**
38 * Creates a new GMAC instance.
39 *
40 * @param cipher the underlying block cipher to use
41 */
42 explicit GMAC(std::unique_ptr<BlockCipher> cipher);
43
44 GMAC(const GMAC& other) = delete;
45 GMAC(GMAC&& other) = default;
46 GMAC& operator=(const GMAC& other) = delete;
47 GMAC& operator=(GMAC&& other) = default;
48
49 ~GMAC() override;
50
51 private:
52 void add_data(std::span<const uint8_t> input) override;
53 void final_result(std::span<uint8_t> output) override;
54 void start_msg(std::span<const uint8_t> nonce) override;
55 void key_schedule(std::span<const uint8_t> key) override;
56
57 static const size_t GCM_BS = 16;
58 std::unique_ptr<BlockCipher> m_cipher;
59 std::unique_ptr<GHASH> m_ghash;
61 bool m_initialized;
62};
63
64} // namespace Botan
65#endif
void final(uint8_t out[])
Definition buf_comp.h:69
std::string name() const override
Definition gmac.cpp:35
GMAC(std::unique_ptr< BlockCipher > cipher)
Definition gmac.cpp:19
~GMAC() override
std::string provider() const override
Definition gmac.cpp:39
std::unique_ptr< MessageAuthenticationCode > new_object() const override
Definition gmac.cpp:90
GMAC & operator=(GMAC &&other)=default
Key_Length_Specification key_spec() const override
Definition gmac.cpp:31
GMAC(GMAC &&other)=default
bool has_keying_material() const override
Definition gmac.cpp:51
void clear() override
Definition gmac.cpp:22
size_t output_length() const override
Definition gmac.cpp:43
GMAC(const GMAC &other)=delete
GMAC & operator=(const GMAC &other)=delete
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:68