ADVANCED ENCRYPTION STANDARD [AES]
BY
                         Dr SAPNA P J
                                             WHY AES?
 A drawback of DES is the use of 64-bit block size.
 For reasons of both efficiency and security, a larger
   block size is desirable.
 As a replacement, Advanced Encryption Standard
   was proposed
 NIST specified that AES must be a symmetric
  block cipher with a block length of 128 bits and
  support for key lengths of 128, 192, and 256 bits.
 NIST selected Rijndael as the proposed AES
  algorithm
                                      RIJNDAEL
 Rijndael was designed to have the following characteristics:
      ● Resistance against all known attacks
      ● Speed and code compactness on a wide range of platforms
      ● Design simplicity
 The input to the encryption and decryption algorithms is a single 128-bit block.
 This block is depicted as a square matrix of bytes
 key is expanded to array of words
 Four transformations in the rounds:
   Byte substitution (1 S-box used on every byte)
   Shift rows (permute bytes between groups/columns)
   Mix columns (uses matrix multiplication of groups)
   Add round key (XOR state with key material)
                                     BYTE SUBSTITUTION
 The Substitute bytes stage uses an S-box to
  perform a byte-by-byte substitution of the block.
 There is a single S-box used on every byte.
 This S-box is a permutation of all 256 8-bit values,
  constructed using a transformation which treats the
  values as polynomials in GF(28)
 Each byte of state is replaced by byte indexed by
  row (left 4-bits) & column (right 4-bits)
 Eg. byte {95} is replaced by byte in row 9 column 5
  which has value {2A}
                                    SHIFT ROWS
 A circular byte shift in each
   1st row is unchanged
   2nd row does 1 byte circular shift to left
   3rd row does 2 byte circular shift to left
   4th row does 3 byte circular shift to left
 Decrypt inverts using shifts to right
 Since state is processed by columns, this
  step permutes bytes between the
  columns
                                      MIX COLUMNS
 Each column is processed separately
 Each byte is replaced by a value dependent on all 4 bytes in the column
 Each byte of a column is mapped into a new value that is a function of all four bytes in that
  column.
 It is designed as a matrix multiplication
Addition is the bitwise XOR operation and that multiplication can be performed according to the
rule. In particular, multiplication of a value by x (i.e., by {02}) can be implemented as a 1-bit
left shift followed by a conditional bitwise XOR with (0001 1011) if the leftmost bit of the
original value (prior to the shift) is 1.
MixColumns transformation on the first column
                                ADD ROUND KEY
 Add Round Key stage which is a simple bitwise XOR of the current block with a
  portion of the expanded key
 Note this is the only step which makes use of the key and obscures the result, hence
  MUST be used at start and end of each round, since otherwise could undo effect of
  other steps.
 But the other steps provide confusion/diffusion/non-linearity.
 Thus you can look at the cipher as a series of XOR with key then scramble/permute
  block repeated.
 This is efficient and highly secure
 In the forward add round key transformation, called AddRoundKey, the 128 bits of State are
   bitwise XORed with the 128 bits of the round key
 The operation is viewed as a columnwise operation between the 4 bytes of a State column and one
   word of the round key; it can also be viewed as a byte-level operation.The following is an example of
   AddRoundKey:
 The inverse add round key transformation is identical to the forward add round key
  transformation, because the XOR operation is its own inverse.
                                        AES KEY EXPANSION
 Expansion of the key into 11 partial keys which are used in initial round , 9 main rounds and final round
 The AES key expansion algorithm takes as input a 4-word (16-byte) key and produces a linear array of
   44 words (176 bytes).
 RotWord performs a one-byte circular left shift on a word. This means that an input word [b0,b1, b2, b3] is
   transformed into [b1, b2, b3, b0].
 Subbytes performs a byte substitution on each byte of its input word, using the S-box
 The result of steps 1 and 2 is XORed with a round constant and the column four positions earlier
 This result is Xored with 2nd column . This result is Xored with third column . This will result in round key 1