Introduction:

Stream Cipher:

In a stream cipher, the input data (plaintext) is processed through one unit at a time. The data unit can be a byte or more commonly one bit. Every data unit is encrypted independently from previous or following bits. The result is output data (ciphertext) of the same data unit size as the input.

In simple terms, using stream cipher: every one bit/byte of plaintext is encrypted at a time producing a corresponding bit/byte ciphertext.

<aside> 💡 Using the above generic understanding of stream ciphers, and using a data unit of one ascii character (which is a byte), we can classify One Time Pad (OTP), simple substitution and affine ciphers as stream ciphers, as they process one character at a time.

</aside>

However, modern stream ciphers use keystream generation algorithms and the XOR operation, as we will describe shortly. This is why the above ciphers are no longer described as stream ciphers.

Examples of common modern stream ciphers include Rivest Cipher 4 (RC4), SEAL, Scream, Rabbit, Salsa20 and ChaCha. A description of how stream ciphers work is presented below:

Untitled

In the above chart, the encryption is XOR of the keystream bit with the corresponding plainstream bit, and decryption is the XOR of the cipherstream bit with the corresponding keystream bit.

<aside> 💡 One notable challenge with stream ciphers is how to generate the key stream? A common practice is to use a Pseudorandom number generator (PRNG) to generate bits/bytes as needed. This would require using the same seed at both ends to generate the same keystream.

</aside>

Stream ciphers are noted for their simplicity, hardware compatibility, and speed. They are suitable for real-time applications in which the data size is unknown, and for applications that require lightweight encryption. They are also widely used in wireless communication protocols.

Block Cipher:

In a block cipher, data is processed in terms of blocks, not simple data units. But how do we choose the block size, and how do we process each block? Let us first learn about the desired design properties for a "good" block cipher.

Block Cipher Requirements:

Block ciphers in modern cryptography refers to ciphers that satisfy two main features. The first is regarding size and the second is regarding security.

Using the above definition, every plaintext or ciphertext block occupies n-bits and there are $2^n$ possible combinations for each block. Typical block sizes are 64, 128, 256, 512 and 1024 bits. When using a block size of 256 bits, there are $1.158 \times 10^{77}$ possible combinations for each block, which is infeasible to break using brute-force attacks.