Exemplo n.º 1
0
void InvMixColumns(BYTE State[4][4])
{
	BYTE temp[4*4];
	DWORD i,j;
	for (i = 0; i < 4; i++)  							// copy State DWORDo temp[]
	{
        for (j = 0; j < 4; j++)         				//0e 0b 0d 09 		 Page108
        {												//09 0e 0b 0d
			temp[4*i+j] =  State[i][j];					//0d 09 0e 0b
        }												//0b 0d 09 0e
	}
	
	for (j = 0; j < 4; j++)
	{
		State[0][j] = (BYTE) ( (DWORD)gfmultby0e(temp[j]) ^ (DWORD)gfmultby0b(temp[4+j]) ^
			(DWORD)gfmultby0d(temp[4*2+j]) ^ (DWORD)gfmultby09(temp[4*3+j]) );
		State[1][j] = (BYTE) ( (DWORD)gfmultby09(temp[j]) ^ (DWORD)gfmultby0e(temp[4+j]) ^
			(DWORD)gfmultby0b(temp[4*2+j]) ^ (DWORD)gfmultby0d(temp[4*3+j]) );
		State[2][j] = (BYTE) ( (DWORD)gfmultby0d(temp[j]) ^ (DWORD)gfmultby09(temp[4+j]) ^
			(DWORD)gfmultby0e(temp[4*2+j]) ^ (DWORD)gfmultby0b(temp[4*3+j]) );
		State[3][j] = (BYTE) ( (DWORD)gfmultby0b(temp[j]) ^ (DWORD)gfmultby0d(temp[4+j]) ^
			(DWORD)gfmultby09(temp[4*2+j]) ^ (DWORD)gfmultby0e(temp[4*3+j]) );
	}
}
Exemplo n.º 2
0
Arquivo: aes.c Projeto: SamuelXu/clibs
void InvMixColumns(ctx_aes* aes)
{
	unsigned char temp[4*4];
	int r,c;
	for (r = 0; r < 4; r++)  // copy State into temp[]
	{
        for (c = 0; c < 4; c++)
        {
			temp[4*r+c] =  aes->State[r][c];
        }
	}
	
	for (c = 0; c < 4; c++)
	{
		aes->State[0][c] = (unsigned char) ( (int)gfmultby0e(temp[c]) ^ (int)gfmultby0b(temp[4+c]) ^
			(int)gfmultby0d(temp[4*2+c]) ^ (int)gfmultby09(temp[4*3+c]) );
		aes->State[1][c] = (unsigned char) ( (int)gfmultby09(temp[c]) ^ (int)gfmultby0e(temp[4+c]) ^
			(int)gfmultby0b(temp[4*2+c]) ^ (int)gfmultby0d(temp[4*3+c]) );
		aes->State[2][c] = (unsigned char) ( (int)gfmultby0d(temp[c]) ^ (int)gfmultby09(temp[4+c]) ^
			(int)gfmultby0e(temp[4*2+c]) ^ (int)gfmultby0b(temp[4*3+c]) );
		aes->State[3][c] = (unsigned char) ( (int)gfmultby0b(temp[c]) ^ (int)gfmultby0d(temp[4+c]) ^
			(int)gfmultby09(temp[4*2+c]) ^ (int)gfmultby0e(temp[4*3+c]) );
	}
}  // InvMixColumns