2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Before introducing stream ciphers, let's first understand a basic prerequisite knowledge point - XOR operation.
Operation rules: The same is 0, different is 1
Features: A bit can be restored to its original state by performing two XOR operations on it.
Plain text: 1100
Key: 0101 (encrypted)
Ciphertext: 1001
Key: 0101 (decryption)
Plain text: 1100
advantage:This reversibility allows the XOR operation to be used for both encryption and decryption transformations.
shortcoming:If an attacker can guess or capture the key, it can also be easily decrypted via XOR.
The reason why the XOR operation can be used for both encryption and decryption is its reversibility, but this is also its disadvantage. Its security depends entirely on key hiding.
One-Time Pad (OTP) is a stream cipher algorithm that is considered to be one of the most secure encryption methods in theory, provided that its implementation strictly follows several key principles:
1. The key must be as long as the plaintext: This means that each encryption uses a key that is exactly the same length as the information to be encrypted.
2. The key must be truly random: Each bit of the key should be randomly generated without any pattern or predictability.
3. The key must be used only once: The same key must never be used to encrypt multiple messages, otherwise the correlation between the ciphertexts can be used to infer the content of the messages.
4. The key must be kept secret: The distribution and storage of keys must be extremely secure to prevent them from being obtained by third parties.
advantage:
shortcoming:
When people were studying one-time encryption algorithms, they tried to solve the problems of key management and length. If there was a way to generate all the keys for encrypting plaintext by providing only a small key, then stream ciphers were developed based on this idea.
In a stream cipher, a small key (often called a seed or initialization vector) is used to generate a pseudo-random key stream of the same length as the plaintext through a pseudo-random number generator (PRNG). This key stream is then XORed with the plaintext to produce the ciphertext. Similarly, the decryption process is to XOR the ciphertext with the same key stream to recover the plaintext.
KeyGenerate a key stream
And use the following rules to
To encrypt:
![]()
Generally, a linear feedback shift register is used to generate a pseudo-random key. The principle will not be elaborated here.
The encryption and decryption process can be described as follows:
The design principles of stream ciphers are really focused on creating a keystream generator that can produce a keystream with certain security properties. The keystream sequence should have the following properties:
The huge cycle: The period of the keystream should be long enough to prevent the reuse of the same keystream, which would expose the pattern of the encrypted data and enable cryptanalysts to attack by comparing the similarities and differences between different messages. In theory, for an n-bit key space, the ideal period length should be 2n−1. In practice, a longer period means a lower frequency of keystream repetition, which increases the security of the cryptographic system.
Good statistical properties: The keystream should look like a truly random sequence of bits, meaning that it should satisfy various statistical tests, such as equal distribution of 0s and 1s, independence between any two or more consecutive bits, and the absence of predictable patterns or periodicity. Good statistical properties help ensure the unpredictability of the keystream, which is an important component of the security of a stream cipher.
Anti-Linear Analysis: A stream cipher should be resistant to linear analysis, where a cryptanalyst attempts to recover the key or plaintext by finding linear correlations between the keystream and the plaintext or ciphertext. This usually requires that the output of the keystream generator is nonlinear, or at least contains enough nonlinear components to prevent simple linear equation solving methods from inferring the keystream or the key itself.