I am in process of implementing a AES 128 encryption in AVX2 assembly (using AES NI), and am having some problems with decryption logic. I have implemented the encryption sequence without any trouble. However, decryption has been giving many problems.So, my questions regarding the decryption are :
Are the keys identical for the encryption sequence and decryption sequence? If not, then, am I required to execute a VAESIMC instruction on the keys as generated for encryption to make those functional for decryption ? If yes, then must I skip this instruction for the Key 0 [the original Key] and for the Key 10 [the last in sequence to get generated] ? Please clarify...
Once the keys have been generated, the sequence of operation is to take the ciphertext, XOR with the Key 10 value, and apply VAESDECLAST to the result using Key 9, and VAESDEC for all other rounds? Or, alternatively, I must apply VAESDEC to result of the XOR from Key 10 step, and apply the VAESDECLAST to the last round (Key 1 ) ?
All help and advice is welcome. Remain grateful..