Keystream
   HOME

TheInfoList



OR:

In
cryptography Cryptography, or cryptology (from grc, , translit=kryptós "hidden, secret"; and ''graphein'', "to write", or ''-logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of adver ...
, a keystream is a
stream A stream is a continuous body of water, body of surface water Current (stream), flowing within the stream bed, bed and bank (geography), banks of a channel (geography), channel. Depending on its location or certain characteristics, a stream ...
of
random In common usage, randomness is the apparent or actual lack of pattern or predictability in events. A random sequence of events, symbols or steps often has no :wikt:order, order and does not follow an intelligible pattern or combination. Ind ...
or
pseudorandom A pseudorandom sequence of numbers is one that appears to be statistically random, despite having been produced by a completely deterministic Determinism is a philosophical view, where all events are determined completely by previously exi ...
characters that are combined with a
plaintext In cryptography, plaintext usually means unencrypted information pending input into cryptographic algorithms, usually encryption algorithms. This usually refers to data that is transmitted or stored unencrypted. Overview With the advent of comp ...
message to produce an encrypted message (the ciphertext). The "characters" in the keystream can be
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
s,
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
s, numbers or actual characters like A-Z depending on the usage case. Usually each character in the keystream is either added, subtracted or
XORed Exclusive or or exclusive disjunction is a Logical connective, logical operation that is true if and only if its arguments differ (one is true, the other is false). It is Table of logic symbols, symbolized by the prefix operator J and by the ...
with a character in the plaintext to produce the ciphertext, using
modular arithmetic In mathematics, modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" when reaching a certain value, called the modulus. The modern approach to modular arithmetic was developed by Carl Friedrich Gauss in his book ...
. Keystreams are used in the
one-time pad In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is not smaller than the message being sent. In this technique, a plaintext is paired with a ran ...
cipher and in most
stream cipher stream cipher is a symmetric key cipher where plaintext digits are combined with a pseudorandom cipher digit stream (keystream). In a stream cipher, each plaintext digit is encrypted one at a time with the corresponding digit of the keystream ...
s.
Block cipher In cryptography, a block cipher is a deterministic algorithm operating on fixed-length groups of bits, called ''blocks''. Block ciphers are specified cryptographic primitive, elementary components in the design of many cryptographic protocols and ...
s 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.


Example

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 plaintext. And to decrypt we subtract the same keystream numbers from the ciphertext to get the plaintext. 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. (Such wrapping is called
modular arithmetic In mathematics, modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" when reaching a certain value, called the modulus. The modern approach to modular arithmetic was developed by Carl Friedrich Gauss in his book ...
.) Here the plaintext message "attack at dawn" is combined by addition with the keystream "kjcngmlhylyu" and produces the ciphertext "kcvniwlabluh".


References

*
Handbook of Applied Cryptography
' by Menezes, van Oorschot and Vanstone (2001), chapter 1, 6 and 7. {{cryptography navbox, stream Stream ciphers