RijndaelCBCMAC.h
/*
* File: RijndaelCBCMAC.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_RijndaelCBCMAC_h_)
#define _RijndaelCBCMAC_h_
#include "AESKey.h"
#include <string.h>
class RijndaelCBCMAC
{
public:
enum
{
BLOCK_SIZE = 16
};
typedef uint8_t block_t[BLOCK_SIZE];
public:
RijndaelCBCMAC() {}
RijndaelCBCMAC(const AESKey<128> &key, const uint8_t *iv = 0);
void update(const uint8_t *data, unsigned length);
void finalize();
const block_t &getMAC() const { return m_mac; }
RijndaelCBCMAC &operator=(const RijndaelCBCMAC &other)
{
m_key = other.m_key;
memcpy(m_mac, other.m_mac, sizeof(m_mac));
return *this;
}
protected:
AESKey<128> m_key;
block_t m_mac;
void updateOneBlock(const uint8_t *data);
};
#endif // _RijndaelCBCMAC_h_
RijndaelCBCMAC::BLOCK_SIZE
Number of bytes in one cipher block.
Definition: RijndaelCBCMAC.h:23
RijndaelCBCMAC::update
void update(const uint8_t *data, unsigned length)
Process data.
Definition: RijndaelCBCMAC.cpp:32
RijndaelCBCMAC::RijndaelCBCMAC
RijndaelCBCMAC()
Default constructor.
Definition: RijndaelCBCMAC.h:33
RijndaelCBCMAC::operator=
RijndaelCBCMAC & operator=(const RijndaelCBCMAC &other)
Assignment operator.
Definition: RijndaelCBCMAC.h:46
RijndaelCBCMAC::block_t
uint8_t block_t[BLOCK_SIZE]
The cipher block data type.
Definition: RijndaelCBCMAC.h:27
RijndaelCBCMAC::m_mac
block_t m_mac
Current message authentication code value.
Definition: RijndaelCBCMAC.h:55
AESKey< 128 >
RijndaelCBCMAC::getMAC
const block_t & getMAC() const
Returns a reference to the current MAC value.
Definition: RijndaelCBCMAC.h:44
RijndaelCBCMAC::m_key
AESKey< 128 > m_key
128-bit key to use for the CBC-MAC.
Definition: RijndaelCBCMAC.h:54
RijndaelCBCMAC::finalize
void finalize()
Signal that all data has been processed.
Definition: RijndaelCBCMAC.cpp:46
RijndaelCBCMAC
Class to compute CBC-MAC using the AES/Rijndael cipher.
Definition: RijndaelCBCMAC.h:18
RijndaelCBCMAC::updateOneBlock
void updateOneBlock(const uint8_t *data)
Definition: RijndaelCBCMAC.cpp:53