Block Ciphers (An Intro To Crypto Algorithms ) - Cryptography 101 Post #7

Cryptographic Algorithms

There are three main types of crypto algorithms.

  • Symmetric
  • Asymmetric
  • Hash Functions

Individually, these algorithms all serve a specific purpose. Put them together and you have what is called a cryptographic systems. Let's start by talking about symmetric algorithms.

As stated in a previous post, symmetric algorithms use the same key for both the encryption and decryption of the message. One time pads and the enigma machine are both considered to use encryption algorithms.

The one time pads, while able to achieve the maximum level of entropy, had a flaw in that the key was actually longer than the messages. This made it very difficult to send messages.

One solution to this might be to use a fixed-length key. However, this in of itself presents a problem. How can you encrypt a message of arbitrary length, if the key is of a fixed length?

The solution that was invented for that problem is called a block cipher. Here's how they work.

A block cipher divides the message you intend to send into blocks or chunks, hence the name block cipher. After that, each block or chunk of the message is encrypted independently. A typical block is 16 bytes.

A block cipher will work on a chunk of a message in what are called rounds.

Rounds

First part of the key is applied, and then other operations are performed on this block of the message. After a certain number of rounds, typically between 10 and 16, we end up with our cipher text. ta daaaaaa! The cipher text block is the exact same size as the message block (16 bytes).

For each round, we operate on a chunk of a message with a part of the symmetric key called the round key. Where does the round key come from?

Well, we derive the various round keys from the symmetric key, using what is called a key schedule. This key schedule performs shifts XOR and multiplication on the original symmetric encryption key, in order to get these round keys.

Now at this point you may be asking "If we're deriving the round keys from the original symmetric key to XOR the block message, why can't we just XOR the block message directly with the key"?

That's a fair question. In order to understand the answer it helps to first look at confusion and diffusion.

Confusion and Diffusion

picture of Claude E. Shannon
Picture of Claude E. Shannon

Claude up there above authored a paper titled Communication Theory of Secrecy Systems. he introduces the concept of confusion and diffusion in this paper.

Confusion is the relationship between the key and the cipher text(encrypted message)
Diffusion is the relationship between the message and the cipher text.

If we confuse the relationship between the key and cipher text, we ensure that a small change in the key results in a large change in the cipher text.

If we were to XOR the block message with the symmetric key, this would not be enough, because a one bit change to the key would only result in a one bit change to the cipher text. That's not good by the way. So that's why we use a key schedule. So that a small change in the key creates big changes in the cipher text.

With diffusion, we want to diffuse the information throughout the message. We want a small change in the message to result in a large change in the cipher text. So to separate confusion and diffusion it's like this.

Confusion is meant to hide the key, and diffusion is meant to hide the message.