AES 128 bit, 192 bit, 256 bit

I was able to successfully create my own implementation of AES using a 128-bit key. However, I'm still chatting how to interpret the AddRoundKey function using 192-bit and 256-bit keys.

Some facts:

  • Block - 128 bit (state)
  • Rounds 128bit = 10, 192bit = 12, 256bit = 14
  • Nk 128bit = 4 (equal to block size), 192bit = 6, 256bit = 8 (word units)

If Nk = 8 and i-4 is a multiple of Nk, then SubWord () applies to w [i-1] before XOR.

Does anyone know how 192-bit and 256-bit keys are applied? Any answers are welcome.

+3
source share
1 answer

I think you have things somewhat embarrassed. From FIPS-197:

AddRoundKey() XOR. Nb

, AddRoundKey() . FIPS-197:

KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk)
begin
word temp
i = 0
while (i < Nk) # copy key to first Nk bytes of key sched. w is the key sched.
    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)] # for remaining key schedule size
    temp = w[i-1]       # get previous word
    if (i mod Nk = 0)   # if i is a multiple of Nk a.k.a. every key length
        temp = SubWord(RotWord(temp)) xor Rcon[i/Nk]
    else if (Nk > 6 and i mod Nk = 4) # this for 256-bit keys only
        temp = SubWord(temp)
    end if
    w[i] = w[i-Nk] xor temp  # the xor operation
    i = i + 1                # if you've used a for loop, ignore this.
end while

. NK . xor , NK, , FIPS-197, xor'd (i/Nk , i% Nk == 0).

, : Nk > 6, , 256- , i mod Nk == 4 .. (q*Nk)+4 i q, pre -xor .

, , , temp.

256- .

, , , - , FIPS-197 NIST AES. ; , , .

+3

Source: https://habr.com/ru/post/1793456/


All Articles