[PATCH] wpa_passphrase: Encode non-ascii SSID in hex

Jouni Malinen j at w1.fi
Sun Nov 20 05:35:24 PST 2022


On Sun, Nov 13, 2022 at 09:37:42AM +0000, Jörn Bethune wrote:
> Issue: wpa_passphrase does not encode non-ascii SSID names.
>        wpa_supplicant needs the name to be encoded to identify the
>        right configuration entry when connecting.

I'm not sure what you mean here with requiring encoding and why this
change would be needed.

> This is my first contribution to this project.

All this text would go into the commit message and as such, this type of
notes should not be included.

> Current implementation:
> 
> $ wpa_passphrase "netwörk" thepassword
> network={
> 	ssid="netwörk"
> 	#psk="thepassword"
> 	psk=30cd9c223d9ba6bf1536b2fd88947c4f21c3b0b4ce680ab502b06d293721e327
> }
> 
> The password is correct. But the SSID won't be matched by
> wpa_supplicant.

It does in my tests..
./wpa_passphrase "netwörk" thepassword > /tmp/a.conf
./wpa_supplicant -i wlan0 -c /tmp/a.conf -dd
...
Line: 1 - start of a new network block
ssid - hexdump_ascii(len=8):
     6e 65 74 77 c3 b6 72 6b                           netw__rk        
PSK - hexdump(len=32): 30 cd 9c 22 3d 9b a6 bf 15 36 b2 fd 88 94 7c 4f 21 c3 b0 b4 ce 68 0a b5 02 b0 6d 29 37 21 e3 27
Priority group 0
   id=0 ssid='netw\xc3\xb6rk'

> Patched implementation:
> 
> $ ./wpa_passphrase "netwörk" thepassword
> network={
> 	#ssid="netwörk"
> 	ssid=6e657477c3b6726b

That hexdump of the SSID matches the one shows up above without any
wpa_passphrase modification..

> The patched wpa_passphrase includes the human-readable SSID as a
> comment, just like what we already have for the psk parameter. In the
> above example, the "ö" is represented by the two-byte sequence c3b6.

UTF-8 encoded 'ö' ended up getting encoded as c3b6 in the ssid parameter
and wpa_supplicant reads that as-is.

> Signed-off-by : Jörn Bethune <bethune+hostap at posteo dot de>

There should not be space between "Signed-off-by" and ":".

> diff --git a/src/utils/common.c b/src/utils/common.c
> +int is_within_ascii_range(const char *str)

bool is the currently preferred type for boolean values in new code even
thought int is still uses in hostap.git for most cases.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list