# Module 3: Wi-Fi Encryption

## Open Wireless Networks

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2Fs09RxSzPI1TKQ6UfsxmX%2Fimage.png?alt=media&#x26;token=be04571e-961a-4762-a9e1-5f67965d3680" alt=""><figcaption><p>The process of connecting to open networks</p></figcaption></figure>

## Wired Equivalent Privacy

WEP uses a 24-bit initialization vector (IV). A 64-bit key was permitted, 24 bits are used for IVs, resulting in a real key size of 40 bits.

### RC4

RC4 is a symettric cipher. Streams of bits are XOR'd with plain text to get the encrypted data. Decrypting it is simply XORing the encrypted text with the key stream.&#x20;

RC4 costs of two key elements:

1. **Key Scheduling Algorithm (KSA)**: Initializes the state table with the IV and WEP key.
2. **Pseudo-Random Generation Algorithm (PRGA)**: Creates the keystream.

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FO8P45IPS3RReoHr0qALI%2Fimage.png?alt=media&#x26;token=8d1351f6-35db-4042-8b04-7e1e611c45a0" alt=""><figcaption><p>RC4 encryption/decryption overview</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FVQ9sfa341XrBP4gaWzCH%2Fimage.png?alt=media&#x26;token=d971584c-bb28-499e-af93-0ade9f2596eb" alt=""><figcaption><p>The WEP encryption process</p></figcaption></figure>

1. Concatenate the IV and WEP key, then run KSA and PRGA to get the keystream.
2. Create the Integrity Check Value (ICV) of the message, then concatenate it to the message.
3. XOR the plain text message plus the CRC32 and the keystream to obtain the encrypted text.
4. The packet then contains the following elements:
   * IV (Used Previously)
     * Key ID
     * Encrypted Text
     * ICV that is the CRC32 of the plain text

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2F123MaQgwsHhpBySc7DeE%2Fimage.png?alt=media&#x26;token=e9b02afc-9b98-4ec4-a715-db176acdfb7a" alt=""><figcaption><p>The WEP decryption process</p></figcaption></figure>

1. Concatenate the IV and the key corresponding to the key ID, then run KSA and PRGA to obtain the keystream.
2. XOR the encrypted message and the keystream, resulting in the message + ICV.
3. Compare the decrypted ICV with the one received with the packet. If they are the same, the frame is intact and accepted, otherwise, discard the frame, as the packet is fake or corrupted.

### WEP Authentication

WEP can make use of two authentication systems:

1. Open Authentication: Client does not provide any credentials. Once associated, it must possess the correct key to encrypt/decrypt data frames.
2. Shared Authentication: A challenge text is sent to the client. The text must be encrypted with the WEP key by the client and sent back to the AP for verification. The AP then attempts to decrypt the text. If successful and matches the clear text version, the client is allowed to proceed to associate with the AP.

## Wi-Fi Protected Access

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FJ7jiYL3cBjanNyxbz6CA%2Fimage.png?alt=media&#x26;token=a7e844f1-c133-4620-affa-6884f980216e" alt=""><figcaption><p>The WPA connection process</p></figcaption></figure>

### WPA Ciphers

Two ciphers are available to WPA:

1. TKIP: Designed to be backward compatible with legacy hardware. Can only handle WEP, but addresses the flaws found in WEP:
   * Per packet key mixing
   * IV sequencing to avoid replay attacks
   * New Message Integrity Check (MIC), using the Michael algorithm and countermeasures on MIC failures
   * Key distribution and rekeying mechanism
2. CCMP: Based on AES. Also known as Robust Security Network (RSN). Designed from the ground up and is not compatible with older hardware.

### WPA Network Connection

The secure communication channel is set up in four steps:

1. Agreement on security protocols
2. Authentication
3. Key distribution and verification
4. Data encryption and integrity

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2F8DNlX7lTZ7bPcNDWiQBN%2Fimage.png?alt=media&#x26;token=f9cf41bd-662c-4b23-9697-3a3dc47773ff" alt=""><figcaption><p>The WPA Enterprise connection process</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FkHIm0AlCJDAAJDNYqRnO%2Fimage.png?alt=media&#x26;token=87adda87-c846-4c28-a215-c9e8a7df2168" alt=""><figcaption><p>The WPA-PSK connection process</p></figcaption></figure>

