Stream Cipher 101: Definition, Usage & Comparisons
Stream Cipher 101: Definition, Usage & Comparisons
A stream cipher is an encryption technique that works byte by byte to transform plain text into code that's unreadable to anyone without the proper key.
Stream ciphers are linear, so the same key both encrypts and decrypts messages. And while cracking them can be difficult, hackers have managed to do it.
For that reason, experts feel stream ciphers aren't safe for widespread use. Even so, plenty of people still lean on the technology to pass information through the internet.
How do stream ciphers work?
All cryptographic methods aim to scramble data to hide it from outsiders. But unlike their counterparts, stream ciphers work on each bit of data in a message rather than chunking the message into groups and encrypting them in blocks.
Stream ciphers rely on:
- Plaintext. You must have a message you'd like to encode.
- Keystreams. A set of random characters replaces those in the plaintext. They could be numbers, letters, or symbols.
- Ciphertext. This is the encoded message.
Generating a key is a complicated mathematical process. Even so, most computers can push through each step in seconds.
Bits of plaintext enter the stream cipher, and the cipher manipulates each bit with the mathematical formula. The resulting text is completely scrambled, and the recipient can't read it without the proper key.
With the right key, a recipient can push the ciphertext back through the stream cipher and transform the garbled data back to plaintext.
There are two main types of stream ciphers, and they each work slightly differently.
- Synchronous stream ciphers: A secret key generates keystreams, and they're made independently of both the plaintext and the ciphertext.
- Self-synchronizing stream ciphers: They use a secret key, but they include another form of randomization to make hacking harder.
Stream ciphers aren't the only tools at your disposal. You could also use block ciphers. Block ciphers break messages down into pieces, and then each piece moves through an encryption algorithm.
How are stream ciphers used?
If you've ever watched a movie about World War II, you've probably seen the power of stream ciphers firsthand. German officials used the technology to send directions to their troops, and it took years for English experts to crack the code.
The Germans used a complicated machine that looked a bit like a typewriter. A set of 26 lights above the keys made the transformation plain. One light represented a converted letter. They changed the keys regularly, and a push of a button updated the Enigma to tap out notes in the new code.
An online model lets you tinker with the Enigma (complete with authentic sounds). Tapping out the word "Welcome" on that simulation returned the encoded message "4JOTSXI."
The history is fascinating. But make no mistake. Stream ciphers didn't go out of style when the war ended. In fact, plenty of people use this technology now.
Stream ciphers come with plenty of benefits, including:
- Speed. This form of encryption is typically faster than others, including block ciphers.
- Low complexity. It's easy to incorporate stream ciphers into modern programs, and developers don't need complex hardware to make it happen.
- Serial nature. Some companies deal with messages written in a trickle. With their bit-by-bit processing, stream ciphers allow them to send information when it's ready rather than waiting for everything to be done.
- Ease of use. Stream ciphers are symmetrical encryption tools, so companies aren't forced to bother with public and private keys. And mathematical concepts that underlie modern stream ciphers allow computers to determine the proper decryption key to use.
Because stream ciphers are easy to implement, many people and organizations use them. In fact, most web browsers and websites use this technology.
When you connect to a protected website, the site sends your computer an SSL certificate. That document is encrypted, and most sites use stream ciphers for that communication.
A deep dive into stream cipher creation
Mathematical concepts underlie stream ciphers. These concepts regulate how to replace information within plaintext, and they explain how to transform the garbled note into a readable state once more.
Most stream ciphers rely on something called linear-feedback shift registers (or LFSRs). These are easy to implement, but they're not strong security components. Developers attempt to enhance security by using:
- Non-linear combining functions. These systems eliminate the linear nature of the math used, making the code slightly harder to crack.
- Clock-controlled functions. They incorporate an element of time that changes the output accordingly.
- Filters. The developers add another element to the calculations, and they keep that filter strictly secret.
Future developers may come up with even more methods to enhance the security of stream ciphers and ensure that hackers can’t undo their work.
Are stream ciphers safe from hackers?
As we learned during WWII, even sophisticated stream ciphers can be cracked with the proper amount of creativity and persistence. No encryption method is 100 percent safe from people determined to get inside.
Read through hacker forums, and you'll learn that most of them consider stream ciphers extremely easy to reverse. Pick at them to learn how they were encoded, and you can use the same tools to reverse the process.
The best way to ensure security with stream ciphers is to use keys just once. And each key should be unrelated to any other you've used. That way, even if attackers crack one key, the rest of your system's security will remain intact.
Popular stream ciphers
When people talk about stream ciphers as a whole, they're often discussing RC4. This is the most popular stream cipher in the world, and it's used widely.
The RC4 cipher works like this:
Plenty of other options exist. Wikipedia lists 25 different types of stream ciphers of varying costs, speeds, and complexities.
Choosing the right encryption method is just one part of developing a robust security system. You must also protect data with firewalls, proper keyword storage, and employee education.
Let us help. Find out how Okta can work with you to keep your company safe.
Rusty but Intact: Nazi Enigma Cipher Machine Found in the Baltic Sea. (December 2020). Ars Technica.
The Lorenz SZ40/42 Cipher Attachment. Virtual Lorenz.
Introduction to Cryptography: One-Time Pads and Stream Ciphers. (February 2020). Medium.
Stream Ciphers. Science Direct.
Synchronous Stream Cipher. (2011). Encyclopedia of Cryptography and Security.
Self-Synchronizing Stream Cipher. (2011). Encyclopedia of Cryptography and Security.
Having Keys and Binary, How Do I Reverse/Decrypt a Stream Encryption? (2016). Reverse Engineering Stack Exchange.
Stream Cipher. Wikipedia.