Computer Science Tutorial

Advanced Encryption Standard

AES is a technique first invented by US Govt. in 2001 to protect sensitive information from attackers. In this technique we convert a plaintext into a ciphertext using a symmetric key algorithm.

Say, A wants to send some information to B securely. First, A will encrypt the the plaintext using symmetric key algorithm and generates a ciphertext. This ciphertext was sent to the B. Now, B already has the same secret key, using the same key B will decrypt the ciphertext and get the plaintext back.

In this technique even if the attacker or hacker gets the encrypted ciphertext, he can not decrypt it, since he doesn’t have the secret key. So, apart from sender and receiver no one can get the information.

In symmetric key algorithm, same key is used by both sender and receiver, hence it is called symmetric key algorithm. But, in asymmetric key algorithm different keys are used by the sender and receiver to encrypt and decrypt the data. The length of the secret key is 128, 192 or 256 bits, that is, key length always an multiple of 32 having minimum length is 128 and maximum is 256.

How AES works?

AES works by organising the plaintext into a block. A block is like a 4X4 matrix of size 128 bits. A 4X4 matrix have 16 elements and each element takes 1 byte that is 8 bits, so total size equals to 16*8 = 128 bits or 16 bytes. The data or plaintext that we want to send in a encrypted form is first organised into a 4X4 matrix. Suppose, the message is “Please do me a favor” which you want to send in a encrypted form. So the letters in the message will be organized into a block or 4x4 column major matrix like this.
    |   P   s   o       |
    |   l   e       a   |
    |   e       m       |
    |   a   d   e   f   |

For the rest of the message another block will be generated. Now, say the secret key is "keys are boring", this key is also shown in matrix form. Here, I have taken 128 bit key length. Now we will encrypt our message with this key using a symmetric key algorithm. This is a sequence of steps. Key in a block form will look like this.
    |   k            i  |
    |   e   a   b    n  |
    |   y   r   o    g  |
    |   s   e   r       |

Now, round keys are generated from these keys using AES key schedule.
    |   14   2e  74    ni  |
    |   h9   a9  4b    n7  |
    |   gt   r2  5o    g1  |
    |   ks   4r  0r    6y  |

Generated round key and orginal message is added using bitwise XOR operation to produce an semi encrypted message like this.
|   jb     n3    kf     n2    |
|   9f     jj    1h     js    |
|   74     wh    0d     18    |
|   hs     17    d6     px    |

After this operation four more operations are processed, these are
  1. Substitute bytes
  2. Shift rows
  3. Mix columns
  4. Add round key again
This complete one round in the encryption process. A minimum of 10 such rounds are carried away to generate final encrypted ciphertext.

After encryption the original message "Please do me a favor" will look like this "ok23b8a0i3j 293uivn5tgdr5u7x8y9k". This may look like a random numbers, but these are not random numbers. These are the numbers generated by applying AES algorithm on the message and secret key combined. This ciphertext is sent to the receiver. At the receiving end, the receiver performs all the operations but in reverse order to obtain the original message.
Next Page
BN Computer Academy
All Rights Reserved