# How does a wifi password encrypt data using WEP and WPA?

How does the password that we enter (to connect to a wireless network) encrypt the data on the wireless network?

Through my reading I am not sure if the password that we enter is the same as the passphrase. If that is right then how can the passphrase generate the four WEP keys?

I understand how the four keys work in WEP and how they encrypt the data. Also, I know how WPA's keys encrypt the data but the only thing I have to know is:

what is the benefit of the password that we enter to get access to the network, and how does this password help in encrypting the data?

• Probably better on security.stackexchange.com Mar 23 '12 at 19:51
• @Kevin true, although strictly speaking it's neither off-topic here as well. Mar 23 '12 at 20:04
• I think this blog post is relevant here: blog.stackoverflow.com/2012/03/… - In other words, if there's an overlap, no reason not to answer it here. it is definitely CS Mar 23 '12 at 23:42
• @Suresh: Not sure it is. It concerns a specific implementation of something, which is kind of a red flag. However, the lines are bound to be blurry in crypto, so I guess it is fine.
– Raphael
Mar 24 '12 at 17:33

WEP uses the stream cipher $RC4$ for confidentiality and the CRC-32 checksum for integrity. All data frames sent by a router in a WEP protected network are encrypted. When a router sends a packet, the following steps are executed.

1. The router picks a $24$-bit value called the initialization vector $IV$. A new $IV$ is used for every packet.

2. The $IV$ is prepended to the key (password you enter) and forms the per packet key $K$.

3. A CRC32 checksum of the payload is produced and appended to the payload. This checksum is called an Integrity Check value ($ICV$).

4. The per packet key $K$ is fed into the $RC4$ stream cipher to produce a key stream $X$ of the length of the payload with checksum.

5. The plaintext with the checksum is XORed with the key stream and forms the cipher text of the packet.

6. The cipher text, the $IV$ and some additional header fields are used to build a packet, which is now sent to the receiver.

Weaknesses of WEP and why to choose WPA

An $IV$ size of $24$-bits provides only $16$ million different key streams for a given WEP key. If the $IV$ is reused, the key stream for a given $IV$ is found and hence an attacker can decrypt subsequent packets that were encrypted with the same $IV$ even without knowing the WEP key.

Since there are only $16$ million $IV$ values, how the $IV$ is chosen makes a big difference in the attacks based on $IV$. As explained above, some implementations choose $IV$s randomly and some are assigned sequentially. With a randomly chosen $IV$, there is a $50\%$ chance of reuse after less than $5000$ packets and if assigned sequentially, collisions are inevitable if the values are re-initialized.

WEP’s integrity check field is implemented as a CRC-32 checksum, which is part of the encrypted payload of the packet. However, CRC-32 is linear, which means that it is possible to compute the bit difference of two CRCs based on the bit difference of the messages over which they are taken. In other words, flipping bit ‘$n$’ in the message results in a deterministic set of bits in the CRC that must be flipped to produce a correct checksum on the modified message. An attacker can therefore change a bit in an encrypted message and know which bit of the encrypted $ICV$ will change as a result.

As explained in Wikipedia:

If ASCII characters are used, the 256 bit key is calculated by applying the PBKDF2 key derivation function to the passphrase, using the SSID as the salt and 4096 iterations of HMAC-SHA1.