I am writing a program to implement AES encryption and decryption. It is for a school project.
I have successfully implemented AES-128 encryption, however i am a little confused with addRoundKey function in decryption.
For encryption you use 11 round keys, the first key being used pre round 1 and the last being used during the final round.
When it comes to decryption, for the first preround of decryption, do i use the first key that was used preround 1 in encryption, or do i use the final key that was used in the last round of encryption?
encryption goes like this : encryption preround ( addRoundkey[0] * state) THEN (subbytes,shiftrows,mixColumns,addRoundKey[1 to 9]) 9 times and final round of subbytes,shiftrows and addRoundKey [10]
is the decryption preround - (addRoundKey[10] * ciphertext) OR (addRoundKey[0] * ciphertext)
and lets say round 3 of decryption, would i use addRoundKey[3] or addRoundKey[7]
thank you.