电子大神的日记本,供应链专家的功夫茶盘,在这里记录、分享与共鸣。

登录以开始

AES加密算法 03

密钥扩展部分也有几个function
subword 进s盒
rotword 转 s0,s1,s2,s3转完了变成s1,s2,s3,s0
rcon  又是一个表 wiki链接
http://en.wikipedia.org/wiki/Rijndael\_key\_schedule\#Rcon
pdf文档中给了伪代码
解释一下变量
Nb 列数 Number of columns (32-bit words) comprising the State. For this
standard, Nb = 4. (Also see Sec. 6.3.)
Nk 密钥数 Number of 32-bit words comprising the Cipher Key. For this
standard, Nk = 4, 6, or 8. (Also see Sec. 6.3.)
Nr 加密轮数 Number of rounds, which is a function of Nk and Nb (which is
fixed). For this standard, Nr = 10, 12, or 14. (Also see Sec. 6.3.)
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

博主
bluejudas@hotmail.com
bluejudas's Blog
bluejudas
点击跳转