0

I am doing a project on the Rijndael Algorithm. I have already written the encryption code which produces the correct output. Now I want to implement decryption as well. I'm doing using VHDL, targetting the Xylinx platform.

Can anyone help me coding for ADD_ROUND_KEY step in decryption.

CodesInChaos
  • 24,841
  • 2
  • 89
  • 128
  • The ADD_ROUND_KEY step is identical for both encryption and decryption; if you have the coding for the encryption step, just reuse that. – poncho Oct 26 '15 at 14:25
  • thanks for ur ans.... i hav done that, but not coming.... are the values of RCON also same? – Jaswanth Vuggirala Oct 26 '15 at 14:32
  • Have you coded for both encryption and decryption? – Jaswanth Vuggirala Oct 26 '15 at 14:33
  • 2
    Actually, you run through the key scheduling backwards (and so the last subkey for the encryption direction is the first subkey for the decryption direction). Or, are you expanding the subkeys at the same time you're performing the encryption? – poncho Oct 26 '15 at 14:34
  • I am coding encryption and decryption both seperately..... – Jaswanth Vuggirala Oct 26 '15 at 14:36
  • My question was whether you expanded the key separately, or whether you generated the subkeys dynamically while performing the encryption/decryption operation. If you generated the subkeys separately, then it's easy; you just reverse the order. If you generate them on the fly, it's trickier in the decrypt direction; you need to run the key expansion process backwards. This is possible (you start with the final key state, not the initial key, and work backwards), however it is trickier (and since I don't know VHDL, I can't help you with the details) – poncho Oct 26 '15 at 14:39
  • Thank u fr ur replies...i am generating the subkeys dynamically. – Jaswanth Vuggirala Oct 26 '15 at 15:04
  • @JaswanthVuggirala: I second Poncho's comment that your problem with AddRoundKey (if any) is likely that you need to compute the key used at the last step of encryption, and start decryption with that. As explained here, if your input for decryption is the key and ciphertext, there's no better way. – fgrieu Oct 26 '15 at 19:55
  • If memory is an issue so that you need to do subkeys dynamically, it can be a bit more challenging. When I wrote my own implementation of some algorithms (for learning purposes -- they are probably weak to side channel attacks) I always threw some memory at it by making all round keys in an array. If you could do this same approach, then decryption would be as simple (in this step) as iterating through the round key array backwards, counting down to element 0 instead of up from 0. – WDS Oct 26 '15 at 20:38

0 Answers0