Лабораторная работа: Методы и средства защиты компьютерной информации
for (i = Nk; i<Nb* (Nr+1); i++)
{
temp = ExpandedKey [i - 1] ; if (i% Nk == 0)
temp = ByteSub (RotByte (temp)) ^Rcon [i/Nk] ; ExpandedKeyp] = ExpandedKey [i - Nk] ^temp;
}
}
ГенерацияключаприLk = 8:
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 = ByteSub (RotByte (temp)) ^Rcon [i/Nk] ; else if (i% Nk == 4)
temp = ByteSub (temp); ExpandedKey [i] = ExpandedKey [i - Nk] ^temp;
}
}
Раундовыефункции:
Round (word State, word RoundKey)
{
ByteSub (State);
ShiftRow (State); MixColumn (State); AddRoundKey (State, RoundKey)
FinalRound (word State, word RoundKey) {
ByteSub (State);
ShiftRow (State);
AddRoundKey (State, RoundKey)
}
Полная процедура зашифрования блока текста: