26 #include "BlockCipher.h" 
   30 #define CRYPTO_AES_ESP32 1 
   32 #define CRYPTO_AES_DEFAULT 1 
   35 #if defined(CRYPTO_AES_DEFAULT) || defined(CRYPTO_DOC) 
   49     void encryptBlock(uint8_t *output, 
const uint8_t *input);
 
   50     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
   61     static void subBytesAndShiftRows(uint8_t *output, 
const uint8_t *input);
 
   62     static void inverseShiftRowsAndSubBytes(uint8_t *output, 
const uint8_t *input);
 
   63     static void mixColumn(uint8_t *output, uint8_t *input);
 
   64     static void inverseMixColumn(uint8_t *output, 
const uint8_t *input);
 
   65     static void keyScheduleCore(uint8_t *output, 
const uint8_t *input, uint8_t iteration);
 
   66     static void applySbox(uint8_t *output, 
const uint8_t *input);
 
   83     bool setKey(
const uint8_t *key, 
size_t len);
 
   97     bool setKey(
const uint8_t *key, 
size_t len);
 
  111     bool setKey(
const uint8_t *key, 
size_t len);
 
  126     bool setKey(
const uint8_t *key, 
size_t len);
 
  128     void encryptBlock(uint8_t *output, 
const uint8_t *input);
 
  129     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
  134     uint8_t schedule[32];
 
  143     bool setKey(
const uint8_t *key, 
size_t len);
 
  145     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
  162     bool setKey(
const uint8_t *key, 
size_t len);
 
  164     void encryptBlock(uint8_t *output, 
const uint8_t *input);
 
  165     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
  170     uint8_t schedule[16];
 
  179     bool setKey(
const uint8_t *key, 
size_t len);
 
  181     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
  191 #if defined(CRYPTO_AES_ESP32) 
  203 #define CRYPTO_ESP32_CONTEXT_SIZE 40 
  212 #define AES128 AES128_ESP 
  213 #define AES192 AES192_ESP 
  214 #define AES256 AES256_ESP 
  226     bool setKey(
const uint8_t *key, 
size_t len);
 
  228     void encryptBlock(uint8_t *output, 
const uint8_t *input);
 
  229     void decryptBlock(uint8_t *output, 
const uint8_t *input);
 
  237     uint8_t ctx[CRYPTO_ESP32_CONTEXT_SIZE];
 
AES block cipher with 128-bit keys.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
size_t keySize() const
Size of a 128-bit AES key in bytes.
AES128()
Constructs an AES 128-bit block cipher with no initial key.
AES block cipher with 192-bit keys.
size_t keySize() const
Size of a 192-bit AES key in bytes.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
AES192()
Constructs an AES 192-bit block cipher with no initial key.
AES block cipher with 256-bit keys.
AES256()
Constructs an AES 256-bit block cipher with no initial key.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
size_t keySize() const
Size of a 256-bit AES key in bytes.
Abstract base class for AES block ciphers.
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
void clear()
Clears all security-sensitive state from this block cipher.
virtual ~AESCommon()
Destroys this AES block cipher object after clearing sensitive information.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
size_t blockSize() const
Size of an AES block in bytes.
AESCommon()
Constructs an AES block cipher object.
AES block cipher with 128-bit keys and reduced memory usage.
void clear()
Clears all security-sensitive state from this block cipher.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
AESSmall128()
Constructs an AES 128-bit block cipher with no initial key.
AES block cipher with 256-bit keys and reduced memory usage.
AESSmall256()
Constructs an AES 256-bit block cipher with no initial key.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
void clear()
Clears all security-sensitive state from this block cipher.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
AES block cipher with 128-bit keys and tiny memory usage.
void clear()
Clears all security-sensitive state from this block cipher.
AESTiny128()
Constructs an AES 128-bit block cipher with no initial key.
size_t blockSize() const
Size of an AES block in bytes.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
size_t keySize() const
Size of a 128-bit AES key in bytes.
AES block cipher with 256-bit keys and tiny memory usage.
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
size_t keySize() const
Size of a 256-bit AES key in bytes.
AESTiny256()
Constructs an AES 256-bit block cipher with no initial key.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
void clear()
Clears all security-sensitive state from this block cipher.
size_t blockSize() const
Size of an AES block in bytes.
Abstract base class for block ciphers.
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
virtual size_t keySize() const =0
Default size of the key for this block cipher, in bytes.