 In this lesson, we'll be looking at a new type of encryption that's known as a block cipher. So far in this course, we've covered various aspects of cryptography, which can be divided into three different categories. Symmetric ciphers, which are the ciphers that we've seen so far, asymmetric ciphers, which is where we're headed in the next few lessons, and then the specific protocols that put those into action. As I mentioned, we've mostly focused on symmetric ciphers, which can be broken down into two different categories, stream ciphers, and block ciphers. Now, stream ciphers is what we've been focusing on in the past. These include examples such as Caesar cipher, a visionaire cipher, and our more recent examples, the LFSR sum cipher, CSS, and others. What we'll start today with this lesson is focusing more on block ciphers. Now, block ciphers we'll see incorporate by working with whole collections of information, not just a single character at a time. And they're used in our more cutting edge, modern encryption techniques, such as DES, AES, they're used in hash functions, which are used with cryptocurrency, and a lot of other applications. Let's look at the properties that block ciphers have. Block ciphers were invented really to strengthen encryption methods by providing the following characteristics. The first is what's called confusion. And this is just any operation where the relationship between plain text and cipher text becomes obscured. Now, we've done this before in the past. This is nothing new. We might have just called this substitution. So, we've done confusion when we've talked about our Caesar cipher back in the early days of this course, just like we've done confusion when we've used a pseudo random bit stream of the LFSR sum cipher to encrypt a piece of plain text that way. Again, nothing new, so it's a new name for it. Now, the real piece of new encryption that we see here with block ciphers is called diffusion. This is when an operation is applied where the influence of just one plain text symbol is spread out over many cipher text symbols. So, we have not seen this yet, but we're gonna see this adds a big layer of complexity with block ciphers that strengthen encryption quite a bit. We need both of these characteristics for an encryption method in these modern times to be considered strong and secure. We can't just have one or the other, we need to have both. Now, let's take a look at how diffusion, this thing we haven't seen quite yet, plays out in stream ciphers, or I guess we'll see in just a moment, doesn't play out in stream ciphers. Let's take a look at a visionaire cipher here, a nice short one where we know the key word, the plain text and the cipher text. We have the key word math, the plain text toil, which when we apply the key word to the plain text, we give up the cipher text foes. Each symbol in the plain text has obscured the relationship with the symbols in the cipher text. That's confusion at work. So, again, that's a substitution process that we're familiar with. But say we change a single character in the plain text, so we change toll to poll. Now, when we encrypt using the key word math, we get the cipher text boes. That one symbol change in the plain text has only changed one symbol in the cipher text and specifically the corresponding symbol, so the one in the same exact position. This would be a case where there is zero or no diffusion in this process. Now, we see it here with visionaire, but we'll see it again in just a moment on our LFSR cipher. Now, the goal for diffusion should be that one change in the plain text should at least change half of the cipher text symbols. So, here it is again in binary. So, we use our XOR operation here, key word, plain text, cipher text. One change in the character of the plain text on the right hand side, that zero has become a one. We can see that underlined. Only one symbol has changed in the cipher text. Again, still no diffusion when we just XOR. So, these old stream cipher methods that we've seen so far, again, do not provide diffusion. However, here is an example of a block cipher. Now, we'll get into the mechanics of maybe how this was created, but we have a two very similar plain text. Just one bit has been flipped. It's the one underlined on the right hand side. That one has become a zero, but by applying the block cipher, we see that the cipher text has changed quite a bit and in fact, five of those eight bits have been changed in the cipher text just by flipping that one bit in the plain text. So, this has achieved our goal where one symbol in the plain text changing, it changes at least half of the symbols in the cipher text. Now, let's talk about maybe how this happens. What is it about a block cipher that works differently than these stream ciphers we've seen in the past? Most block ciphers are gonna take a fixed size block of plain text. So, that could be like eight characters. It could be 64 bits. And we're gonna convert that into an identically sized block of cipher text by some repeated operations. Those operations need to be invertible, meaning undoable in the opposite direction. That way we can decrypt our messages. And those series of operations are what we call the round function. Each time we run through the round function, we call that a single round. And we'll do that in several different ways. Each round can consist of a substitution stage. And again, that provides the confusion characteristic that we're looking for, which isn't followed by a permutation or also called a mixing stage to provide the diffusion within the block. Some of these block ciphers will also split the plain text into two equal sized halves. And the round function only gets applied to one half using some key. And then we take that output and we XOR it with the other half. And then we just swap the two halves for the next round. This particular method has a name. It's called the Feistel cipher. And many of the ciphers that are block ciphers that are used today, like the US data encryption standard, also known as DES, the Russian or Soviet equivalent, G-O-S-T. And then more recently, two ciphers called blowfish and two fish use this Feistel cipher. So let's take a look at how the Feistel cipher works. Take one block of your data, we'll call that our plain text, and we split it into two halves. We'll call those L sub zero and R sub zero. And then we have a key. And again, the key could be a piece of text. It could be a binary stream or just kind of any piece of information that can be represented numerically. We'll use this as an initial key, but it's gonna get altered for each subsequent round in the information. So you can see here's an added piece of complexity already. The key that we choose will be predictably altered in each subsequent round of these kind of mixings and substitutions of our letters. We're gonna have some function that we'll call F that the F function is what actually provides the confusion and diffusion properties. It's gonna have a series of operations that it contains that provides both those characteristics. In the specifics of how that function works is unique to each cipher type. So DES might have a different series of operations that happened in this round or this component as opposed to AES or Two Fish or any of the others that we mentioned. They all have different properties inside this F. So it's kind of a general placeholder for the part of the round that provides confusion and diffusion or maybe more mathematically speaking, substitution and transposition. We'll take our right half of the block and we'll take that with the key and those are the two inputs to this F function and it will output some information. Could be again, that could be text, it could be a series of binary digits, anything that can be represented numerically and we'll mix that or X or that with the left half of the block which so far hasn't been touched. So the output of this F function must be the same size of just half of our plain text. So if our plain text was 16 characters, the output of the F should be eight characters and the left half of the block should also contain eight characters so then we can have equivalent sized pieces of information to X or together. Take the output of that X or function and the output of the right half of the block, again, we just gotta take an untouched copy and we swap them and they become the left half and the right block and the right half of the new block of information. So again, that new left half is just an exact replica of the previous right half and the new right half is that modified version of the previous left half. We can now have a new block of data and if we just did this one time we might consider that our cipher text. If we did this multiple times then we have what we call a Feistel network and we can see here on the right-hand side that we just kind of repeat this process over and over and over again. We call it N times. So by the time we have L sub N and R sub N together that's our cipher text. Now this is all very kind of conceptual and abstract. We're gonna look at actually creating one of these in detail in a future lesson. So don't worry too much about the exact operations that are taking place. We're gonna take a look at how we can compose those in a very simple way and then show you the more complicated version, DES, that actually how that gets applied in real life. We'll also look at an upcoming lesson about just the simple characteristics of diffusion and confusion that don't require any sort of computer programming. We'll look at a cipher that was used primarily in World War I and even though it's not officially a block cipher, I think it'll do a good job showing you exactly how diffusion and confusion are applied in the context of encryption. So that's it for our introduction to block ciphers. Again, just to summarize, a block cipher will take a group of characters, not just one letter, but a group of characters or digits together, perform a series of operations on them to provide confusion, meaning substitution from the plain text to get to the cipher text and diffusion, where a single change of a character or a digit in the plain text will impact multiple characters or digits in the cipher text. And in the upcoming lessons, we'll start to see these in action.