【问题标题】:Why does AES decryption have one less round than AES encryption?为什么AES解密比AES加密少一轮?
【发布时间】:2017-02-18 13:01:50
【问题描述】:

我正在做一些关于 AES 的工作,并且我看到了很多伪代码,例如,如果加密在 10 轮中完成,解密则在 9 轮中完成。确切地说,主要是这个:

http://people.eku.edu/styere/Encrypt/JS-AES.html

这正常吗?有什么我想念的吗?是不是真的10轮解密但是我读错了代码?

【问题讨论】:

标签: javascript encryption cryptography aes


【解决方案1】:

真正的问题是为什么人们相信这些网站发布了一些糟糕的 JavaScript 密码版本。

这是来自FIPS 197 的官方 NIST 伪代码:

Cipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])
begin
    byte state[4,Nb]
    state = in
    AddRoundKey(state, w[0, Nb-1])
    for round = 1 step 1 to Nr–1
        SubBytes(state)
        ShiftRows(state)
        MixColumns(state)
        AddRoundKey(state, w[round*Nb, (round+1)*Nb-1]) end for
    SubBytes(state)
    ShiftRows(state)
    AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
    out = state
end

InvCipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])
begin
    byte state[4,Nb]
    state = in
    AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
    for round = Nr-1 step -1 downto 1
        InvShiftRows(state)
        InvSubBytes(state)
        AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])
        InvMixColumns(state) end for
    InvShiftRows(state)
    InvSubBytes(state)
    AddRoundKey(state, w[0, Nb-1])
    out = state 
end

然后砰,不一样了。您指向的站点在加密例程中出现了错误,taking it up to 11

在寻找代码时,测试向量使用原始或原始文档和规范

【讨论】:

  • 谢谢!也感谢您的提示!我只是担心 AES 中是否有一些隐藏的细节使伪代码正确或其他什么,哈哈哈。再次感谢!
猜你喜欢
  • 1970-01-01
  • 2016-09-22
  • 2012-02-24
  • 2021-11-23
  • 1970-01-01
  • 2015-01-20
  • 2014-01-05
  • 2019-01-06
  • 1970-01-01
相关资源
最近更新 更多