Advanced Encryption Standard is an encryption algorithm that was developed by two Belgian Cryptographers Vincent Rijmen and Joan Daemen.

The algorithm which was originally named Rijndael (A combination of the surnames of the developers) was submitted to the National Institute of Standards and Technology (NIST) as an entry for the competition that was organized to find a new encryption algorithm to replace the Data Encryption Standard (DES) that had been found to be defective due to its small key size (64 bits).

In 2001, NIST officially established AES as the encryption standard for electronic data. It uses a block cipher which breaks plain text into blocks of 128 bits in length. It’s key size, however, can be 128, 192 or 256 bits in length.

How AES works

Following in the tradition we’ve established in the previous post, let’s look at AES as a box that receives plain text, performs some operations on them using a key and then generates a resulting cipher text.

So here it is:

The AES box

Now let’s open up the AES box.

AES uses a block cipher means of encryption i.e. before performing any operations on the plain text, it first breaks it into blocks, each block is 128 bits in length. It then takes one block at a time and encrypts, at the end of the encryption of all blocks, it puts all the blocks back together so you have a string of cipher text as long as the original plain text.

The key sizes could either be 128, 192 or 256 bits in length depending on the type of AES algorithm being used i.e. AES-128, AES-192 or AES-256. For the purpose of this article, we shall be using a key size of 128 bits. The same processes apply to the AES-192 and AES-256, the only thing that differs is the key size.

Now, let’s move on. When a block of plain text enters into the AES, the first operation that is performed on it is the mathematical XOR bitwise operation. It performs this operation not against the key, but against a sub-key that is generated from the original key.

Let me explain,

For every operation AES performs on the plain text, it generates a random sub-key from the original key which is of course equal in length to the original key. That way one can never predict what key AES is using for each operation. So, for example, to perform the first operation on the plain text, it generates a random sub-key from the original key, uses it, when it’s done, it gets rid of it, for the second operation, it generates another sub-key still from the original key, uses it, when it’s done, it gets rid of it and so on till all operations are complete.

That’s pretty smart of AES right?

Let’s go back to the operations of AES. Like I said at the beginning of this paragraph, the first operation AES performs on the block of plain text is the mathematical XOR bitwise operation using the first sub-key generated. To understand how the XOR bitwise operation works, you can read it here.

After the XOR bitwise operation, it then goes through at least 10 rounds of a particular operation (which we would look at shortly but for now let’s just refer to it as a box) then the resulting output is the final cipher text. Please note that the output of a particular operation serves as input for the next operation that comes after it.

Now let’s look at the opened AES box so you can picture all I’ve said so far.

AES opened up to show it's operations

Now let’s take a look at the operation I talked about in the previous paragraph (the box), yea the one I said goes at least 10 rounds (The number of rounds it goes depends on the type of AES algorithm being used but it’s at least 10). You can see the color of the box in the diagram above is orange just so we can identify it.

Let’s open up the box and see what really happens in this operation.

The inner AES operation opened up

When the result from the first operation (bitwise XOR) enters this box, there are four operations that are carried out which are purely mathematical; substitution, transposition, substitution again then a bitwise XOR (yea, again). The only operation that needs the newly generated sub-key is the bitwise XOR operation.

For the first substitution, the block of 128-bit text is split into blocks of 16 bytes each and then the bytes are substituted with each other i.e 1 block of 16 bytes is substituted with another block of 16 bytes till all bytes have been substituted. The procedure for substitution is defined in a table consisting of 256 entries that define how each block bytes should be substituted because there are 256 possible ways for substituting them.

The result of this operation is then passed on to another operation called transposition.

After transposition, substitution occurs again, but this time the block of 128-bits text is broken into smaller blocks which are 4 bytes in length as opposed to the 16 bytes in the first substitution. The method of substitution is defined by a formula not a table as in the first. That’s because there are 2^32 (4,294,967,296) possible ways of substituting them which is way too much to be put in a table.

After the second substitution occurs, a bitwise XOR operation is carried out.

These 4 operations make up one round that AES does, it repeats this round at least 10 times before producing a final output of block cipher text.

So let’s take a look at what the final expanded box of AES looks like:

All the boxes opened up

So we see that AES is just all about performing repetitive mathematical operations on a block of text using a key just to make it exteremly hard to decrypt.

So that’s AES, in a later post, we shall see how all these come to play in practical sense. A good example is in SSL/TLS. For now, bye.