[Upgrading, Modifying and Unlocking] iboone:
My experience

Hi,

I have been the last few days been trying to make the Freewifi_secure worked on my old Y360 Huawei phone (custom ROM Resurrection Remix based on Lineage OS 14.1, rooted). I have tried many things and here are the results of what I have found.

First:

wifi data are stored in /data/misc/wifi/wpa_supplicant.conf

1°) For me, editing wpa_supplicant.conf is not working because file would get overwritten by the network manager.

Modifying it directly didn't work for me. I have checked how the wpa_supplicant.conf would change (edit/save/read after connection). When reading the file, it would somehow overwrite parameters that are not correct, when it attemps to connect. In my particular example, wpa_supplicant would need to have a additional parameter to use (id_str).

Conclusion: better to edit a existing wifi parameters in the conf file than to add new data to the conf file otherwise it gets deleted.

2°) How to debug the wifi authentification? The best way to understand what's happening

Use adb command line.

adb logcat wpa_supplicant:V *:S

With this command, now we are able to understand what's happening.

I notice that when trying to connect to Freewifi_secure, my phone would freeze/hang.. In fact, by checking the log, it's trying at least 3 times before failing to give a final result which takes time. So sometimes, depending the ROM, it would loop causing my phone to reboot or to crash.

Now, what's interesting is the errors thrown.

"EAP: buildIdentity: configuration was not available" and "Identity needed for SSID"

H:\>adb logcat wpa_supplicant:V *:S
--------- beginning of system
--------- beginning of main
04-21 19:07:22.745 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid=[ZZ:ZZ:ZZ:ZZ] reason=3 locally_generated=1 (from previous wifi connection)
04-21 19:07:22.788 1512 1512 I wpa_supplicant: wlan0: Trying to associate with SSID 'FreeWifi_secure'
04-21 19:07:22.824 1512 1512 I wpa_supplicant: wlan0: Associated with [YY:YY:YY:YY]
04-21 19:07:22.824 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
04-21 19:07:22.837 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-STARTED EAP authentication started
04-21 19:07:22.838 1512 1512 W wpa_supplicant: [B]EAP: buildIdentity: identity configuration was not available[/B]
04-21 19:07:22.838 1512 1512 I wpa_supplicant: wlan0: [B]CTRL-REQ-IDENTITY-2:Identity needed for SSID FreeWifi_secure[/B]
04-21 19:07:22.847 1512 1512 I wpa_supplicant: set country: FR
04-21 19:07:22.847 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=FR
04-21 19:07:22.875 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-STARTED EAP authentication started
04-21 19:07:22.915 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=18
04-21 19:07:22.929 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 18 (SIM) selected
04-21 19:07:22.958 1512 1512 I wpa_supplicant: wlan0: CTRL-REQ-SIM-2:GSM-AUTH:1a0679cf49925b16311dcb792d484327:da09b399079b39e9292c86ca0e7acece:d9260d3b90654aa6b4c5f2e54dff8a91 needed for SSID FreeWifi_secure
04-21 19:08:22.886 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-FAILURE EAP authentication failed
04-21 19:08:24.111 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=18
04-21 19:08:24.116 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 18 (SIM) selected
04-21 19:08:24.117 1512 1512 I wpa_supplicant: wlan0: CTRL-REQ-SIM-2:GSM-AUTH:1a0679cf49925b16311dcb792d484327:da09b399079b39e9292c86ca0e7acece:d9260d3b90654aa6b4c5f2e54dff8a91 needed for SSID FreeWifi_secure
04-21 19:08:24.895 1512 1512 I wpa_supplicant: wlan0: Authentication with [YY:YY:YY:YY] timed out.
04-21 19:08:24.912 1512 1512 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid=f4:ca:e5:c8:4c:4e reason=3 locally_generated=1

Why the freewifi_secure is failing to connect?

The EAP SIM needs to retrieve the IMSI number for authentification.

Here, for some reasons, it cannot build the identity parameters from what I understand (the identity is based on the IMSI number).

Some people would try to directly write in the conf file the identity such as:

network={
ssid="FreeWifi_secure"
key_mgmt=WPA-EAP IEEE8021X
eap=SIM
sim_slot="0"
imsi="1xxxxxxxxxxxxxxx@wlan.mnc015.mcc208.3gppnetwork.org"
identity="1xxxxxxxxxxxxxxx@wlan.mnc015.mcc208.3gppnetwork.org"
pcsc="rild"
priority=8
}

where xxxxxxxxxxxxxxx is the IMSI number, to make it work.

But in my case, that doesnt work. It gets deleted.

So two hypothesis:

1°) The IMSI number cannot be extracted from the SIM.

Not sure if it's something to dig... but IMSI seems to be found by SIM info apps.

But on the ROM i have installed (Nougat), i cannot access the contacts stored on the SIM. I don't know if it is related.

Many people reported that they can't access their SIM contacts. It would depend the ROM and version of Android.

It seems Nougat would not be able to get contacts from SIM.

So that's why this hypothesis might be relevant if for some reasons, a system program would not let access to all the SIM data. (Yet in my case SIM is found , I can phone and use mobile data. I can't just access the SIM contacts.)

2°) There is a problem with the wpa_supplicant binary which hasn't the functions to connect to EAP SIM.

I have read that when building wpa_supplicant, you need in the building CONFIG to have "CONFIG_EAP_SIM=y" & "CONFIG_PCSC=y" activated.

And by looking at the code, that might be why many CUSTOM ROMS and ROMS compiled with a wpa_supplicant cannot use EAP SIM.

Some people here reported by using another wpa_supplicant binary, it will work... the solution would be in fact

- Either to reuse another working wpa_supplicant binary (with all the required libraries). I haven't find a list of all the files that would require to be changed.

- Either to rebuild wpa_supplicant with the EAP SIM / PCSC options on my specific platform. (that would require knowledge that I don't have).

Let me know if you have find some solutions.

At the moment, reusing the wpa_supplicant from the stock ROM has failed since my Rom is in Nougat (7.1.2) as the stock Rom is in 4.4. It doesn't work as you need to change many libraries files, and so it gets unstable.

I have tried also to get a binary from another Nougat 7.1.2 rom... (from Nexus 6 ROM). definitely, the wpa_supplicant binary is compatible as I can run it on the adb shell. But also, it fails also. I have tried by modifying the wpa_supplicant.conf also.

Looking at the source, it seems that by default CONFIG_PCSC is not activated. So final conclusion: to test my hypothesis, I have to build my own wpa_supplicant with CONFIG_PCSC=y.

But this I don't know how to proceed.

Someone also has been abled to do it with a desktop linux on the net (Oh No More Gadgets blog).