Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
RijndaelCBCMAC.h
1 /*
2  * File: RijndaelCBCMAC.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_RijndaelCBCMAC_h_)
8 #define _RijndaelCBCMAC_h_
9 
10 #include "AESKey.h"
11 #include <string.h>
12 
19 {
20 public:
21  enum
22  {
23  BLOCK_SIZE = 16
24  };
25 
27  typedef uint8_t block_t[BLOCK_SIZE];
28 
29 public:
35  RijndaelCBCMAC(const AESKey<128> &key, const uint8_t *iv = 0);
36 
38  void update(const uint8_t *data, unsigned length);
39 
41  void finalize();
42 
44  const block_t &getMAC() const { return m_mac; }
47  {
48  m_key = other.m_key;
49  memcpy(m_mac, other.m_mac, sizeof(m_mac));
50  return *this;
51  }
52 
53 protected:
55  block_t m_mac;
56 
57  void updateOneBlock(const uint8_t *data);
58 };
59 
60 #endif // _RijndaelCBCMAC_h_
Number of bytes in one cipher block.
Definition: RijndaelCBCMAC.h:23
void update(const uint8_t *data, unsigned length)
Process data.
Definition: RijndaelCBCMAC.cpp:32
RijndaelCBCMAC()
Default constructor.
Definition: RijndaelCBCMAC.h:33
RijndaelCBCMAC & operator=(const RijndaelCBCMAC &other)
Assignment operator.
Definition: RijndaelCBCMAC.h:46
uint8_t block_t[BLOCK_SIZE]
The cipher block data type.
Definition: RijndaelCBCMAC.h:27
block_t m_mac
Current message authentication code value.
Definition: RijndaelCBCMAC.h:55
const block_t & getMAC() const
Returns a reference to the current MAC value.
Definition: RijndaelCBCMAC.h:44
AESKey< 128 > m_key
128-bit key to use for the CBC-MAC.
Definition: RijndaelCBCMAC.h:54
void finalize()
Signal that all data has been processed.
Definition: RijndaelCBCMAC.cpp:46
Class to compute CBC-MAC using the AES/Rijndael cipher.
Definition: RijndaelCBCMAC.h:18
void updateOneBlock(const uint8_t *data)
Definition: RijndaelCBCMAC.cpp:53