Botan 3.4.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#include <botan/internal/alignment_buffer.h>
14
15namespace Botan {
16
17class BlockCipher;
18class GHASH;
19
20/**
21* GMAC
22*
23* GMAC requires a unique initialization vector be used for each message.
24* This must be provided via the MessageAuthenticationCode::start() API
25*/
27 public:
28 void clear() override;
29 std::string name() 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&) = delete;
45 GMAC& operator=(const GMAC&) = delete;
46
47 ~GMAC() override;
48
49 private:
50 void add_data(std::span<const uint8_t>) override;
51 void final_result(std::span<uint8_t>) override;
52 void start_msg(std::span<const uint8_t> nonce) override;
53 void key_schedule(std::span<const uint8_t> key) override;
54
55 static const size_t GCM_BS = 16;
56 std::unique_ptr<BlockCipher> m_cipher;
57 std::unique_ptr<GHASH> m_ghash;
60 bool m_initialized;
61};
62
63} // namespace Botan
64#endif
Alignment buffer helper.
std::string name() const override
Definition gmac.cpp:36
GMAC(std::unique_ptr< BlockCipher > cipher)
Definition gmac.cpp:19
~GMAC() override
std::unique_ptr< MessageAuthenticationCode > new_object() const override
Definition gmac.cpp:108
Key_Length_Specification key_spec() const override
Definition gmac.cpp:32
bool has_keying_material() const override
Definition gmac.cpp:61
GMAC & operator=(const GMAC &)=delete
void clear() override
Definition gmac.cpp:22
size_t output_length() const override
Definition gmac.cpp:40
GMAC(const GMAC &)=delete
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61