RC4 encryption algorithm is a variable-length stream encryption algorithm cluster designed in 1987 by Ron Rivest, the number one character in the well-known RSA trio. It is called a cluster because the S-box length of its core part can be arbitrary, but generally 256 bytes. The algorithm is about 10 times faster than DES encryption.
The principle of the RC4 algorithm is very simple, including the initialization algorithm and the pseudo-random sub-Password generation algorithm. Assume that the S-box length and key length are both N. Let's take a look at the initialization part of the algorithm (represented by Class C pseudo code ):
For (I = 0; I s [I] = I;
J = 0;
For (I = 0; I {
J = (J + S [I] + k [I]) %256;
Swap (s [I], s [J]);
}
During initialization, the key's main function is to disrupt S-box. I ensures that every element of S-box is processed, and J ensures that S-box is random. Different S-boxes can obtain different sub-key sequences after processing the pseudo-random sub-Password generation algorithm, and the sequences are random:
I = J = 0;
While (plaintext is not ended)
{
++ I % = N;
J = (J + S [I]) % N;
Swap (s [I], s [J]);
Sub_k = S (S [I] + s [J]) % N );
}
The obtained sub-Password sub_k is used to perform XOR operations on the plaintext. The ciphertext is obtained, and the decryption process is the same.
Because the RC4 algorithm uses XOR for encryption, once the sub-Key sequence is repeated, the ciphertext may be cracked. For details about how to crack XOR encryption, see section 1.4 simple XOR in Bruce Schneier's applied cryptography. So will the subkey sequence generated by the RC4 algorithm be repeated? After my tests, some weak keys exist, making the sub-Key sequence completely repeated within less than 1 million bytes. If it is partially repeated, therefore, we recommend that you use the RC4 algorithm to test the encryption key to determine whether it is a weak key.
Moreover, based on the current analysis results, no analysis is effective for RC4 with a key length of 128 bits. Therefore, RC4 is one of the most secure encryption algorithms, so you can use it with confidence!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service