RC4 Encryption Principle
The RC4 encryption algorithm is stream cipher, which can use variable length keys. The algorithm was developed in 1987 by Ron Rivest, for RSA Data Security, and was a propriety algorithm until 1994.
In the algorithm the keystream is completely independent of the plaintext used. An 8 * 8 S-Box (S0 S255), each of the entries is a permutation of the numbers 0 to 255, and the permutation is a function of the variable length key. There are two counters i, and j, both initialised to 0 used in the algorithm.
The S-Box is easily generated, using the following:
Fill S1 to S255 linearly (i.e. S0 = 0; S1 = 1 ... S255 = 255)
Another 256 byte array is then filled with the key, the key is repeated as necessary to fill the entire array.
The index j is then set to 0
for (i = 0 to i = 255)
j = (j + Si + ki) MOD 256
Swap Si and Sj
fi
The following is used to generate a random byte:
i = (i + 1) MOD 256
j = (j + Si) MOD 256
Swap Si and Sj
t = (Si + Sj) MOD 256
K = St
K is the XORed with the plaintext to produce the ciphertext, or the ciphertext to produce the plaintext.
RSA claims that the algorithm is immune to differential and linear cryptanalysis. The algorithm can also be changed from the 8-bit used above to 16-bit by using a 16 * 16 S-Box, and a 16-bit word. The initial set-up would need to be repeated 65,536 times to keep with the design, but it should be faster.
本文介绍了RC4加密算法原理,它是一种流密码,可使用可变长度密钥。算法中密钥流与明文无关,通过特定方法生成S - Box,利用计数器i和j进行操作。还说明了生成随机字节的方式,以及与明文异或产生密文等内容,且该算法可从8位扩展到16位。
3955

被折叠的 条评论
为什么被折叠?



