Cryptography Reference
In-Depth Information
Key generation:
KeyExpansion (byte CipherKey, word ExpandedKey)
{
for (i = 0; i < Nk; i++)
ExpandedKey[i] = (CipherKey[4*i], CipherKey[4*i + 1],
CipherKey[4*i + 2], CipherKey[4*i + 3]);
for(i=Nk;i<Nb*(Nr+1);i++)
{
temp = ExpandedKey[i - 1];
if(i%Nk==0)
temp = SubBytes (RotBytes (temp)) ˆ Rcon[i/Nk];
else if ((Nk == 8) && (i % Nk == 4))
temp = SubBytes (temp);
ExpandedKey[i] = ExpandedKey[i - Nk] ˆ temp;
}
}
Round functions:
Round (word State, word RoundKey)
{
SubBytes (State);
ShiftRows (State);
MixColumns (State);
AddRoundKey (State, RoundKey)
}
FinalRound (word State, word RoundKey)
{
SubBytes (State);
ShiftRows (State);
AddRoundKey (State, RoundKey)
}
Entire operation for encrypting a block:
Rijndael (byte State, byte CipherKey)
{
KeyExpansion (CipherKey, ExpandedKey);
AddRoundKey (State, ExpandedKey);
for (i = 1; i < Nr; i++)
Round (State, ExpandedKey + Nb*i);
FinalRound (State, ExpandedKey + Nb*Nr);
}
Search WWH ::




Custom Search