From fcb3f11e4d536ca6e7f297db488394ed843bb753 Mon Sep 17 00:00:00 2001 From: Ashok Ponnaiah Date: Fri, 30 Nov 2018 17:26:26 +0200 Subject: [PATCH] SAE: Fix external authentication on big endian platforms Need to handle the little endian 16-bit fields properly when building and parsing Authentication frames. Fixes: 5ff39c1380d9 ("SAE: Support external authentication offload for driver-SME cases") Signed-off-by: Ashok Ponnaiah --- wpa_supplicant/sme.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index a7e3bf28b..ccc2064bc 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -895,10 +895,10 @@ static int sme_external_auth_build_buf(struct wpabuf *buf, os_memcpy(resp->da, da, ETH_ALEN); os_memcpy(resp->sa, sa, ETH_ALEN); os_memcpy(resp->bssid, da, ETH_ALEN); - resp->u.auth.auth_alg = WLAN_AUTH_SAE; - resp->seq_ctrl = seq_num << 4; - resp->u.auth.auth_transaction = auth_transaction; - resp->u.auth.status_code = WLAN_STATUS_SUCCESS; + resp->u.auth.auth_alg = host_to_le16(WLAN_AUTH_SAE); + resp->seq_ctrl = host_to_le16(seq_num << 4); + resp->u.auth.auth_transaction = host_to_le16(auth_transaction); + resp->u.auth.status_code = host_to_le16(WLAN_STATUS_SUCCESS); if (params) wpabuf_put_buf(buf, params); @@ -1178,13 +1178,14 @@ void sme_external_auth_mgmt_rx(struct wpa_supplicant *wpa_s, return; } - if (header->u.auth.auth_alg == WLAN_AUTH_SAE) { + if (le_to_host16(header->u.auth.auth_alg) == WLAN_AUTH_SAE) { int res; - res = sme_sae_auth(wpa_s, header->u.auth.auth_transaction, - header->u.auth.status_code, - header->u.auth.variable, - len - auth_length, 1, header->sa); + res = sme_sae_auth( + wpa_s, le_to_host16(header->u.auth.auth_transaction), + le_to_host16(header->u.auth.status_code), + header->u.auth.variable, + len - auth_length, 1, header->sa); if (res < 0) { /* Notify failure to the driver */ sme_send_external_auth_status(