From eb324600295a570199a5e25eb64e60781a04fb74 Mon Sep 17 00:00:00 2001 From: Masashi Honma Date: Sat, 31 Aug 2013 16:11:48 +0300 Subject: [PATCH] Fix switching from EAP-SIM to EAP-AKA/AKA' Switching EAP method from EAP-SIM to EAP-AKA fails. wpa_cli commands are below. ------------------ sudo wpa_cli add_network sudo wpa_cli set_network 0 ssid '"eap-sim"' sudo wpa_cli set_network 0 key_mgmt WPA-EAP sudo wpa_cli set_network 0 eap SIM sudo wpa_cli set_network 0 pin '"1234"' sudo wpa_cli set_network 0 pcsc '""' sudo wpa_cli select_network 0 sudo wpa_cli disable_network 0 sudo wpa_cli disconnect sudo wpa_cli remove_network 0 sudo wpa_cli add_network sudo wpa_cli set_network 0 ssid '"eap-sim"' sudo wpa_cli set_network 0 key_mgmt WPA-EAP sudo wpa_cli set_network 0 eap AKA sudo wpa_cli set_network 0 pin '"1234"' sudo wpa_cli set_network 0 pcsc '""' sudo wpa_cli select_network 0 ------------------ Then EAP-AKA connection resulted in fail. wpa_supplicant log is below. ------------------ wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 23 (AKA) selected SCARD: Non-USIM card - cannot do UMTS auth EAP-AKA: UMTS authentication failed (AUTN) wlan0: CTRL-EVENT-EAP-FAILURE EAP authentication failed ------------------ This occurs because on the first EAP-SIM authentication, the SIM/USIM card in the device was recognized as SIM card even if it is USIM card. So this patch changes it to recognize as USIM card even if EAP-SIM authentication was required. I have tested these switching cases. EAP-SIM -> EAP-AKA EAP-SIM -> EAP-AKA' EAP-AKA -> EAP-SIM EAP-AKA -> EAP-AKA' EAP-AKA' -> EAP-SIM EAP-AKA' -> EAP-AKA Signed-hostap: Masashi Honma --- wpa_supplicant/events.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 8d6c23496..e9399fef5 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -273,7 +273,7 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, { #ifdef IEEE8021X_EAPOL #ifdef PCSC_FUNCS - int aka = 0, sim = 0, type; + int aka = 0, sim = 0; if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL) return 0; @@ -312,14 +312,9 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM " "(sim=%d aka=%d) - initialize PCSC", sim, aka); - if (sim && aka) - type = SCARD_TRY_BOTH; - else if (aka) - type = SCARD_USIM_ONLY; - else - type = SCARD_GSM_SIM_ONLY; - wpa_s->scard = scard_init(type, NULL); + wpa_s->scard = scard_init((!sim && aka) ? SCARD_USIM_ONLY : + SCARD_TRY_BOTH, NULL); if (wpa_s->scard == NULL) { wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM " "(pcsc-lite)");