Keystream

From Wikipedia, the free encyclopedia

In cryptography, a keystream is a stream of random or pseudorandom characters that are combined with a cleartext message to produce an encrypted message (the ciphertext).

The "characters" in the keystream can be bits, bytes, numbers or actual characters like A-Z depending on the usage case.

Usually each character in the keystream is either added, subtracted or XORed with a character in the cleartext to produce the ciphertext, using modular arithmetic.

Keystreams are used in the one-time pad cipher and in most stream ciphers. Block ciphers can also be used to produce keystreams. For instance CTR mode is a block mode that makes a block cipher produce a keystream and thus turns the block cipher into a stream cipher.

In this simple example we use the English alphabet of 26 characters from a-z. Thus we can not encrypt numbers, commas, spaces and other symbols. The random numbers in the keystream then have to be at least between 0 and 25.

To encrypt we add the keystream numbers to the cleartext. And to decrypt we subtract the same keystream numbers from the ciphertext to get the cleartext.

Note that if a ciphertext number becomes larger than 25 we wrap it to a value between 0-25. Thus 26 becomes 0 and 27 becomes 1 and so on.

Here the cleartext message "attack at dawn" is combined by addition with the keystream "kjcngmlhylyu" and produces the ciphertext "jcvniwlabluh".

Cleartext a t t a c k a t d a w n
Cleartext as numbers 0 19 19 0 2 10 0 19 3 0 22 13
Keystream k j c n g m l h y l y u
Keystream as numbers 10 9 2 13 6 12 11 7 24 11 24 20
Ciphertext as numbers 10 28 21 13 8 22 11 26 27 11 46 33
Ciphertext as numbers
wrapped to 0-25
10 2 21 13 8 22 11 0 1 11 20 7
Ciphertext as text j c v n i w l a b l u h


Stream ciphers
v  d  e
Algorithms: A5/1 | A5/2 | E0 | FISH | Grain | HC-256 | ISAAC | LILI-128 | MUGI | Panama | Phelix | Pike | Py | Rabbit | RC4 | Salsa20 | Scream | SEAL | SOBER | SOBER-128 | SOSEMANUK | Trivium | VEST | WAKE
Theory: Shift register | LFSR | NLFSR | Shrinking generator | T-function | IV
Standardization: eSTREAM
Cryptography
v  d  e
History of cryptography | Cryptanalysis | Cryptography portal | Topics in cryptography
Symmetric-key algorithm | Block cipher | Stream cipher | Public-key cryptography | Cryptographic hash function | Message authentication code | Random numbers
Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.