/src/botan/build/include/internal/botan/internal/cmac.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * CMAC |
3 | | * (C) 1999-2007,2014 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_CMAC_H_ |
9 | | #define BOTAN_CMAC_H_ |
10 | | |
11 | | #include <botan/block_cipher.h> |
12 | | #include <botan/mac.h> |
13 | | |
14 | | namespace Botan { |
15 | | |
16 | | /** |
17 | | * CMAC, also known as OMAC1 |
18 | | */ |
19 | | class CMAC final : public MessageAuthenticationCode { |
20 | | public: |
21 | | std::string name() const override; |
22 | | |
23 | 0 | size_t output_length() const override { return m_block_size; } |
24 | | |
25 | | std::unique_ptr<MessageAuthenticationCode> new_object() const override; |
26 | | |
27 | | void clear() override; |
28 | | bool has_keying_material() const override; |
29 | | |
30 | 0 | Key_Length_Specification key_spec() const override { return m_cipher->key_spec(); } |
31 | | |
32 | | /** |
33 | | * @param cipher the block cipher to use |
34 | | */ |
35 | | explicit CMAC(std::unique_ptr<BlockCipher> cipher); |
36 | | |
37 | | CMAC(const CMAC&) = delete; |
38 | | CMAC& operator=(const CMAC&) = delete; |
39 | | |
40 | | private: |
41 | | void add_data(std::span<const uint8_t>) override; |
42 | | void final_result(std::span<uint8_t>) override; |
43 | | void key_schedule(std::span<const uint8_t>) override; |
44 | | |
45 | | std::unique_ptr<BlockCipher> m_cipher; |
46 | | secure_vector<uint8_t> m_buffer, m_state, m_B, m_P; |
47 | | const size_t m_block_size; |
48 | | size_t m_position; |
49 | | }; |
50 | | |
51 | | } // namespace Botan |
52 | | |
53 | | #endif |