/*
 * The MixColumns transformation of AES
 */
void MixColumns( unsigned char state[4][4] )
{
  int col,row,k;
  unsigned char tmp[4][4];

  memset ( tmp, 0, 4*4 );

  for(col=0; col<4; col++){
    for(row=0; row<4; row++){
      for(k=0; k<4; k++)
    tmp[row][col] ^= FieldMult( MC[row][k], state[k][col] );
    }
  }
  memcpy( state, tmp, 4*4 );
}
Beispiel #2
0
void MixColumn(unsigned char state[4][4])
{
	int i, j, k;
	unsigned char tmp[4];
	for(j = 0; j < 4; j++){
		for(i = 0; i < 4; i++) {
			unsigned char sum = 0;
			for(k = 0; k < 4; k++)
				sum ^= FieldMult(MixColMatrix[i][k], state[k][j]);
			tmp[i] = sum;
		}
		for(i = 0; i < 4; i++)
			state[i][j] = tmp[i];
	}
}