How RC4 Works
Now that you understand the very basics of encryption, let's take a closer look at how it is implemented in RC4. RC4 is a synchronous stream cipher that uses XOR to combine output from a key stream generator with the plaintext of the message. When used properly, its state value is relatively unpredictable; thus, it is a strong, fast, and
The leaked RC4 algorithm is commonly referred to as ARC4 (assumed RC4). RSA never
There are several
RC4 Encryption StatesRC4 uses a concept known as states in its encryption and decryption process. The state value is held in array, which is a matrix of values. For example, an alphabet array would hold the values "a “z". A particular letter could be called from the array by using the respective number of the alphabet. In other words, alpha(1) would = "a", and alpha(26) would = "z".
In addition, an array can be useful if a series of values needs to be swapped, or if you require some form of random value generation. For example, what if the values of the alpha array were randomized? This would provide the
This type of random generation is used in RC4. During the encryption process, a series of numerical values (usually 1 “256) is placed into a state array, which is then scrambled. The state array is then used in the key stream, which is discussed later. Initiation Vector Used in RC4
When data is passed through the RC4 algorithm, there are two pieces of information that go into the encryption process. The first is the password, which is required by both parties to encrypt and decrypt the data. However, because of the transmission method of data encrypted with RC4, it would be a simple matter to capture and crack ciphertext if only the password was used to encrypt the data. A hacker would simply have to determine the value of the plaintext prior to its encryption, then capture the transmitted
What makes RC4 a streaming cipher is its use of a
The IV is supposed to create a new key to avoid re-use of the secret key when the state table is re-
The party who receives the encrypted text requires both the password and the IV to initialize the decryption process. As we previously mentioned, an internal state is used in the encryption process to create the streaming cipher. This means the same internal state must also be created on the
Key Scheduling Algorithm Generation in RC4Now that you understand the purpose of the internal state and the purpose of the IV, let's take a closer look at the actual encryption process. The first part of the encryption algorithm generates the Key Scheduling Algorithm (KSA) . This is accomplished by creating an array of values equal to the index you want to use in the algorithm. RC4 comes in several varieties: 8-bit, 16-bit, and so on. WEP uses 8-bit RC4 and operates on 8-bit values by creating an array with 256 8-bit values for a lookup table (8-bits of 8-bit values).
The
Listing 4.1 Key Scheduling Algorithm
Initialization:
For i = 0 ... N - 1
S[i] = i
j = 0
Scrambling:
For i = 0 ... N - 1
j = j + S[i] + K[i mod l]
Swap(S[i], S[j])
Pseudo Random Generation Algorithm: Generating the Streaming KeyAfter the state array has been computed, it is time to move on to the encryption process. This part of the algorithm is responsible for creating the streaming values used to encrypt the plaintext, which is based on the output of the KSA. The stream is created by looping through the algorithm, provided in Listing 4.2, for each byte of the packet. This streaming value is then used in an XOR calculation against the plaintext. The result is ciphertext, which is sent to the receiving party. Listing 4.2 Pseudo Random Generation Algorithm (PRGA)
Initialization:
i = 0
j = 0
Generation Loop: i = i + 1
j = (j + S[i]) mod l
Swap(S[i], S[j])
Output z = S[S[i] + S[j]]
An Example
To
Creation of the State Array
To create the state array, several values must be known. These are the initial value of the variable
i
and
j
, the index value, and the password. In our example, we will assume both
i
and
j
are both
, and the index value is
4
. We choose
4
because of the
It would take far too long to work through all the KSA steps with normal 8-bit RC4. It is far easier to
The initial values of our variable are as
i=0 j=0 pass="6152" pass length=4 Index (N) = 4 Now, let's initialize the KSA:
For i = 0 ... N - 1
S[i] = i
Next
In regular English, this would read "Continue this loop until i=N-1 (or i=4-1 ), adding one to i each time through the loop and adding the current value of i to the state array ( S[i] )." In other words, once this loop was complete, we would have the following values assigned to the state array: S[0]=0 S[1]=1 S[2]=2 S[3]=3 Next we need to scramble the values held in the state array using the following algorithm:
For i = 0 ... N - 1
j = j + S[i] + K[i mod l]
Swap(S[i], S[j])
In English, this says "Continue this loop until i=N-1 (or i=4-1 ), adding one to i each time through the loop. For every time through the loop, calculate the value of j , and then swap the array value held in S[i] for the value held in S[j] ." KSA Example
To illustrate, we will present the current values of each variable prior to each pass through the loop, as well as the values after they have been
Note: the
In other words, if the results of a calculation were 6, and the
First LoopInitial values: S[0]=0 S[1]=1 S[2]=2 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=0 j=0 pass (K)="6152" pass length(l)=4 Index (N) = 4 Equations: j = j + S[i] + K[i mod l] Swap(S[i], S[j]) j=(0 + S[0] + K[0]) mod 4 j=(0+0+6) mod 4 j=6 mod 4 j=2 Swap (S[0] , S[2]) Final values: S[0]=2 S[1]=1 S[2]=0 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=1 j=2 pass (K)="6152" pass length(l)=4 Index (N) = 4 Second LoopInitial values: S[0]=2 S[1]=1 S[2]=0 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=1 j=2 pass (K)="6152" pass length(l)=4 Index (N) = 4 Equations: j = j + S[i] + K[i mod l] Swap(S[i], S[j]) j=(2 + S[1] + K[1]) mod 4 j=(2+1+1) mod 4 j=4 mod 4 j=0 Swap (S[1] , S[0]) Final values: S[0]=1 S[1]=2 S[2]=0 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=2 j=0 pass (K)="6152" pass length(l)=4 Index (N) = 4 Third LoopInitial values: S[0]=1 S[1]=2 S[2]=0 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=2 j=0 pass (K)="6152" pass length(l)=4 Index (N) = 4 Equations: j = j + S[i] + K[i mod l] Swap(S[i], S[j]) j=(0 + S[2] + K[2]) mod 4 j=(0+0+5) mod 4 j=5 mod 4 j=1 Swap (S[2] , S[1]) Final values: S[0]=1 S[1]=0 S[2]=2 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=3 j=1 pass (K)="6152" pass length(l)=4 Index (N) = 4 Fourth LoopInitial values: S[0]=1 S[1]=0 S[2]=2 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=3 j=1 pass (K)="6152" pass length(l)=4 Index (N) = 4 Equations: j = j + S[i] + K[i mod l] Swap(S[i], S[j]) j=(1 + S[3] + K[3]) mod 4 j=(1+3+2) mod 4 j=6 mod 4 j=2 Swap (S[3] , S[2]) Final values: S[0]=1 S[1]=0 S[2]=3 S[3]=2 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=4 j=2 pass (K)="6152" pass length(l)=4 Index (N) = 4 PRGA ExampleNow that we have set up the KSA, it is time to initialize and use the PRGA. This uses the following algorithm, into which the values stored during the scheduling were placed. Initialization:
i = 0
j = 0
Generation Loop: i = i + 1 j = j + S[i] Swap(S[i], S[j]) mod l Output z = S[S[i] + S[j]] First LoopInitial values: S[0]=1 S[1]=0 S[2]=3 S[3]=2 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=0 j=0 pass (K)="6152" pass length(l)=4 Index (N) = 4 Algorithm: i=0+1=1 j=0+S[1]=0+0=0 Swap (S[1] , S[0]) Second LoopInitial values: S[0]=0 S[1]=1 S[2]=3 S[3]=2 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=1 j=0 pass (K)="6152" pass length(l)=4 Index (N) = 4 Algorithm: i=1+1=2 j=0+S[2]=3 Swap(S[2],S[3]) Final Initial values: S[0]=0 S[1]=1 S[2]=2 S[3]=3 K[0]=6 K[1]=1 K[2]=5 K[3]=2 i=2 j=3 pass (K)="6152" pass length(l)=4 Index (N) = 4 Algorithm: i=2+1=3 j=3+S[3]=6%4=2 Swap(S[3],S[2]) And so on. XOR PRGA with Plaintext Example
Now that we have a PRGA stream (albeit a basic one), let's use it to encrypt the word
HI
. Because RC4 is a bitwise encrypter, we need to convert the
H (ASCII) Let's now XOR the binary values with the output stream from the PRGA. H (ASCII)
Therefore, the encrypted value of
HI
when used with a simple form of RC4 is
IH
. Note that this is a very basic illustration that used an index of 4 and a short password. Typically, this index would be 256, and the password values would be anything from 1 “256. The password values are actually converted to their decimal equivalent of the ASCII
RC4 and WEP
As previously mentioned, RC4 uses initialization vectors. This is a unique value that ensures each packet of information sent out is encrypted with a different key stream. Recalling our example, we used the password
6152
to encrypt the data. The values of each character and the length of the password were both used to set up the KSA, which in
In the real world, RC4 would be encrypting multiple packets. The IV is used to load the KSA with a different value for each and every different packet of information passed over the wireless network. This creates a different encryption stream (PRGA) for each
Although this creates a more secure environment for data transfer, it also requires the communicating parties to share two pieces of information. The first is the password, which is preshared and typically static. The second is the IV, which changes for each packet. This means the IV must also be sent out over the airwaves in such a way that the receiving party can determine its value. So, what is the IV used for? Well, in our example, we used a 4-digit value as a password ( 6152 ). However, this is not a real-world example. In reality, a 5- or 13-digit password is used, which is then combined with the IV to create an 8- or 16-digit password. In other words, the IV becomes the part of the password that is used to generate the KSA, and ultimately the ciphertext. Understanding Key StrengthRC4, as incorporated into WEP, uses either 40- or 104-bit protection with a 24-bit IV.
When you create a password, its letters and/or
H(ASCII) Therefore, HACKS Note that the binary equivalent of each letter contains eight bits. Also note, the entire password when converted to binary equals 40 bits (ones and zeros). If you own a wireless device or have ever set up a wireless network, you will probably not recognize these 40- or 104-bit values. However, you might recognize the term 64-bit and 128-bit (Figure 4.2). These values are actually referring to the 40- and 104-bit encryption we just discussed. What the vendor is not telling you is that 24 bits of the encryption belong to the IVs prepended to the password during the encryption process. In other words, 64-bit encryption is created by a five letter-password and three IV values, and 128-bit encryption is created by a thirteen letter-password and three IV values. This is slightly misleading on the vendor's part, simply because the IV bits are not really secure. In fact, these values are sent over the airwaves in plain text! Figure 4.2. Linksys WAP11 64-bit WEP key settings.
NOTE
Not all
Many
Figure 4.3. Linksys WAP11 128-bit WEP key settings.
Verifying Data Integrity Using Cyclic Redundancy Checks (CRC)
The first step in a wireless data transfer is to break the data into smaller chunks that can be transmitted. This is similar to the spoken language of
When data is sent over the airwaves, or even through land-based wires, it must
The answer is a checksum. The checksum is created using a simple algorithm that derives a unique number based on the specific data. In the case of 802.11, this value is a 32-bit (or 4-byte) value.
Once calculated, the checksum
The WEP ProcessWe have covered a great deal of information thus far in the chapter. You now understand how RC4 works, why the IV is important to the encryption process, and what role passwords play with WEP. You also understand that each packet not only goes through an encryption process, but also an integrity check. We will now put this entire process together by stepping through a live wireless data transmission. First we need data. Suppose we send an Instant Message (IM) across a wireless network to ourself. This message is quite long, so our computer firsts breaks the data into several smaller and more manageable chunks of information, as illustrated in Figure 4.4. The data is then sent to the chat relay server, and sent back to us. Figure 4.4. Data processing.
As it processes the data, it takes the first chunk and
Figure 4.5. WEP
|

Guide to Wireless Network Security

Darknet: Hollywood's War Against the Digital Generation

ARRL Ham Radio License Manual: All You Need to Become an Amateur Radio Operator (Arrl Ham Radio License Manual) (Arrl Ham Radio License Manual)

Wireless Communications Security (Artech House Universal Personal Communications)