Re: [PATCH 2/3] Replace WPA_ALG_PMK with KEY_FLAG_PMK

Jouni Malinen <[email protected]>
Newsgroups gmane.linux.drivers.hostap
Message-ID <[email protected]>
On Thu, Feb 27, 2020 at 10:52:47PM +0100, Alexander Wetzel wrote:
> Drop the no longer needed internal alg WPA_ALG_PMK and use KEY_FLAG_PMK
> as replacement.

> This is of course fully optional. With the key_flag API now merged WPA_ALG_PMK
> just looks redundant and the few users of it are easily converted.

This is probably fine as a general direction, but I'm a bit concerned
about the use of this type of comparison of key_flag which is defined as
a bitmap:

> @@ -3093,7 +3092,7 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
> -	if (alg == WPA_ALG_PMK &&
> +	if (key_flag == KEY_FLAG_PMK &&

Sure, we do not really use KEY_FLAG_PMK with any other bit set, but
still, comparing key_flag to any fixed value looks a bit strange and
potentially easy to break should we ever add some more flag bits that
could be used even with KEY_FLAG_PMK.

>  	    (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X))
>  		return nl80211_set_pmk(drv, key, key_len, addr);
>  	if (key_flag & KEY_FLAG_PMK)

And here is the way of comparing it against the specific bit for PMK in
a manner that survives addition of new bits to the key_flag bitmap.

-- 
Jouni Malinen                                            PGP id EFC895FA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.