iPXE
Functions | Variables
wpa_psk.c File Reference

Frontend for WPA using a pre-shared key. More...

#include <string.h>
#include <ipxe/net80211.h>
#include <ipxe/sha1.h>
#include <ipxe/wpa.h>
#include <errno.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int wpa_psk_init (struct net80211_device *dev)
 Initialise WPA-PSK state.
static int wpa_psk_start (struct net80211_device *dev)
 Start WPA-PSK authentication.
static int wpa_psk_step (struct net80211_device *dev)
 Step WPA-PSK authentication.
static int wpa_psk_no_change_key (struct net80211_device *dev __unused)
 Do-nothing function; you can't change a WPA key post-authentication.
static void wpa_psk_stop (struct net80211_device *dev)
 Disable handling of received WPA authentication frames.

Variables

struct net80211_handshaker
wpa_psk_handshaker 
__net80211_handshaker
 WPA-PSK security handshaker.

Detailed Description

Frontend for WPA using a pre-shared key.

Definition in file wpa_psk.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
static int wpa_psk_init ( struct net80211_device dev) [static]

Initialise WPA-PSK state.

Parameters:
dev802.11 device
Return values:
rcReturn status code

Definition at line 39 of file wpa_psk.c.

References net80211_device::rsn_ie, and wpa_make_rsn_ie().

{
        return wpa_make_rsn_ie ( dev, &dev->rsn_ie );
}
static int wpa_psk_start ( struct net80211_device dev) [static]

Start WPA-PSK authentication.

Parameters:
dev802.11 device
Return values:
rcReturn status code

Definition at line 50 of file wpa_psk.c.

References ctx, DBGC, DBGC_HD, EACCES, net80211_device::essid, fetch_string_setting(), net80211_device::handshaker, len, net80211_deauthenticate(), net80211_device::netdev, netdev_settings(), pbkdf2_sha1(), net80211_handshaker::priv, strlen(), WPA_PMK_LEN, and wpa_start().

{
        char passphrase[64+1];
        u8 pmk[WPA_PMK_LEN];
        int len;
        struct wpa_common_ctx *ctx = dev->handshaker->priv;

        len = fetch_string_setting ( netdev_settings ( dev->netdev ),
                                     &net80211_key_setting, passphrase,
                                     64 + 1 );

        if ( len <= 0 ) {
                DBGC ( ctx, "WPA-PSK %p: no passphrase provided!\n", ctx );
                net80211_deauthenticate ( dev, -EACCES );
                return -EACCES;
        }

        pbkdf2_sha1 ( passphrase, len, dev->essid, strlen ( dev->essid ),
                      4096, pmk, WPA_PMK_LEN );

        DBGC ( ctx, "WPA-PSK %p: derived PMK from passphrase `%s':\n", ctx,
               passphrase );
        DBGC_HD ( ctx, pmk, WPA_PMK_LEN );

        return wpa_start ( dev, ctx, pmk, WPA_PMK_LEN );
}
static int wpa_psk_step ( struct net80211_device dev) [static]

Step WPA-PSK authentication.

Parameters:
dev802.11 device
Return values:
rcReturn status code

Definition at line 83 of file wpa_psk.c.

References ctx, EACCES, net80211_device::handshaker, net80211_handshaker::priv, wpa_common_ctx::state, WPA_FAILURE, and WPA_SUCCESS.

{
        struct wpa_common_ctx *ctx = dev->handshaker->priv;

        switch ( ctx->state ) {
        case WPA_SUCCESS:
                return 1;
        case WPA_FAILURE:
                return -EACCES;
        default:
                return 0;
        }
}
static int wpa_psk_no_change_key ( struct net80211_device *dev  __unused) [static]

Do-nothing function; you can't change a WPA key post-authentication.

Parameters:
dev802.11 device
Return values:
rcReturn status code

Definition at line 103 of file wpa_psk.c.

{
        return 0;
}
static void wpa_psk_stop ( struct net80211_device dev) [static]

Disable handling of received WPA authentication frames.

Parameters:
dev802.11 device

Definition at line 113 of file wpa_psk.c.

References wpa_stop().

{
        wpa_stop ( dev );
}

Variable Documentation

struct net80211_handshaker wpa_psk_handshaker __net80211_handshaker
Initial value:
 {
        .protocol = NET80211_SECPROT_PSK,
        .init = wpa_psk_init,
        .start = wpa_psk_start,
        .step = wpa_psk_step,
        .change_key = wpa_psk_no_change_key,
        .stop = wpa_psk_stop,
        .priv_len = sizeof ( struct wpa_common_ctx ),
}

WPA-PSK security handshaker.

Definition at line 119 of file wpa_psk.c.