Cryptography Reference
In-Depth Information
anonymously posted is commonly referred to as
ARCFOUR
. It is the term we use in
this topic.
ARCFOUR is a synchronous (additive) stream cipher—that is, a sequence
of pseudorandom bytes (i.e., a key stream) is generated independently from the
plaintext message or ciphertext, and this sequence is added modulo 2 to the plaintext
message byte sequence. The cipher takes a variable-length key that may range from
1 to 256 bytes (i.e., 2,048 bits). To generate the key stream, ARCFOUR employs
an array
S
of 256 bytes of State information (called S-box). The elements of
S
are
labeled
S
[0]
,...,S
[255]. They are initialized as follows: three steps:
1. All elements of
S
are initialized with their index:
S
[0]
=
0
S
[1]
=
1
...
S
[255]
=
255
2. Another array
S
2
of 256 bytes is allocated and filled with the key, repeating
bytes as necessary.
3. The S-box is then initialized as suggested in Algorithm 10.5. Note that this
algorithm only operates on
S
(i.e., there is no other input or output parameter
than
S
). Also note that
S
[
i
]
↔
S
[
j
] means that the S-box entries
S
[
i
] and
S
[
j
]
are swapped.
Algorithm 10.5
The S-Box initialization algorithm of ARCFOUR.
(
S
)
for
i
=0to 255 do
j ←
(
j
+
S
[
i
]+
S
2
[
i
]) mod 256
S
[
i
]
↔ S
[
j
]
(
S
)
After
S
is initialized (according to Algorithm 10.2),
i
and
j
are set to zero
(all entries of
S
2
are also set to zero). Algorithm 10.6 is then used to generate a
potentially infinite sequence of key bytes. The algorithm takes
S
as input parameter
and outputs a key byte
k
. If a plaintext message (ciphertext) of
l
bytes must be
encrypted (decrypted), then the algorithm must be iterated
l
times, and each key byte
k
i
(
i
=1
,...,l
) must be added modulo 2 to the corresponding plaintext message
(ciphertext) byte.