2 * File: RijndaelCBCMAC.h
4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_RijndaelCBCMAC_h_)
8 #define _RijndaelCBCMAC_h_
14 * \brief Class to compute CBC-MAC using the AES/Rijndael cipher.
16 * Currently only supports 128-bit keys and block sizes.
23 BLOCK_SIZE = 16 //!< Number of bytes in one cipher block.
26 //! The cipher block data type.
27 typedef uint8_t block_t[BLOCK_SIZE];
30 //! \brief Default constructor.
32 //! The key and IV are both set to zero.
35 //! \brief Constructor.
36 RijndaelCBCMAC(const AESKey<128> & key, const uint8_t * iv=0);
38 //! \brief Process data.
39 void update(const uint8_t * data, unsigned length);
41 //! \brief Signal that all data has been processed.
44 //! \brief Returns a reference to the current MAC value.
45 const block_t & getMAC() const { return m_mac; }
47 //! \brief Assignment operator.
48 RijndaelCBCMAC & operator = (const RijndaelCBCMAC & other)
51 memcpy(m_mac, other.m_mac, sizeof(m_mac));
56 AESKey<128> m_key; //!< 128-bit key to use for the CBC-MAC.
57 block_t m_mac; //!< Current message authentication code value.
59 void updateOneBlock(const uint8_t * data);
62 #endif // _RijndaelCBCMAC_h_