Page 1 of 1

wifi wpa2 psk length >51 does not work? - Solved

Posted: Tue Jan 03, 2017 10:20 pm
by kosmonaut pirx
hello,
got my vocore2 last year already, starting to use it finally. First catch, however, wifi connection between vorcore and hostapd can't be established.

After several ours (first suspect always: special chars) figured out, wpa2 psk key length seems to be a problem. Simple example (hostapd.conf snippet):

Code: Select all
## does not work, 52chars
wpa_passphrase=0123456789012345678901234567890123456789012345678901

## works, 51chars
wpa_passphrase=012345678901234567890123456789012345678901234567890


Inserted appropriate counterpart at /etc/config/wireless at the vocore, of course.

I don't want to change the key just for this 'cause of other stations. So, maybe anyone can confirm and/or has a workaround at hand?
Of course, already searched for the net a lot.

As there are exactly 12chars missing to max of 63chars, I suspect bssid (default: mac-address, 12chars) is perhaps related in some way..

thanks&regards

Re: wifi wpa2 psk length >51 does not work?

Posted: Wed Jan 04, 2017 12:47 am
by Vonger
Oh? where do you setup this? i do not know this yet :)

Re: wifi wpa2 psk length >51 does not work?

Posted: Wed Jan 04, 2017 8:27 pm
by kosmonaut pirx
hello,
the AP is running hostapd, so it's under my direct control. I may change anything there in the corresponding conf file. At vocore it's the usual wirelesl-config file

Setup:
AP: running Gentoo Linux
4.7.0-rc2-g3058387 #9 SMP PREEMPT Sun Jul 10 12:48:03 CEST 2016 armv7l SAMSUNG EXYNOS (Flattened Device Tree) GNU/Linux
Hostapd
net-wireless/hostapd
Latest version available: 2.5
Latest version installed: 2.5

STA: Vocore2
root@OpenWrt:/# uname -a
Linux OpenWrt 3.18.29 #32 Sat Dec 24 22:01:05 CST 2016 mips GNU/Linux

I just checked a different AP (my phone) and same behavior: said 51char psk key and vocore connects, 52char psk key no connection.
Other stations (RPi, Phone)connect to said AP without problems since a year or more.

Part of /etc/config/wireless looks like this:
Code: Select all
config wifi-iface 'sta'
        option device 'radio0'
        option mode 'sta'
        option network 'wwan'
        option ifname 'apcli0'
        option led 'mediatek:orange:wifi'
#      example ssid
        option ssid 'jolla'
        option key '012345678901234567890123456789012345678901234567890'
        option encryption 'psk2+ccmp'


I noticed wifi connection is build up with the help of some kind /sbin/ap_client, which is a binary provided by mtk-sdk-wifi, kind of MediaTek soft, I guess. Did try a replacement, but the known wpa_supplicant does not work unfortunately

regards

Re: wifi wpa2 psk length >51 does not work?

Posted: Wed Jan 04, 2017 9:04 pm
by kosmonaut pirx
Some more investigations and kind-of success.

There's most likely something wrong in the used mediatek binary. Looking at some kind of code found here:
https://github.com/MediaTek-Labs/linkit-smart-7688-feed/blob/master/mtk-sdk-wifi/src/ap_client.c

It uses ioctls via 'iwpriv'. So i did the some from cli:
root@OpenWrt:/# iwpriv apcli0 set ApCliWPAPSK='0123456789012345678901234567890123456789012345678901'
and voila, immediate connection :!:

I guess using a 64char buf is not enough in
[code]
static void iwpriv(const char *name, const char *key, const char *val):
//...
[char data[64];

snprintf(data, 64, "%s=%s", key, val);/code]

This explains the missing 12 chars: "ApCliWPAPSK" is 11chars and the '=' is number 12

@Vonger: Where may I get the source of the mtk-sdk-wifi you sue to check for a patch working? Afterwards I'll close this as solved.
Thanks

Re: wifi wpa2 psk length >51 does not work?

Posted: Thu Jan 05, 2017 12:39 am
by Vonger
Wi-Fi driver from mediatek is not open source yet. :( Current one is from Linkit.

Re: wifi wpa2 psk length >51 does not work?

Posted: Thu Jan 05, 2017 9:41 pm
by kosmonaut pirx
That's exactly what I suspected :(

so maybe the board needs to be patched after each firmware update for this, but maybe it's even possible via rc.local.
Thanks a lot.