From dd43026a193058c30ab752db075c118b856d1799 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 31 Dec 2012 11:05:42 +0200 Subject: [PATCH] SAE: Rename state variables to match IEEE 802.11 standard The enum values for struct sae_data::state now match the protocol instance states as defined in IEEE Std 802.11-2012, 11.3.8.2.2 Signed-hostap: Jouni Malinen --- src/ap/ieee802_11.c | 8 ++++++-- src/common/sae.h | 2 +- wpa_supplicant/sme.c | 9 +++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 3ecac9108..88825b6ae 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -376,6 +376,7 @@ static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, sta->sae = os_zalloc(sizeof(*sta->sae)); if (sta->sae == NULL) return; + sta->sae->state = SAE_NOTHING; } if (auth_transaction == 1) { @@ -386,13 +387,14 @@ static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, ((const u8 *) mgmt) + len - mgmt->u.auth.variable); if (resp == WLAN_STATUS_SUCCESS) { - sta->sae->state = SAE_COMMIT; data = auth_process_sae_commit(hapd, sta); if (data == NULL) resp = WLAN_STATUS_UNSPECIFIED_FAILURE; + else + sta->sae->state = SAE_COMMITTED; } } else if (auth_transaction == 2) { - if (sta->sae->state != SAE_COMMIT) { + if (sta->sae->state != SAE_COMMITTED) { hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, @@ -416,6 +418,8 @@ static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, data = auth_build_sae_confirm(hapd, sta); if (data == NULL) resp = WLAN_STATUS_UNSPECIFIED_FAILURE; + else + sta->sae->state = SAE_ACCEPTED; } } else { hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, diff --git a/src/common/sae.h b/src/common/sae.h index bfefd5da6..2cafd9d65 100644 --- a/src/common/sae.h +++ b/src/common/sae.h @@ -13,7 +13,7 @@ #define SAE_CONFIRM_MAX_LEN (2 + 32) struct sae_data { - enum { SAE_INIT, SAE_COMMIT, SAE_CONFIRM } state; + enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state; u16 send_confirm; u8 kck[32]; u8 pmk[32]; diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 043a0a773..814beb756 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -344,7 +344,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, return; params.sae_data = wpabuf_head(resp); params.sae_data_len = wpabuf_len(resp); - wpa_s->sme.sae.state = start ? SAE_COMMIT : SAE_CONFIRM; + wpa_s->sme.sae.state = start ? SAE_COMMITTED : SAE_CONFIRMED; } #endif /* CONFIG_SAE */ @@ -390,7 +390,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, struct wpa_ssid *ssid) { #ifdef CONFIG_SAE - wpa_s->sme.sae.state = SAE_INIT; + wpa_s->sme.sae.state = SAE_NOTHING; wpa_s->sme.sae.send_confirm = 0; #endif /* CONFIG_SAE */ sme_send_authentication(wpa_s, bss, ssid, 1); @@ -414,7 +414,7 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction, if (wpa_s->current_bss == NULL || wpa_s->current_ssid == NULL) return -1; - if (wpa_s->sme.sae.state != SAE_COMMIT) + if (wpa_s->sme.sae.state != SAE_COMMITTED) return -1; if (sae_parse_commit(&wpa_s->sme.sae, data, len) != WLAN_STATUS_SUCCESS) @@ -431,10 +431,11 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction, return 0; } else if (auth_transaction == 2) { wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE confirm"); - if (wpa_s->sme.sae.state != SAE_CONFIRM) + if (wpa_s->sme.sae.state != SAE_CONFIRMED) return -1; if (sae_check_confirm(&wpa_s->sme.sae, data, len) < 0) return -1; + wpa_s->sme.sae.state = SAE_ACCEPTED; return 1; }