From 86f6084862cd218d04b5213e7ac9df2e66ec138e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 7 Sep 2019 18:33:02 +0300 Subject: [PATCH] SAE: Tell sae_parse_commit() whether H2E is used This will be needed to help parsing the received SAE commit. Signed-off-by: Jouni Malinen --- src/ap/ieee802_11.c | 3 ++- src/common/common_module_tests.c | 2 +- src/common/sae.c | 3 ++- src/common/sae.h | 3 ++- wpa_supplicant/sme.c | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 0152cf563..b1d520874 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -1139,7 +1139,8 @@ static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, resp = sae_parse_commit(sta->sae, mgmt->u.auth.variable, ((const u8 *) mgmt) + len - mgmt->u.auth.variable, &token, - &token_len, groups); + &token_len, groups, status_code == + WLAN_STATUS_SAE_HASH_TO_ELEMENT); if (resp == SAE_SILENTLY_DISCARD) { wpa_printf(MSG_DEBUG, "SAE: Drop commit message from " MACSTR " due to reflection attack", diff --git a/src/common/common_module_tests.c b/src/common/common_module_tests.c index 30c52476b..0263709ec 100644 --- a/src/common/common_module_tests.c +++ b/src/common/common_module_tests.c @@ -377,7 +377,7 @@ static int sae_tests(void) } if (sae_parse_commit(&sae, peer_commit, sizeof(peer_commit), NULL, NULL, - NULL) != 0 || + NULL, 0) != 0 || sae_process_commit(&sae) < 0) goto fail; diff --git a/src/common/sae.c b/src/common/sae.c index 396091407..30a5e187d 100644 --- a/src/common/sae.c +++ b/src/common/sae.c @@ -1099,7 +1099,8 @@ static int sae_parse_password_identifier(struct sae_data *sae, u16 sae_parse_commit(struct sae_data *sae, const u8 *data, size_t len, - const u8 **token, size_t *token_len, int *allowed_groups) + const u8 **token, size_t *token_len, int *allowed_groups, + int h2e) { const u8 *pos = data, *end = data + len; u16 res; diff --git a/src/common/sae.h b/src/common/sae.h index 10f9302e3..ef7cf9167 100644 --- a/src/common/sae.h +++ b/src/common/sae.h @@ -72,7 +72,8 @@ int sae_process_commit(struct sae_data *sae); void sae_write_commit(struct sae_data *sae, struct wpabuf *buf, const struct wpabuf *token, const char *identifier); u16 sae_parse_commit(struct sae_data *sae, const u8 *data, size_t len, - const u8 **token, size_t *token_len, int *allowed_groups); + const u8 **token, size_t *token_len, int *allowed_groups, + int h2e); void sae_write_confirm(struct sae_data *sae, struct wpabuf *buf); int sae_check_confirm(struct sae_data *sae, const u8 *data, size_t len); u16 sae_group_allowed(struct sae_data *sae, int *allowed_groups, u16 group); diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index ad533a148..0e42542d9 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -1150,7 +1150,8 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction, if (groups && groups[0] <= 0) groups = NULL; res = sae_parse_commit(&wpa_s->sme.sae, data, len, NULL, NULL, - groups); + groups, status_code == + WLAN_STATUS_SAE_HASH_TO_ELEMENT); if (res == SAE_SILENTLY_DISCARD) { wpa_printf(MSG_DEBUG, "SAE: Drop commit message due to reflection attack");