This function adds the round key to state. The round key is added to the state by an XOR function.
| 341 | // This function adds the round key to state. |
| 342 | // The round key is added to the state by an XOR function. |
| 343 | static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey) |
| 344 | { |
| 345 | uint8_t i,j; |
| 346 | for (i = 0; i < 4; ++i) |
| 347 | { |
| 348 | for (j = 0; j < 4; ++j) |
| 349 | { |
| 350 | (*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j]; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | // The SubBytes Function Substitutes the values in the |
| 356 | // state matrix with values in an S-box. |