Software implementation of the AES algorithm. More...

Macros | |
| #define | PH_CRYPTOSYM_KEYSCHEDULE_ENCRYPTION 0x0F |
| Performs the AddRoundKey step of the AES Algorithm for encryption and decryption as defined in Chap. More... | |
Functions | |
| void | phCryptoSym_Sw_Aes_SubBytesShiftRows (uint8_t PH_CRYTOSYM_SW_FAST_RAM *pState) |
| Performs the combined SubBytes and Shift Rows step of the AES Algorithm for encryption as defined in Chap. More... | |
| void | phCryptoSym_Sw_Aes_InvSubBytesShiftRows (uint8_t PH_CRYTOSYM_SW_FAST_RAM *pState) |
| Performs the combined SubBytes and Shift Rows step of the AES Algorithm for encryption as defined in Chap. More... | |
| void | phCryptoSym_Sw_Aes_MixColumns (uint8_t PH_CRYTOSYM_SW_FAST_RAM *pState) |
| Performs the MixColumn step of the AES Algorithm for encryption as defined in Chap. More... | |
| void | phCryptoSym_Sw_Aes_InvMixColumns (uint8_t PH_CRYTOSYM_SW_FAST_RAM *pState) |
| Performs the MixColumn step of the AES Algorithm for encryption as defined in Chap. More... | |
| void | phCryptoSym_Sw_Aes_AddRoundKey (uint8_t PH_CRYTOSYM_SW_FAST_RAM *pState, uint8_t PH_CRYTOSYM_SW_FAST_RAM *pKey, uint8_t *pNkCurrent, uint8_t bNk, uint8_t bMode) |
Software implementation of the AES algorithm.
| #define PH_CRYPTOSYM_KEYSCHEDULE_ENCRYPTION 0x0F |
Performs the AddRoundKey step of the AES Algorithm for encryption and decryption as defined in Chap.
5.1.4 and 5.3.4 of FIPS-197. The input state is XORed with the relevant round key. There are two compile options that come together with AddRoundKey:
PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING is not defined: In that case, the round keys have been calculated already upfront in the phCryptoSym_Sw_Aes_KeyExpansion function. The round keys are stored in pDataParams->pKey using the following framing: ORIGINAL KEY || RK1 || RK2 || ... || RKn In total, there are a maximum of 14 Round keys + the original key = 13*16 + 32 = 240 bytes Thus, the function simply picks the correct 16 byte chunk out of the round keys according to the bCnt provided.
PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING is defined: In that case, the round keys are calculated online. The pDataParams->pKey array has a size of 32 bytes in that case. This key is copied into a local 32 bytes buffer, which then is provided to the AddRoundKey function to always update the next 16 bytes of round key according to the algorithm. There are three options available for that function:
| void phCryptoSym_Sw_Aes_SubBytesShiftRows | ( | uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pState | ) |
Performs the combined SubBytes and Shift Rows step of the AES Algorithm for encryption as defined in Chap.
5.1.1, 5.1.2 of FIPS-197. First Row remains untouched, second row is shifted by 1 pos, third row is shifted by 2 pos, fourth row is shifted by 3 pos.
| [in,out] | pState | [InOut] 16 byte array containing the state to operate on |
| void phCryptoSym_Sw_Aes_InvSubBytesShiftRows | ( | uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pState | ) |
Performs the combined SubBytes and Shift Rows step of the AES Algorithm for encryption as defined in Chap.
5.3.1, 5.3.2 of FIPS-197. First Row remains untouched, second row is shifted by 3 pos, third row is shifted by 2 pos, fourth row is shifted by 1 pos.
| [in,out] | pState | [InOut] 16 byte array containing the state to operate on |
| void phCryptoSym_Sw_Aes_MixColumns | ( | uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pState | ) |
Performs the MixColumn step of the AES Algorithm for encryption as defined in Chap.
5.1.3 of FIPS-197. The input bytes are multiplied as specified in the algorithm. The compile flag PH_CRYPTOSYM_SW_ROM_OPTIMIZATION specifies whether all values to be multiplied with are taken from the lookup tables phCryptoSym_Sw_Aes_times2 and phCryptoSym_Sw_Aes_times3 or if phCryptoSym_Sw_Aes_times3 is calculated out of the XOR of phCryptoSym_Sw_Aes_times2 and the relevant value itself.
| [in,out] | pState | [InOut] 16 byte array containing the state to operate on |
| void phCryptoSym_Sw_Aes_InvMixColumns | ( | uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pState | ) |
Performs the MixColumn step of the AES Algorithm for encryption as defined in Chap.
5.3.3 of FIPS-197. The input bytes are multiplied as specified in the algorithm. The compile flag PH_CRYPTOSYM_SW_ROM_OPTIMIZATION specifies whether all values to be multiplied with are taken from the lookup tables phCryptoSym_Sw_Aes_times9, phCryptoSym_Sw_Aes_timesB, phCryptoSym_Sw_Aes_timesD and phCryptoSym_Sw_Aes_timesE or if the following simplifications are used: phCryptoSym_Sw_Aes_timesD = phCryptoSym_Sw_Aes_timesC XOR the value itself phCryptoSym_Sw_Aes_timesE = phCryptoSym_Sw_Aes_timesC XOR phCryptoSym_Sw_Aes_times2
| [in,out] | pState | [InOut] 16 byte array containing the state to operate on |
| void phCryptoSym_Sw_Aes_AddRoundKey | ( | uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pState, |
| uint8_t PH_CRYTOSYM_SW_FAST_RAM * | pKey, | ||
| uint8_t * | pNkCurrent, | ||
| uint8_t | bNk, | ||
| uint8_t | bMode | ||
| ) |
| [in,out] | pState | [InOut] 16 byte array containing the state to operate on |
| [in] | pKey | [In] 32 byte array containing the current round key buffer. NOTE: always the same buffer has to be applied within one encryption. NOTE: if this is the original key buffer, the key is overwritten!. |
| [in] | pNkCurrent | [In] Current Nk value. (= numCurRound*4) |
| [in] | bNk | [In] Nk for the currently loaded key type. AES128: 4, AES192: 6, AES256: 8 |
| [in] | bMode | [In] Option byte indicating whether we have encryption, decryption or key preparation. |