Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
src/blfwk/RijndaelCTR.h
1 /*
2  * File: RijndaelCTR.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_RijndaelCTR_h_)
8 #define _RijndaelCTR_h_
9 
10 #include "AESKey.h"
11 #include "AESCounter.h"
12 #include <string.h>
13 
19 class RijndaelCTR
20 {
21 public:
22  enum
23  {
24  BLOCK_SIZE = 16
25  };
26 
28  typedef uint8_t block_t[BLOCK_SIZE];
29 
30 public:
32  RijndaelCTR(const AESKey<128> &key, const AESCounter<128> &counter);
33 
35  void encrypt(const uint8_t *data, unsigned length, uint8_t *dest);
36 
38  void decrypt(const uint8_t *data, unsigned length, uint8_t *dest);
39 
42  {
43  m_key = other.m_key;
44  m_counter = other.m_counter;
45  return *this;
46  }
47 
48 protected:
51 
52  void incrementCounter(AESCounter<128>::counter_t *counter);
53  void baseProcess(const uint8_t *data, unsigned length, uint8_t *dest);
54 
55 private:
57  RijndaelCTR() {}
58 };
59 
60 #endif // _RijndaelCTR_h_
Class to compute AES 128 CTR encryption/decryption.
Definition: apps/elftosb/common/RijndaelCTR.h:19
AESCounter< 128 > m_counter
Counter value for encrypt/decrypt.
Definition: apps/elftosb/common/RijndaelCTR.h:50
RijndaelCTR & operator=(const RijndaelCTR &other)
Assignment operator.
Definition: src/blfwk/RijndaelCTR.h:41
uint8_t block_t[BLOCK_SIZE]
The cipher block data type.
Definition: apps/elftosb/common/RijndaelCTR.h:28
Number of bytes in one cipher block.
Definition: apps/elftosb/common/RijndaelCTR.h:24
void encrypt(const uint8_t *data, unsigned length, uint8_t *dest)
Encrypt data.
Definition: apps/elftosb/common/RijndaelCTR.cpp:28
AESKey< 128 > m_key
128-bit key to use for encrypt/decrypt
Definition: apps/elftosb/common/RijndaelCTR.h:49
void decrypt(const uint8_t *data, unsigned length, uint8_t *dest)
Encrypt data.
Definition: apps/elftosb/common/RijndaelCTR.cpp:23