Botan 3.5.0
Crypto and TLS for C&
kmac.h
Go to the documentation of this file.
1/*
2* KMAC
3* (C) 2023 Jack Lloyd
4* (C) 2023 Falko Strenzke
5* (C) 2023 René Meusel - Rohde & Schwarz Cybersecurity
6*
7* Botan is released under the Simplified BSD License (see license.txt)
8*/
9
10#ifndef BOTAN_KMAC_H_
11#define BOTAN_KMAC_H_
12
13#include <botan/mac.h>
14
15namespace Botan {
16
17class cSHAKE_XOF;
18
20 protected:
21 KMAC(std::unique_ptr<cSHAKE_XOF> cshake, size_t output_bit_length);
22
23 public:
24 virtual ~KMAC();
25
26 KMAC(const KMAC&) = delete;
27 KMAC& operator=(const KMAC&) = delete;
28
29 void clear() final;
30 size_t output_length() const final;
32 bool has_keying_material() const final;
33
34 std::string provider() const final;
35
36 private:
37 void start_msg(std::span<const uint8_t> nonce) final;
38 void add_data(std::span<const uint8_t>) final;
39 void final_result(std::span<uint8_t>) final;
40 void key_schedule(std::span<const uint8_t>) final;
41
42 private:
43 size_t m_output_bit_length;
44 secure_vector<uint8_t> m_encoded_key;
45 bool m_message_started;
46
47 std::unique_ptr<cSHAKE_XOF> m_cshake;
48};
49
50/**
51* KMAC-128 as specified in NIST SP.800-185 Section 4
52*/
53class KMAC128 final : public KMAC {
54 public:
55 KMAC128(size_t output_bit_length);
56 std::string name() const override;
57 std::unique_ptr<MessageAuthenticationCode> new_object() const override;
58};
59
60/**
61* KMAC-256 as specified in NIST SP.800-185 Section 4
62*/
63class KMAC256 final : public KMAC {
64 public:
65 KMAC256(size_t output_bit_length);
66 std::string name() const override;
67 std::unique_ptr<MessageAuthenticationCode> new_object() const override;
68};
69
70} // namespace Botan
71
72#endif
KMAC(std::unique_ptr< cSHAKE_XOF > cshake, size_t output_bit_length)
Definition kmac.cpp:18
KMAC & operator=(const KMAC &)=delete
virtual ~KMAC()
bool has_keying_material() const final
Definition kmac.cpp:48
void clear() final
Definition kmac.cpp:27
size_t output_length() const final
Definition kmac.cpp:33
Key_Length_Specification key_spec() const final
Definition kmac.cpp:37
std::string provider() const final
Definition kmac.cpp:52
KMAC(const KMAC &)=delete
virtual std::unique_ptr< MessageAuthenticationCode > new_object() const =0
virtual std::string name() const =0
std::string name
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61