### WPA Authentication

The authentication step is only done in WPA Enterprise configurations and is based on the Extensible Authentication Protocol (EAP).

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FHUpEEHqU9WMJ2CIZ1ZyP%2Fimage.png?alt=media&#x26;token=a7d5fe6c-463b-4533-8191-1bfdb70fde1b" alt=""><figcaption><p>The key distribution and verification phase</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FAtBUmFRXLucAc92MxIKH%2Fimage.png?alt=media&#x26;token=7bdc26c3-8628-48f0-bb0d-818e330d45e9" alt=""><figcaption><p>The group key handshake process</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2Fwm4dbpcaSF9HOCjUs2kc%2Fimage.png?alt=media&#x26;token=8480bd49-77db-4db3-9264-cd7f4c21f103" alt=""><figcaption><p>The Pairwise Transient Key (PMK) generation process</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2F8d2ZolFwjIIChFjlWpWk%2Fimage.png?alt=media&#x26;token=fdf8cbd9-5c01-4857-889d-1eb6ed8bec57" alt=""><figcaption><p>The GTK construction process</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FQKWcJNm5KudqpgRHOA2e%2Fimage.png?alt=media&#x26;token=605f20fc-a531-4c24-ae82-7180ef14d0fc" alt=""><figcaption><p>A TKIP encrypted frame</p></figcaption></figure>

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FV6TuFxmhLZMCle0fNiua%2Fimage.png?alt=media&#x26;token=f7834843-b110-42b7-a1ce-fbec96f9afb7" alt=""><figcaption><p>A CCMP encrypted frame</p></figcaption></figure>

## Wi-Fi Protected Access 3

Simultaneous Authentication of Equals (SAE) replaces PSK in WPA personal. SAE is a variant of Dragonfly. AES is the only cipher allowed.&#x20;

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FryeD8dxHXh8wNKkvczUR%2Fimage.png?alt=media&#x26;token=26d301dc-9665-4c40-82a0-276e5552f5f6" alt=""><figcaption><p>WPA3 authentication</p></figcaption></figure>

## Opportunistic Wireless Encryption

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2FqQBjiohzyuM2CSOmcYxM%2Fimage.png?alt=media&#x26;token=b26ae427-9444-42cb-90d4-871cde653d17" alt=""><figcaption><p>Opportunistic Wireless encryption connection</p></figcaption></figure>

## Wireless Protected Setup

### WPS Architecture

There are three components to WPS:

* Enrollee: a device seeking to join a WLAN
* Access point
* Registrar: an entity with the authority to issue or revoke credentials for a WLAN

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2Fl3UnTnKYgmdvGQZKi4Mx%2Fimage.png?alt=media&#x26;token=06dd76be-a044-40a5-9e6e-87ba3c4eb29b" alt=""><figcaption><p>WPS components and interfaces</p></figcaption></figure>

### WPS Configuration Methods

Two modes of operations are available: in-band configuration and out-of-band configuration. In-band is done via WLAN communication and out-of-band is done using any other communication channel or method, such as by using a NFC tag or USB thumbdrive.

### WPS Protocol

<figure><img src="https://2580392783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2bsvcHu5JxoX3MBNE1Wb%2Fuploads%2Fhlbci8b2ECLa8tnhNBOL%2Fimage.png?alt=media&#x26;token=4f6fa416-c3f7-4802-9c1a-8664fe626594" alt=""><figcaption><p>Setup using a standalone AP/Registrar</p></figcaption></figure>

### WPS Registration Protocol Messages

_The M1 to M8 EAP messages are specific to the WPS registration protocol._   &#x20;

## 802.11w

### Connection

The below table details the outcome of connection depending on the client and AP settings for PMF:

| AP       | Client   | Connection | PMF |
| -------- | -------- | ---------- | --- |
| No       | No       | Yes        | No  |
| No       | Capable  | Yes        | No  |
| No       | Required | No         |     |
| Capable  | No       | Yes        | No  |
| Capable  | Capable  | Yes        | Yes |
| Capable  | Required | Yes        | Yes |
| Required | No       | No         |     |
| Required | Capable  | Yes        | Yes |
| Required | Required | Yes        | Yes |

### Security Association Teardown Protection

This mechanism prevents attacks using unprotected association, disassociation or deauthentication frames from tearing down a connection.
