Botan 2.19.5 Crypto and TLS for C&

cmac.h
Go to the documentation of this file.
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/mac.h>
12#include <botan/block_cipher.h>
13
14 BOTAN_FUTURE_INTERNAL_HEADER(cmac.h)
15
16namespace Botan {
17
18/**
19* CMAC, also known as OMAC1
20*/
21 class BOTAN_PUBLIC_API(2,0) CMAC final : public MessageAuthenticationCode
22 {
23 public:
24 std::string name() const override;
25 size_t output_length() const override { return m_block_size; }
26 MessageAuthenticationCode* clone() const override;
27
28 void clear() override;
29
30 Key_Length_Specification key_spec() const override
31 {
32 return m_cipher->key_spec();
33 }
34
35 /**
36 * CMAC's polynomial doubling operation
37 *
38 * This function was only exposed for use elsewhere in the library, but it is not
39 * longer used. This function will be removed in a future release.
40 *
41 * @param in the input
42 */
43 static secure_vector<uint8_t>
44 BOTAN_DEPRECATED("This was only for internal use and is no longer used")
45 poly_double(const secure_vector<uint8_t>& in);
46
47 /**
48 * @param cipher the block cipher to use
49 */
50 explicit CMAC(BlockCipher* cipher);
51
52 CMAC(const CMAC&) = delete;
53 CMAC& operator=(const CMAC&) = delete;
54 private:
55 void add_data(const uint8_t[], size_t) override;
56 void final_result(uint8_t[]) override;
57 void key_schedule(const uint8_t[], size_t) override;
58
59 std::unique_ptr<BlockCipher> m_cipher;
60 secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
61 const size_t m_block_size;
62 size_t m_position;
63 };
64
65}
66
67#endif
Botan::BlockCipher
Definition: block_cipher.h:22
Botan::CMAC
Definition: cmac.h:22
Botan::CMAC::output_length
size_t output_length() const override
Definition: cmac.h:25
Botan::CMAC::key_spec
Key_Length_Specification key_spec() const override
Definition: cmac.h:30
Botan::Key_Length_Specification
Definition: sym_algo.h:20
Botan::MessageAuthenticationCode
Definition: mac.h:23
Botan::MessageAuthenticationCode::clone
virtual MessageAuthenticationCode * clone() const =0
Botan::SymmetricAlgorithm::name
virtual std::string name() const =0
Botan::SymmetricAlgorithm::clear
virtual void clear()=0
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
std
Definition: bigint.h:1155