正在加载图片...
KeyExpansion(byte key[4*Nk],word w[Nb*(Nr+1)],Nk) begi word temp i=0 while (i<Nk) w[i]word(key[4*i],key[4*i+1],key[4*i+2],key[4*i+3]) i=i+1 end while i =Nk while (i<Nb (Nr+1)] temp w[i-1] if (i mod Nk =0) temp SubWord(RotWord(temp))xor Rcon[i/Nk] else if (Nk 6 and i mod Nk 4) temp SubWord(temp) end if w[i】=w[i-Nk】xor temp i=i+1 end while end Note that Nk=4,6,and 8 do not all have to be implemented; they are all included in the conditional statement above for conciseness. Specific implementation requirements for the Cipher Key are presented in Sec.6.1. Figure 11.Pseudo Code for Key Expansion.2 Appendix A presents examples of the Key Expansion. 5.3 Inverse Cipher The Cipher transformations in Sec.5.1 can be inverted and then implemented in reverse order to produce a straightforward Inverse Cipher for the AES algorithm.The individual transformations used in the Inverse Cipher -InvShiftRows(),InvSubBytes ()InvMixColumns () and AddRoundkey ()-process the State and are described in the following subsections. The Inverse Cipher is described in the pseudo code in Fig.12.In Fig.12,the array w[]contains the key schedule,which was described previously in Sec.5.2. 2 The functions subword()and Rotword()return a result that is a transformation of the function input,whereas the transformations in the Cipher and Inverse Cipher(e.g.,ShiftRows ()SubBytes ()etc.)transform the State array that is addressed by the'state'pointer. 2020 Figure 11. Pseudo Code for Key Expansion.2 Appendix A presents examples of the Key Expansion. 5.3 Inverse Cipher The Cipher transformations in Sec. 5.1 can be inverted and then implemented in reverse order to produce a straightforward Inverse Cipher for the AES algorithm. The individual transformations used in the Inverse Cipher - InvShiftRows(), InvSubBytes(),InvMixColumns(), and AddRoundKey() – process the State and are described in the following subsections. The Inverse Cipher is described in the pseudo code in Fig. 12. In Fig. 12, the array w[] contains the key schedule, which was described previously in Sec. 5.2. 2 The functions SubWord() and RotWord() return a result that is a transformation of the function input, whereas the transformations in the Cipher and Inverse Cipher (e.g., ShiftRows(), SubBytes(), etc.) transform the State array that is addressed by the ‘state’ pointer. KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk) begin word temp i = 0 while (i < Nk) w[i] = word(key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]) i = i+1 end while i = Nk while (i < Nb * (Nr+1)] temp = w[i-1] if (i mod Nk = 0) temp = SubWord(RotWord(temp)) xor Rcon[i/Nk] else if (Nk > 6 and i mod Nk = 4) temp = SubWord(temp) end if w[i] = w[i-Nk] xor temp i = i + 1 end while end Note that Nk=4, 6, and 8 do not all have to be implemented; they are all included in the conditional statement above for conciseness. Specific implementation requirements for the Cipher Key are presented in Sec. 6.1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有