Cryptography Reference
In-Depth Information
end do;
for i from 0 to 3 do
st[2,i]:=bitXortable[state[0,i], bitXortable[state[1,i],
bitXortable[multtable[state[2,i],2], multtable[state[3,i],3]]]]
end do;
for i from 0 to 3 do
st[3,i]:=bitXortable[multtable[state[0,i],3], bitXortable[state[1,i],
bitXortable[state[2,i], multtable[state[3,i],2]]]]
end do;
st
end proc:
The inverse operation is similarly defined, multiplying by the inverse matrix
over
F 2 8 of the one used in the function MixColumns . This inverse is given by
Matrix([seq(ListTools:-Rotate([14,11,13,9],-i),i=0..3)]) .
As before, we define this multiplication directly using the operation tables of
F 2 8 .
> InvMixColumns := proc(state)
local st, i;
st := Array(0..3, 0..3);
for i from 0 to 3 do
st[0,i]:=
bitXortable[multtable[state[0,i],14],bitXortable[multtable[state[1,i],11],
bitXortable[multtable[state[2,i],13], multtable[state[3,i],9]]]]
end do;
for i from 0 to 3 do
st[1,i]:=
bitXortable[multtable[state[0,i],9],bitXortable[multtable[state[1,i],14],
bitXortable[multtable[state[2,i],11], multtable[state[3,i],13]]]]
end do;
for i from 0 to 3 do
st[2,i]:=
bitXortable[multtable[state[0,i],13],bitXortable[multtable[state[1,i],9],
bitXortable[multtable[state[2,i],14], multtable[state[3,i],11]]]]
end do;
for i from 0 to 3 do
st[3,i]:=
bitXortable[multtable[state[0,i],11],bitXortable[multtable[state[1,i],13],
bitXortable[multtable[state[2,i],9], multtable[state[3,i],14]]]]
end do;
st
end proc:
4.4.1.4 AddRoundKey
The AddRoundKey operation is the result of Xor-ing the bytes in the state matrix
with those in the corresponding round subkey of the expanded key (i.e., the new state
matrix is obtained by adding over
F 2 8 the round subkeymatrix to the old statematrix).
We do not define the inverse operation because AddRoundKey is its own inverse.
> AddRoundKey := proc(roundk, state)
local i, j;
for i from 0 to 3 do
for j from 0 to 3 do
state[i, j] := bitXortable[state[i, j], roundk[i, j]]
end do
end do;
state
end proc:
Search WWH ::




Custom Search