Cryptography

# Understanding stream ciphers in cryptography

January 11, 2021 by Nitesh Malviya

Stream ciphers fall under the symmetric encryption category. Thus, using stream ciphers the sender and the recipient of the data use the same key to encrypt and decrypt the data.

A stream cipher is different from a block cipher. In a stream cipher one byte (8 bit) of data is encrypted at a time while in block cipher, a block of data is encrypted at a time (usually 128 bits).

## What is a keystream?

Stream ciphers make use of something called keystream. A keystream is a random 8-bit output that is generated by supplying a key to a pseudorandom bit generator. The 8-bit output generated is called keystream and is used in the encryption and decryption of data in a given stream cipher algorithm.

## Encryption

### Steps

1. For encryption, plain text and keystream are required.
2. The plain text and keystream produce ciphertext using XOR Operation.
3. Plain text is XOR’ed with keystream bit by bit to produce CipherText.

### Example

Plain Text: 10011001

Keystream: 11000011

———————

Ciphertext: 01011010

## Decryption

### Steps

1. For decryption, ciphertext and the same keystream are required which was used for encryption.
2. The ciphertext and the keystream produce plain text using XOR Operation.
3. The ciphertext is XOR’ed with keystream bit by bit to produce PlainText.

### Example

Ciphertext: 01011010

Keystream: 11000011

———————-

Plain Text: 10011001

## Popular stream ciphers

Following are the popular stream ciphers used for encrypting the data.

• RC4
• SALSA
• SOSEMANUK
• PANAMA

## Block cipher and stream cipher differences

Following are the differences between block cipher and stream cipher in tabulated form.

 Block Ciphers Stream Ciphers Block Ciphers converts plain text to cipher text by taking a block at a time Stream Ciphers converts plain text to cipher text by taking 1 byte of plain text at a time Block Ciphers encrypt 64 bits or more at a time Stream Ciphers encrypt 8 bits at a time. It is more simple than Stream Ciphers It is more complex than Block Ciphers It uses confusion as well as diffusion. It uses only confusion. Reverse Encryption is harder Reverse Encryption is very simple Slower than stream cipher Faster than block cipher It works on transposition techniques like Caesar cipher, polygram substitution cipher etc. It works on substitution techniques like rail-fence technique, columnar transposition technique etc.

### Sources

Posted: January 11, 2021
##### Nitesh Malviya
View Profile

Nitesh Malviya is a Security Consultant. He has prior experience in Web Appsec, Mobile Appsec and VAPT. At present he works on IoT, Radio and Cloud Security and open to explore various domains of CyberSecurity. He can be reached on his personal blog - https://nitmalviya03.wordpress.com/ and Linkedin - https://www.linkedin.com/in/nitmalviya03/.