Home Tech Encyclopedia Stream Cipher

Technology Consulting Services

Stream Cipher PDF Print E-mail
A stream cipher is a type of cipher found in symmetric cryptography which essentially combines a byte of “keystream” data with a byte of plain text data to create a byte of ciphertext. Unlike block ciphers which transform discrete-sized “blocks” of data, stream ciphers transform data one byte at a time.

The backbone of the stream cipher is the “keystream function.” A keystream function takes an encryption key as input, and produces “output stream” of bytes. Each byte is the combined (typically XOR'd) with the original plaintext message to create a byte of ciphertext.

A very simple example of a keystream function may be f(x) = 2x. This “double the value” function will basically take an integer as input, and double its value. So, if the input was 3, the output would be 6. If the input were 40, the output would be 80, and so on. Using our “double the value” keystream, let us encrypt the string “hello” using a very primitive stream cipher:

  • Let M = Message, our original plaintext message.
  • Let KS = Keystream
  • Let C = Ciphertext
  • Let I = Iteration number

Encrypt: "hello"

Iteration #
M(i)
Operation
KS(i)
C(i)
1h
     ⊕2·i
j
2
e
     ⊕2·i
a
3
l
     ⊕2·i
j
4
l
     ⊕2·i
d
5
o
     ⊕ 2·ie
Encrypted text = "jajde"

In our first iteration, the keystream function doubles our input value 1, to produce 2. The number 2 is XOR'd with the ASCII value of 'h' (104) to produce a value of 106, which has an ASCII representation of 'j.' The second iteration follows the same format, doubling iteration value 2. The third iteration again follows the same format, but doubles the iteration value 3. The fourth iteration has a keystream output value of 8, and the fifth and final iteration has a keystream output of 10.

To decyrpt the ciphertext, we simply XOR each byte of ciphertext with each byte of keystream data by using the same encryption keys for decryption:


Decrypt: "jajde"

Iteration #
C(i)
Operation
KS(i)
M(i)
1j
     ⊕2·i
h
2
a
     ⊕2·i
e
3
j
     ⊕2·i
l
4
d
     ⊕2·i
l
5
e
     ⊕ 2·io
Decrypted text = "hello"


Stream ciphers are extremely fast algorithms, but are prone to brute force and integrity attacks. As such, stream ciphers are often hardened with supplemental cryptography techniques such as message authentication codes (MACs). Various symmetric ciphers have been in use since the late 1980s, but the most widely used stream-based cipher is the RC4 (“Rivest Cipher 4”) algorithm, invented in 1987 by Ron Rivest of RSA.
Last Updated on Saturday, 21 November 2009 09:27
 

Add comment


Security code
Refresh


Atomic Fission, Information Technology Services, San Francisco, CA

Cloud Certification


Latest Comments

  • Thank you...this was very helpful
  • Nice well explained.
  • Yes, and Juniper now supports multiple proxyIDs in...
  • I think ProxyID is a Juniper thing.
  • What is proxy ID exactly? It is synonymous with se...

Atomic Fission RSS

feed-image Feed Entries