السلام عليكم ورحمة الله تعالى وبركاته لقد كتبت كود تشفير لخوارزمية الAES ولكن لا اعرف اين الاخطاء
والكود هو
#include<iostream.h>
#include<stdio.h>
KeyExpansion (byte Key[4*Nk), word w[Nb*Nr+1)],Nk)
{
for (i = 0; i < Nk; i++)
ExpandedKey = (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];
ExpandedKey = ExpandedKey[i - Nk] ^ temp;
}
}
KeyExpansion (byte CipherKey, word ExpandedKey)
{
for (i = 0; i < Nk; i++)
ExpandedKey = (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 (itemp = ByteSub (temp);
ExpandedKey = 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)
}
AES (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);
}
decryption()
InvFinalRound (word State, word RoundKey)
{
AddRoundKey (State, RoundKey);
InvShiftRow (State);
InvByteSub (State);
}
InvRound (word State, word RoundKey)
{
AddRoundKey (State, RoundKey);
InvMixColumn (State);
InvShiftRow (State);
InvByteSub (State);
}
InvRijndael (byte State, byte CipherKey)
{
KeyExpansion (CipherKey, ExpandedKey);
InvFinalRound (State, ExpandedKey + Nb*Nr);
for (i = Nr - 1; i > 0; i--)
InvRound (State, ExpandedKey + Nb*i);
AddRoundKey (State, ExpandedKey);
}
InvFinalRound (word State, word RoundKey)
{
AddRoundKey (State, RoundKey);
InvByteSub (State);
InvShiftRow (State);
}
InvRound (word State, word RoundKey)
{
InvMixColumn (State);
AddRoundKey (State, MixColumn (RoundKey));
InvByteSub (State);
InvShiftRow (State);
}
AddRoundKey (State, RoundKey);
InvRound (word State, word RoundKey)
{
InvByteSub (State);
InvShiftRow (State);
InvMixColumn (State);
AddRoundKey (State, MixColumn (RoundKey));
}
InvFinalRound (word State, word RoundKey)
{
InvByteSub (State);
InvShiftRow (State);
AddRoundKey (State, RoundKey)
}
AddRoundKey (State, RoundKey);
InvRound (word State, word RoundKey)
{
InvByteSub (State);
InvShiftRow (State);
InvMixColumn (State);
AddRoundKey (State, MixColumn (RoundKey));
}
InvFinalRound (word State, word RoundKey)
{
InvByteSub (State);
InvShiftRow (State);
AddRoundKey (State, RoundKey)
}
InvRijndael (byte State, byte CipherKey)
{
InvKeyExpansion (CipherKey, InvExpandedKey);
AddRoundKey (State, InvExpandedKey + Nb*Nr);
for (i = Nr - 1; i > 0; i--)
InvRound (State, InvExpandedKey + Nb*i);
InvFinalRound (State, InvExpandedKey);
}
return 0;
}
}