Example #1
0
 /// <summary>
 /// Generates the round constants using GF(2^8) arithmetic.
 /// </summary>
 /// <returns> The round constants. </returns>
 public static byte[] generateRoundConstants() //creates the round constants used in the key generation
 {
     byte[] constants = new byte[ROUNDS - 1];  //the first round uses the 128 bit key so no constant for that.
     constants[0] = 1;
     for (int ii = 1; ii < constants.Length; ii++)
     {
         constants[ii] = GF_TABLE.multiply(constants[ii - 1], 0x02);
     }
     return(constants);
 }
Example #2
0
 /// <summary>
 /// Conducts the mixColumns step of the AES algorithm. Now Deprecated
 /// </summary>
 public void mixColumns()
 {
     byte[] newBytes = new byte[SIZE];
     for (int ii = 0; ii < newBytes.Length; ii++)
     {   //2, 3, 1, 1 are hard-coded into the algorithm for the GF(2^8) multiplication here.
         newBytes[ii] = (byte)(GFBox.multiply(2, bytes[startValue + ii]) ^
                               GFBox.multiply(3, bytes[startValue + WORD_LENGTH * (ii / WORD_LENGTH) + (ii + 1) % WORD_LENGTH]) ^
                               bytes[startValue + WORD_LENGTH * (ii / WORD_LENGTH) + (ii + 2) % WORD_LENGTH] ^
                               bytes[startValue + WORD_LENGTH * (ii / WORD_LENGTH) + (ii + 3) % WORD_LENGTH]);
     }
     Array.Copy(newBytes, 0, bytes, startValue, SIZE);
 }