Symmetric Encryption 81 DATA PADDING H E L L O 3 3 3 DATA PADDING T E S T 4 4 4 4 PADDING 8 8 8 8 8 8 8 8 BLOCK BLOCK BLOCK If we have data that ends on an even multiple of 8 bytes, we need to add an entire block of padding. This way, we know that there is always padding that must be removed after decryption. Mode In addition to specifying the padding, we also need to specify the mode for a block cipher before using it. The mode defines how a cipher should apply an encryption algorithm. Changing the mode can allow a block cipher to function as a stream cipher. Block ciphers operate on data a block at a time, where a block can be any number of bits, usually 64 or 128. A stream cipher, on the other hand, can encrypt or decrypt data a byte at a time, making it much more useful for streaming applications, like network communication. We will discuss some of the more common modes below. ECB (Electronic Code Book) ECB is the simplest mode: the same plaintext block will always encrypt to the exact same ciphertext block. This is fine for sending single chunks of data, like a key, but not good for implementing an encrypted stream of information. This is because if the same plaintext is sent multiple times, the same ciphertext will also be sent. Let's say we're sending the following message in a chat application, "meet me later", and we're sending it one character at a time. The following might be our ciphertext if we were using DES: mD8hEmbih6E= m TRw+doCp3EQ= e TRw+doCp3EQ= e Dj3lTDsRkxw= t mD8hEmbih6E= m TRw+doCp3EQ= e xXyJjiHigk8= l x26P5lw+XyM= a Dj3lTDsRkxw= t TRw+doCp3EQ= e XIoLD1MHGO4= r