Botan 3.9.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 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& other) = delete;
44 GMAC(GMAC&& other) = default;
45 GMAC& operator=(const GMAC& other) = delete;
46 GMAC& operator=(GMAC&& other) = default;
47
48 ~GMAC() override;
49
50 private:
51 void add_data(std::span<const uint8_t> input) override;
52 void final_result(std::span<uint8_t> output) override;
53 void start_msg(std::span<const uint8_t> nonce) override;
54 void key_schedule(std::span<const uint8_t> key) override;
55
56 static const size_t GCM_BS = 16;
57 std::unique_ptr<BlockCipher> m_cipher;
58 std::unique_ptr<GHASH> m_ghash;
60 bool m_initialized;
61};
62
63} // namespace Botan
64#endif
void final(uint8_t out[])
Definition buf_comp.h:69
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:85
GMAC & operator=(GMAC &&other)=default
Key_Length_Specification key_spec() const override
Definition gmac.cpp:30
GMAC(GMAC &&other)=default
bool has_keying_material() const override
Definition gmac.cpp:46
void clear() override
Definition gmac.cpp:21
size_t output_length() const override
Definition gmac.cpp:38
GMAC(const GMAC &other)=delete
GMAC & operator=(const GMAC &other)=delete
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:69