Source
/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */
/*
*
* This is an implementation of the AES algorithm, specifically ECB, CTR and CBC mode.
* Block size can be chosen in aes.h - available choices are AES128, AES192, AES256.
*
* The implementation is verified against the test vectors in:
* National Institute of Standards and Technology Special Publication 800-38A 2001 ED
*
* ECB-AES128
* ----------
*
* plain-text:
* 6bc1bee22e409f96e93d7e117393172a
* ae2d8a571e03ac9c9eb76fac45af8e51
* 30c81c46a35ce411e5fbc1191a0a52ef
* f69f2445df4f9b17ad2b417be66c3710
*
* key:
* 2b7e151628aed2a6abf7158809cf4f3c
*
* resulting cipher
* 3ad77bb40d7a3660a89ecaf32466ef97
* f5d3d58503b9699de785895a96fdbaaf
* 43b1cd7f598ece23881b00e3ed030688
* 7b0c785e27e8ad3f8223207104725dd4
*
*
* NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0)
* You should pad the end of the string with zeros if this is not the case.
* For AES192/256 the key size is proportionally larger.
*
*/
/*****************************************************************************/
/* Includes: */
/*****************************************************************************/
// CBC mode, for memset
/*****************************************************************************/
/* Defines: */
/*****************************************************************************/
// The number of columns comprising a state in AES. This is a constant in AES. Value=4
// The number of 32 bit words in a key.
// The number of rounds in AES Cipher.
// jcallan@github points out that declaring Multiply as a function
// reduces code size considerably with the Keil ARM compiler.
// See this link for more information: https://github.com/kokke/tiny-AES-C/pull/3