PMKSA support (SAE only)
cover PMKSA support (SAE only)
This adds support for PMKSA-based connections. For now only SAE and SAE-FT are supported. This was done for a few reasons:
- PMKSA with WPA2 doesn't make a whole lot of sense. There is no real benefit to using PMKSA over full association.
- PMKSA is required by the WiFi Alliance for WPA3 certificaion
Missing features include:
- 802.1x support, this may be added at a later date.
- Filesystem storage of PMKSA caches. For now this just hasn't been implemented.
Denis Kenzior (4):
pmksa: Add skeleton
unit: Add basic pmksa test
pmksa: Add debugging
handshake: Add pmksa setter & stealer
James Prestwood (11):
handshake: add ref counting to handshake_state
unit: update use of handshake_state with ref/unref
auto-t: always initialize StationDebug in Device class
auto-t: add pmksa_flush() to hostapd module
auto-t: update testSAE to disable PMKSA
handshake: add handshake_state_remove_pmksa
netdev: add support to use PMKSA over SAE if available
station: hold reference to handshake object
station: support PMKSA connections
auto-t: add PMKSA tests
doc: document DisablePMKSA option
.gitignore | 1 + Makefile.am | 18 +- autotests/testPMKSA-SAE/connection_test.py | 114 ++++++++++ autotests/testPMKSA-SAE/hw.conf | 7 + autotests/testPMKSA-SAE/ssidSAE.conf | 12 ++ autotests/testSAE-roam/connection_test.py | 60 +++++- autotests/testSAE/main.conf | 3 + autotests/util/hostapd.py | 4 + autotests/util/iwd.py | 4 +- src/adhoc.c | 4 +- src/ap.c | 2 +- src/handshake.c | 105 ++++++++- src/handshake.h | 21 +- src/iwd.config.rst | 5 + src/netdev.c | 31 ++- src/p2p.c | 2 +- src/pmksa.c | 235 +++++++++++++++++++++ src/pmksa.h | 46 ++++ src/station.c | 90 +++++++- src/wsc.c | 2 +- unit/test-eapol.c | 38 ++-- unit/test-pmksa.c | 164 ++++++++++++++ unit/test-sae.c | 15 +- unit/test-wsc.c | 10 +- 24 files changed, 942 insertions(+), 51 deletions(-) create mode 100644 autotests/testPMKSA-SAE/connection_test.py create mode 100644 autotests/testPMKSA-SAE/hw.conf create mode 100644 autotests/testPMKSA-SAE/ssidSAE.conf create mode 100644 src/pmksa.c create mode 100644 src/pmksa.h create mode 100644 unit/test-pmksa.c
Signature · 1 line
2.34.1
PATCH 1/15 handshake: add ref counting to handshake_state
This adds a ref count to the handshake state object (as well as ref/unref APIs). Currently IWD is careful to ensure that netdev holds the root reference to the handshake state. Other modules do track it themselves, but ensure that it doesn't get referenced after netdev frees it.
Future work related to PMKSA will require that station holds a references to the handshake state, specifically for retry logic, after netdev is done with it so we need a way to delay the free until station is also done.
--- src/adhoc.c | 4 ++-- src/ap.c | 2 +- src/handshake.c | 12 +++++++++++- src/handshake.h | 9 ++++++--- src/netdev.c | 5 +++-- src/p2p.c | 2 +- src/station.c | 8 ++++---- src/wsc.c | 2 +- 8 files changed, 29 insertions(+), 15 deletions(-)
src/adhoc.c +2 -2
@@ -94,13 +94,13 @@ static void adhoc_sta_free(void *data)eapol_sm_free (sta->sm);if (sta->hs_sta) -handshake_state_free (sta->hs_sta); +handshake_state_unref (sta->hs_sta);if (sta->sm_a)eapol_sm_free (sta->sm_a);if (sta->hs_auth) -handshake_state_free (sta->hs_auth); +handshake_state_unref (sta->hs_auth); end:l_free (sta);
src/ap.c +1 -1
@@ -230,7 +230,7 @@ static void ap_stop_handshake(struct sta_state *sta) }if (sta->hs) { -handshake_state_free (sta->hs); +handshake_state_unref (sta->hs); sta->hs =NULL ; }
src/handshake.c +11 -1
@@ -103,7 +103,14 @@ void __handshake_set_install_ext_tk_func(handshake_install_ext_tk_func_t func) install_ext_tk = func; } -void handshake_state_free (struct handshake_state *s) +struct handshake_state *handshake_state_ref (struct handshake_state *s) +{ +__sync_fetch_and_add (&s->refcount,1 ); + +return s; +} + +void handshake_state_unref (struct handshake_state *s) { __typeof__(s->free) destroy;
@@ -117,6 +124,9 @@ void handshake_state_free(struct handshake_state *s)return ; } +if (__sync_sub_and_fetch (&s->refcount,1 )) +return ; +l_free (s->authenticator_ie);l_free (s->supplicant_ie);l_free (s->authenticator_rsnxe);
src/handshake.h +6 -3
@@ -170,6 +170,8 @@ struct handshake_state {bool in_event;handshake_event_func_t event_func; + +int refcount; };#define HSID (x) UNIQUE_ID(handshake_, x)
@@ -186,7 +188,7 @@ struct handshake_state { ##__VA_ARGS__); \ \if (!HSID (hs)->in_event) { \ -handshake_state_free (HSID (hs)); \ +handshake_state_unref (HSID (hs)); \HSID (freed) = true; \ }else \HSID (hs)->in_event = false; \
@@ -194,7 +196,8 @@ struct handshake_state {HSID (freed); \ }) -void handshake_state_free (struct handshake_state *s); +struct handshake_state *handshake_state_ref (struct handshake_state *s); +void handshake_state_unref (struct handshake_state *s);void handshake_state_set_supplicant_address (struct handshake_state *s,const uint8_t *spa);
@@ -316,4 +319,4 @@ void handshake_util_build_gtk_kde(enum crypto_cipher cipher, const uint8_t *key,void handshake_util_build_igtk_kde (enum crypto_cipher cipher,const uint8_t *key,unsigned int key_index,uint8_t *to); -DEFINE_CLEANUP_FUNC (handshake_state_free); +DEFINE_CLEANUP_FUNC (handshake_state_unref);
src/netdev.c +3 -2
@@ -376,6 +376,7 @@ struct handshake_state *netdev_handshake_state_new(struct netdev *netdev) nhs->super.ifindex = netdev->index; nhs->super.free = netdev_handshake_state_free; + nhs->super.refcount =1 ; nhs->netdev = netdev;/*
@@ -828,7 +829,7 @@ static void netdev_connect_free(struct netdev *netdev)eapol_preauth_cancel (netdev->index);if (netdev->handshake) { -handshake_state_free (netdev->handshake); +handshake_state_unref (netdev->handshake); netdev->handshake =NULL ; }
@@ -4239,7 +4240,7 @@ int netdev_reassociate(struct netdev *netdev, const struct scan_bss *target_bss,eapol_sm_free (old_sm);if (old_hs) -handshake_state_free (old_hs); +handshake_state_unref (old_hs);return 0 ; }
src/p2p.c +1 -1
@@ -1497,7 +1497,7 @@ static void p2p_handshake_event(struct handshake_state *hs,static void p2p_try_connect_group (struct p2p_device *dev) {struct scan_bss *bss = dev->conn_wsc_bss; - _auto_(handshake_state_free) struct handshake_state *hs = NULL; + _auto_(handshake_state_unref) struct handshake_state *hs = NULL;struct iovec ie_iov[16 ];int ie_num =0 ;int r;
src/station.c +4 -4
@@ -1394,7 +1394,7 @@ static struct handshake_state *station_handshake_setup(struct station *station,return hs; not_supported: -handshake_state_free (hs); +handshake_state_unref (hs);return NULL ; }
@@ -2484,7 +2484,7 @@ static void station_preauthenticate_cb(struct netdev *netdev, }if (station_transition_reassociate (station, bss, new_hs) <0 ) { -handshake_state_free (new_hs); +handshake_state_unref (new_hs);station_roam_failed (station); } }
@@ -2687,7 +2687,7 @@ static bool station_try_next_transition(struct station *station, }if (station_transition_reassociate (station, bss, new_hs) <0 ) { -handshake_state_free (new_hs); +handshake_state_unref (new_hs);return false; }
@@ -3734,7 +3734,7 @@ int __station_connect_network(struct station *station, struct network *network, station_netdev_event, station_connect_cb, station);if (r <0 ) { -handshake_state_free (hs); +handshake_state_unref (hs);return r; }
src/wsc.c +1 -1
@@ -393,7 +393,7 @@ static int wsc_enrollee_connect(struct wsc_enrollee *wsce, struct scan_bss *bss,return 0 ; error: -handshake_state_free (hs); +handshake_state_unref (hs);return r; }
Signature · 1 line
2.34.1
PATCH 2/15 unit: update use of handshake_state with ref/unref
In reply to James Prestwood--- unit/test-eapol.c | 38 +++++++++++++++++++++----------------- unit/test-sae.c | 15 ++++++++------- unit/test-wsc.c | 10 ++++++---- 3 files changed, 35 insertions(+), 28 deletions(-)
unit/test-eapol.c +21 -17
@@ -94,6 +94,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex) ths->super.ifindex = ifindex; ths->super.free = test_handshake_state_free; + ths->super.refcount =1 ;return &ths->super; }
@@ -2199,7 +2200,7 @@ static void eapol_sm_test_ptk(const void *data)assert (verify_step4_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -2263,7 +2264,7 @@ static void eapol_sm_test_igtk(const void *data)assert (verify_step4_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -2332,7 +2333,7 @@ static void eapol_sm_test_wpa2_ptk_gtk(const void *data)assert (verify_gtk_step2_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -2399,7 +2400,7 @@ static void eapol_sm_test_wpa_ptk_gtk(const void *data)assert (verify_gtk_step2_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -2467,7 +2468,7 @@ static void eapol_sm_test_wpa_ptk_gtk_2(const void *data)assert (verify_gtk_step2_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -2721,7 +2722,7 @@ static void eapol_sm_wpa2_retransmit_test(const void *data)l_free (ptk);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -3141,7 +3142,7 @@ done:if (sm)eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit ();eap_exit (); }
@@ -3424,7 +3425,7 @@ static void eapol_sm_test_eap_nak(const void *data) sizeof(eap_failure), false);assert (ths->handshake_failed); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit ();eap_exit (); }
@@ -3510,7 +3511,7 @@ static void eapol_ft_handshake_test(const void *data)assert (verify_step4_called);eapol_sm_free (sm); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit (); }
@@ -3609,6 +3610,7 @@ static struct handshake_state *test_ap_sta_hs_new(struct test_ap_sta_data *s, ths->super.ifindex = ifindex; ths->super.free = (void (*)(struct handshake_state *s)) l_free; + ths->super.refcount =1 ; ths->s = s;return &ths->super;
@@ -3692,8 +3694,10 @@ static void eapol_ap_sta_handshake_test(const void *data)test_ap_sta_run (&s); -handshake_state_free (s.ap_hs); -handshake_state_free (s.sta_hs); +l_info ("freeing in eapol_ap_sta_handshake_test()" ); + +handshake_state_unref (s.ap_hs); +handshake_state_unref (s.sta_hs);__handshake_set_install_tk_func (NULL );assert (s.ap_success && s.sta_success);
@@ -3753,8 +3757,8 @@ static void eapol_ap_sta_handshake_bad_psk_test(const void *data)test_ap_sta_run (&s); -handshake_state_free (s.ap_hs); -handshake_state_free (s.sta_hs); +handshake_state_unref (s.ap_hs); +handshake_state_unref (s.sta_hs);__handshake_set_install_tk_func (NULL );/*
@@ -3825,8 +3829,8 @@ static void eapol_ap_sta_handshake_ip_alloc_ok_test(const void *data)assert (s.sta_hs->subnet_mask == s.ap_hs->subnet_mask);assert (s.sta_hs->go_ip_addr == s.ap_hs->go_ip_addr); -handshake_state_free (s.ap_hs); -handshake_state_free (s.sta_hs); +handshake_state_unref (s.ap_hs); +handshake_state_unref (s.sta_hs);__handshake_set_install_tk_func (NULL );assert (s.ap_success && s.sta_success);
@@ -3889,8 +3893,8 @@ static void eapol_ap_sta_handshake_ip_alloc_no_req_test(const void *data)assert (!s.ap_hs->support_ip_allocation);assert (!s.sta_hs->support_ip_allocation); -handshake_state_free (s.ap_hs); -handshake_state_free (s.sta_hs); +handshake_state_unref (s.ap_hs); +handshake_state_unref (s.sta_hs);__handshake_set_install_tk_func (NULL );assert (s.ap_success && s.sta_success);
unit/test-sae.c +8 -7
@@ -101,6 +101,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex) ths->super.ifindex = ifindex; ths->super.free = test_handshake_state_free; + ths->super.refcount =1 ;return &ths->super; }
@@ -183,7 +184,7 @@ static struct auth_proto *test_initialize(struct test_data *td)static void test_destruct (struct test_data *td) { -handshake_state_free (td->handshake); +handshake_state_unref (td->handshake);l_free (td); }
@@ -459,8 +460,8 @@ static void test_bad_confirm(const void *arg)assert (td1->tx_assoc_called);assert (td2->status !=0 ); -handshake_state_free (hs1); -handshake_state_free (hs2); +handshake_state_unref (hs1); +handshake_state_unref (hs2); ap1->free (ap1); ap2->free (ap2);
@@ -544,8 +545,8 @@ static void test_confirm_after_accept(const void *arg)assert (auth_proto_rx_associate (ap1, (uint8_t *)assoc, frame_len) ==0 );assert (auth_proto_rx_associate (ap2, (uint8_t *)assoc, frame_len) ==0 ); -handshake_state_free (hs1); -handshake_state_free (hs2); +handshake_state_unref (hs1); +handshake_state_unref (hs2);auth_proto_free (ap1);auth_proto_free (ap2);
@@ -621,8 +622,8 @@ static void test_end_to_end(const void *arg)assert (auth_proto_rx_associate (ap1, (uint8_t *)assoc, frame_len) ==0 );assert (auth_proto_rx_associate (ap2, (uint8_t *)assoc, frame_len) ==0 ); -handshake_state_free (hs1); -handshake_state_free (hs2); +handshake_state_unref (hs1); +handshake_state_unref (hs2);auth_proto_free (ap1);auth_proto_free (ap2);
unit/test-wsc.c +6 -4
@@ -61,6 +61,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex) ths->super.ifindex = ifindex; ths->super.free = test_handshake_state_free; + ths->super.refcount =1 ;return &ths->super; }
@@ -2093,7 +2094,7 @@ static void wsc_test_pbc_handshake(const void *data) eap_fail, sizeof(eap_fail), false);assert (verify.eapol_failed); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit ();eap_exit (); }
@@ -2216,7 +2217,7 @@ static void wsc_test_retransmission_no_fragmentation(const void *data) sizeof(eap_fail), false);assert (verify.eapol_failed); -handshake_state_free (hs); +handshake_state_unref (hs);eapol_exit ();eap_exit (); }
@@ -2335,6 +2336,7 @@ static struct handshake_state *test_ap_sta_hs_new(struct test_ap_sta_data *s, ths->super.ifindex = ifindex; ths->super.free = (void (*)(struct handshake_state *s)) l_free; + ths->super.refcount =1 ; ths->s = s;return &ths->super;
@@ -2535,8 +2537,8 @@ static void wsc_r_test_pbc_handshake(const void *data)test_ap_sta_run (&s); -handshake_state_free (s.ap_hs); -handshake_state_free (s.sta_hs); +handshake_state_unref (s.ap_hs); +handshake_state_unref (s.sta_hs);__handshake_set_install_tk_func (NULL );l_settings_free (ap_8021x_settings);l_settings_free (sta_8021x_settings);
Signature · 1 line
2.34.1
PATCH 3/15 auto-t: always initialize StationDebug in Device class
In reply to James PrestwoodSince IWD doesn't utilize DBus signals in "normal" operations its fine to lazy initialize any of the DBus interfaces since properties can be obtained as needed with Get/GetAll.
For test-runner though StationDebug uses signals for debug events and until the StationDebug class is initialized (via a method call or property access) all signals will be lost. Fix this by always initializing the StationDebug interface when a Device class is initialized.
--- autotests/util/iwd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
autotests/util/iwd.py +3 -1
@@ -450,13 +450,15 @@ class Device(IWDDBusAbstract): self._wps_manager_if = None self._station_if = None self._station_props = None - self._station_debug_obj = None self._dpp_obj = None self._sc_dpp_obj = None self._ap_obj = None IWDDBusAbstract.__init__(self, *args, **kwargs) + self._station_debug_obj = StationDebug(object_path=self._object_path, + namespace=self._namespace) + @property def _wps_manager(self): if self._wps_manager_if is None:
Signature · 1 line
2.34.1
PATCH 4/15 auto-t: add pmksa_flush() to hostapd module
In reply to James Prestwood--- autotests/util/hostapd.py | 4 ++++ 1 file changed, 4 insertions(+)
autotests/util/hostapd.py +4 -0
@@ -368,3 +368,7 @@ class HostapdCLI(object): others = [h for h in args if h != hapd] hapd._add_neighbors(*others) + + def pmksa_flush(self): + cmd = self.cmdline + ['pmksa_flush'] + ctx.start_process(cmd).wait()
Signature · 1 line
2.34.1
PATCH 5/15 auto-t: update testSAE to disable PMKSA
In reply to James PrestwoodThere are quite a few tests here for various scenarios and PMKSA throws a wrench into that. Rather than potentially breaking the tests in attempt to get them working with PMKSA, just disable PMKSA.
--- autotests/testSAE/main.conf | 3 +++ 1 file changed, 3 insertions(+)
autotests/testSAE/main.conf +3 -0
@@ -4,3 +4,6 @@ # hardware, but fails when used in simulated environment with mac80211_hwsim. # Disable MAC randomization for the tests with hidden networks. DisableMacAddressRandomization=true + +[General] +DisablePMKSA=true
Signature · 1 line
2.34.1
PATCH 6/15 pmksa: Add skeleton
In reply to James PrestwoodFrom: Denis Kenzior <[email protected]>
--- Makefile.am | 7 +- src/pmksa.c | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pmksa.h | 46 +++++++++++ 3 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 src/pmksa.c create mode 100644 src/pmksa.h
Makefile.am +5 -2
@@ -65,7 +65,8 @@ ell_headers = ell/util.h \ ell/cleanup.h \ ell/netconfig.h \ ell/sysctl.h \ - ell/notifylist.h + ell/notifylist.h \ + ell/minheap.h ell_sources = ell/private.h \ ell/missing.h \
@@ -147,7 +148,8 @@ ell_sources = ell/private.h \ ell/acd.c \ ell/netconfig.c \ ell/sysctl.c \ - ell/notifylist.c + ell/notifylist.c \ + ell/minheap.c ell_shared = ell/useful.h ell/asn1-private.h
@@ -269,6 +271,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h \ src/json.h src/json.c \ src/dpp.c \ src/udev.c \ + src/pmksa.h src/pmksa.c \ $(eap_sources) \ $(builtin_sources)
src/pmksa.c new file +224 -0
224 lines not on this page · raw message
src/pmksa.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 7/15 unit: Add basic pmksa test
In reply to James PrestwoodFrom: Denis Kenzior <[email protected]>
--- .gitignore | 1 + Makefile.am | 7 +- unit/test-pmksa.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 unit/test-pmksa.c
.gitignore +1 -0
@@ -67,6 +67,7 @@ unit/test-band unit/test-dpp unit/test-json unit/test-nl80211util +unit/test-pmksa unit/cert-*.pem unit/cert-*.csr unit/cert-*.srl
Makefile.am +6 -1
@@ -438,7 +438,8 @@ unit_tests += unit/test-cmac-aes \ unit/test-ie unit/test-util unit/test-ssid-security \ unit/test-arc4 unit/test-wsc unit/test-eap-mschapv2 \ unit/test-eap-sim unit/test-sae unit/test-p2p unit/test-band \ - unit/test-dpp unit/test-json unit/test-nl80211util + unit/test-dpp unit/test-json unit/test-nl80211util \ + unit/test-pmksa endif if CLIENT
@@ -594,6 +595,10 @@ unit_test_nl80211util_SOURCES = unit/test-nl80211util.c \ src/ie.h src/ie.c \ src/util.h src/util.c unit_test_nl80211util_LDADD = $(ell_ldadd) + +unit_test_pmksa_SOURCES = unit/test-pmksa.c src/pmksa.c src/pmksa.h \ + src/module.h src/util.h +unit_test_pmksa_LDADD = $(ell_ldadd) endif if CLIENT
unit/test-pmksa.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 8/15 pmksa: Add debugging
In reply to James PrestwoodFrom: Denis Kenzior <[email protected]>
--- src/pmksa.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
src/pmksa.c +12 -1
@@ -34,6 +34,10 @@#include "src/module.h" #include "src/pmksa.h" +#define PMKID "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" +#define PMKID_STR (x) x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], \ + x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15] +static uint64_t dot11RSNAConfigPMKLifetime =43200ULL *L_USEC_PER_SEC ;static uint32_t pmksa_cache_capacity =255 ;
@@ -108,6 +112,7 @@ struct pmksa *pmksa_cache_get(const uint8_t spa[static 6], const uint8_t *ssid, size_t ssid_len, uint32_t akm) { + struct pmksa *pmksa;int r =pmksa_cache_find (spa, aa, ssid, ssid_len, akm);if (r <0 )
@@ -121,7 +126,11 @@ struct pmksa *pmksa_cache_get(const uint8_t spa[static 6],__minheap_sift_down (cache.data, cache.used, r, &ops); done: -return cache.data[cache.used]; + pmksa = cache.data[cache.used]; + +l_debug ("Returning entry with PMKID: " PMKID ,PMKID_STR (pmksa->pmkid)); + +return pmksa; }/*
@@ -130,6 +139,8 @@ done:*/ int pmksa_cache_put (struct pmksa *pmksa) { +l_debug ("Adding entry with PMKID: " PMKID ,PMKID_STR (pmksa->pmkid)); +if (cache.used == cache.capacity) {l_free (cache.data[0 ]); cache.data[0 ] = pmksa;
Signature · 1 line
2.34.1
PATCH 9/15 handshake: Add pmksa setter & stealer
In reply to James PrestwoodFrom: Denis Kenzior <[email protected]>
The majority of this patch was authored by Denis Kenzior, but I have appended setting the PMK inside handshake_state_set_pmksa as well as checking if the pmkid exists in handshake_state_steal_pmkid.
--- Makefile.am | 4 +++ src/handshake.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ src/handshake.h | 11 ++++++- 3 files changed, 91 insertions(+), 1 deletion(-)
Makefile.am +4 -0
@@ -458,6 +458,7 @@ unit_test_eap_sim_SOURCES = unit/test-eap-sim.c \ src/eapol.h src/eapol.c \ src/eapolutil.h src/eapolutil.c \ src/handshake.h src/handshake.c \ + src/pmksa.h src/pmksa.c \ src/eap.h src/eap.c src/eap-private.h \ src/util.h src/util.c \ src/simauth.h src/simauth.c \
@@ -517,6 +518,7 @@ unit_test_eapol_SOURCES = unit/test-eapol.c \ src/eapol.h src/eapol.c \ src/eapolutil.h src/eapolutil.c \ src/handshake.h src/handshake.c \ + src/pmksa.h src/pmksa.c \ src/eap.h src/eap.c src/eap-private.h \ src/eap-tls.c src/eap-ttls.c \ src/eap-md5.c src/util.c \
@@ -547,6 +549,7 @@ unit_test_wsc_SOURCES = unit/test-wsc.c src/wscutil.h src/wscutil.c \ src/eapol.h src/eapol.c \ src/eapolutil.h src/eapolutil.c \ src/handshake.h src/handshake.c \ + src/pmksa.h src/pmksa.c \ src/eap.h src/eap.c src/eap-private.h \ src/util.h src/util.c \ src/erp.h src/erp.c \
@@ -565,6 +568,7 @@ unit_test_sae_SOURCES = unit/test-sae.c \ src/crypto.h src/crypto.c \ src/ie.h src/ie.c \ src/handshake.h src/handshake.c \ + src/pmksa.h src/pmksa.c \ src/erp.h src/erp.c \ src/band.h src/band.c \ src/util.h src/util.c \
src/handshake.c +77 -0
98 lines not on this page · raw message
src/handshake.h +10 -1
@@ -29,6 +29,7 @@struct handshake_state ;enum crypto_cipher ;struct eapol_frame ; +struct pmksa ;enum handshake_kde {/* 802.11-2020 Table 12-9 in section 12.7.2 */
@@ -141,7 +142,12 @@ struct handshake_state { bool supplicant_ocvc : 1; bool ext_key_id_capable : 1; bool force_default_ecc_group : 1; -uint8_t ssid[SSID_MAX_SIZE ]; + bool have_pmksa : 1; +union { +struct pmksa *pmksa; +uint64_t expiration; + }; +uint8_t ssid[32 ];size_t ssid_len;char *passphrase;char *password_identifier;
@@ -302,6 +308,9 @@ void handshake_state_set_chandef(struct handshake_state *s,int handshake_state_verify_oci (struct handshake_state *s,const uint8_t *oci,size_t oci_len); +bool handshake_state_set_pmksa (struct handshake_state *s,struct pmksa *pmksa); +void handshake_state_cache_pmksa (struct handshake_state *s); +bool handshake_util_ap_ie_matches (const struct ie_rsn_info *msg_info,const uint8_t *scan_ie,bool is_wpa);
Signature · 1 line
2.34.1
Re: [PATCH 09/15] handshake: Add pmksa setter & stealer
Hi James,
Quoted 15 lines · James Prestwood
From: Denis Kenzior <[email protected]>
The majority of this patch was authored by Denis Kenzior, but I have appended setting the PMK inside
handshake_state_set_pmksaas well as checking if the pmkid exists inhandshake_state_steal_pmkid.Authored-by Denis Kenzior <[email protected]>Authored-by James Prestwood <[email protected]>--- Makefile.am | 4 +++ src/handshake.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ src/handshake.h | 11 ++++++- 3 files changed, 91 insertions(+), 1 deletion(-)
<snip>
src/handshake.h struct handshake_state { · line 150
Quoted 11 lines
src/handshake.h +6
-1@@ -141,7 +142,12 @@ struct handshake_state { bool supplicant_ocvc : 1; bool ext_key_id_capable : 1; bool force_default_ecc_group : 1; -uint8_t ssid[SSID_MAX_SIZE ]; + bool have_pmksa : 1; +union { +struct pmksa *pmksa; +uint64_t expiration; + }; +uint8_t ssid[32 ];
I changed this back to using SSID_MAX_SIZE instead of the magic number.
src/handshake.h struct handshake_state { · line 153
Quoted 3 lines
src/handshake.h +0
-0size_t ssid_len;char *passphrase;char *password_identifier;
All 15 patches applied, thanks.
Regards,
-Denis
Re: [PATCH 09/15] handshake: Add pmksa setter & stealer
Hi Denis,
Quoted 35 lines · Denis Kenzior
Hi James,
Quoted 15 lines · James Prestwood
From: Denis Kenzior <[email protected]>
The majority of this patch was authored by Denis Kenzior, but I have appended setting the PMK inside
handshake_state_set_pmksaas well as checking if the pmkid exists inhandshake_state_steal_pmkid.Authored-by Denis Kenzior <[email protected]>Authored-by James Prestwood <[email protected]>---
Makefile.am | 4 +++
src/handshake.c| 77 +++++++++++++++++++++++++++++++++++++++++++++++++src/handshake.h| 11 ++++++-3 files changed, 91 insertions(+), 1 deletion(-)<snip>
src/handshake.h struct handshake_state { · line 150
Quoted 11 lines
src/handshake.h +6
-1@@ -141,7 +142,12 @@ struct handshake_state { bool supplicant_ocvc : 1; bool ext_key_id_capable : 1; bool force_default_ecc_group : 1; - uint8_t ssid[SSID_MAX_SIZE]; + bool have_pmksa : 1; + union { + struct pmksa *pmksa; + uint64_t expiration; + }; + uint8_t ssid[32];I changed this back to using
SSID_MAX_SIZEinstead of the magic number.
Quoted 5 lines
src/handshake.h struct handshake_state { · line 153
Quoted 3 lines
src/handshake.h +0
-0size_t ssid_len; char *passphrase; char *password_identifier;All 15 patches applied, thanks.
Thanks!
Bryce, I know you were interested in this. It would be good to see if this allows IWD to pass certification with the wifi alliance. Let us know if you run into any more problems on that front.
Thanks,
James
Re: [PATCH 09/15] handshake: Add pmksa setter & stealer
Hi James,
Thanks! We will running another product through wifi certification in the next 3-6 months with a new chipset from TI (cc3301). I'll check with TI to see if there is a pretest so we aren't running into issues at the lab. We got our last product certified reverting back to wpa_supplicant just before the wifi alliance pushed out the latest changes/requirements.
Also annoying the cheaper automatic testing uses wpa_suppliant pretty integrated, hopefully wifi alliance will create a way to do that with IWD in the same way if enough people are using it.
If anyone got a product through certification I would be interested in any experiences with IWD!
Bryce
Quoted 56 lines · James Prestwood
Hi Denis,
Quoted 35 lines · Denis Kenzior
Hi James,
Quoted 15 lines · James Prestwood
From: Denis Kenzior <[email protected]>
The majority of this patch was authored by Denis Kenzior, but I have appended setting the PMK inside
handshake_state_set_pmksaas well as checking if the pmkid exists inhandshake_state_steal_pmkid.Authored-by Denis Kenzior <[email protected]>Authored-by James Prestwood <[email protected]>--- Makefile.am | 4 +++ src/handshake.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ src/handshake.h | 11 ++++++- 3 files changed, 91 insertions(+), 1 deletion(-)<snip>
src/handshake.h struct handshake_state { · line 150
Quoted 11 lines
src/handshake.h +6
-1@@ -141,7 +142,12 @@ struct handshake_state { bool supplicant_ocvc : 1; bool ext_key_id_capable : 1; bool force_default_ecc_group : 1; -uint8_t ssid[SSID_MAX_SIZE ]; + bool have_pmksa : 1; +union { +struct pmksa *pmksa; +uint64_t expiration; + }; +uint8_t ssid[32 ];I changed this back to using
SSID_MAX_SIZEinstead of the magic number.Quoted 5 lines
src/handshake.h struct handshake_state { · line 153
Quoted 3 lines
src/handshake.h +0
-0size_t ssid_len;char *passphrase;char *password_identifier;All 15 patches applied, thanks.
Thanks!
Bryce, I know you were interested in this. It would be good to see if this allows IWD to pass certification with the wifi alliance. Let us know if you run into any more problems on that front.
Thanks,
James
Re: [PATCH 09/15] handshake: Add pmksa setter & stealer
Hi Bryce,
Quoted 7 lines · Bryce Johnson
Hi James,
Thanks! We will running another product through wifi certification in the next 3-6 months with a new chipset from TI (cc3301). I'll check with TI to see if there is a pretest so we aren't running into issues at the lab. We got our last product certified reverting back towpa_supplicantjust before the wifi alliance pushed out the latest changes/requirements.
Great, eager to hear how it goes.
Quoted 4 lines
Also annoying the cheaper automatic testing uses
wpa_suppliantpretty integrated, hopefully wifi alliance will create a way to do that with IWD in the same way if enough people are using it.
I'd be interested to see what they are doing with this. If they are letting wpa_supplicant act autonomously and triggering things on the AP side, or if they are using the CLI to interact with wpa_supplicant directly for "force" it to exercise some of the features they're testing.
Quoted 59 lines
If anyone got a product through certification I would be interested in any experiences with IWD!
Bryce
Quoted 51 lines · James Prestwood
Hi Denis,
Quoted 33 lines · Denis Kenzior
Hi James,
Quoted 15 lines · James Prestwood
From: Denis Kenzior <[email protected]>
The majority of this patch was authored by Denis Kenzior, but I have appended setting the PMK inside
handshake_state_set_pmksaas well as checking if the pmkid exists inhandshake_state_steal_pmkid.Authored-by Denis Kenzior <[email protected]>Authored-by James Prestwood <[email protected]>--- Makefile.am | 4 +++ src/handshake.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ src/handshake.h | 11 ++++++- 3 files changed, 91 insertions(+), 1 deletion(-)<snip>
src/handshake.h struct handshake_state { · line 150
Quoted 11 lines
src/handshake.h +6
-1@@ -141,7 +142,12 @@ struct handshake_state { bool supplicant_ocvc : 1; bool ext_key_id_capable : 1; bool force_default_ecc_group : 1; -uint8_t ssid[SSID_MAX_SIZE ]; + bool have_pmksa : 1; +union { +struct pmksa *pmksa; +uint64_t expiration; + }; +uint8_t ssid[32 ];I changed this back to using
SSID_MAX_SIZEinstead of the magic number.Quoted 4 lines
src/handshake.h struct handshake_state { · line 153
Quoted 3 lines
src/handshake.h +0
-0size_t ssid_len;char *passphrase;char *password_identifier;All 15 patches applied, thanks.
Thanks!
Bryce, I know you were interested in this. It would be good to see if this allows IWD to pass certification with the wifi alliance. Let us know if you run into any more problems on that front.
Thanks,
James
Re: [PATCH 09/15] handshake: Add pmksa setter & stealer
Hi James,
Quoted 8 lines
Quoted 4 lines
Also annoying the cheaper automatic testing uses
wpa_suppliantpretty integrated, hopefully wifi alliance will create a way to do that with IWD in the same way if enough people are using it.I'd be interested to see what they are doing with this. If they are letting
wpa_supplicantact autonomously and triggering things on the AP side, or if they are using the CLI to interact withwpa_supplicantdirectly for "force" it to exercise some of the features they're testing.
I looked into it a year or so ago - a bunch of it is hidden behind the wifi alliance paywall... but they have some examples,
https://github.com/Wi-FiTestSuite/Wi-FiTestSuite-Linux-DUT - looks like using wpa_cli in some cases.
Also: Mentioned in the doc/INSTALL for the DUT agent
3. Running the software
3.1 DUT -- dut/wfa_dut
a. The current implementation is based on the open source wpa_supplicant
(hostap.epitest.fi/wpa_supplicant). The DUT must have this installed.
The test lab had to run the tests "manually" when I tried to use IWD to get it certified before.
Bryce
PATCH 10/15 handshake: add handshake_state_remove_pmksa
In reply to James PrestwoodThis is needed in order to clear the PMKSA from the handshake state without actually putting it back into the cache. This is something that will be needed in case the AP rejects the association due to an expired (or forgotten) PMKSA.
--- src/handshake.c | 16 ++++++++++++++++ src/handshake.h | 1 + 2 files changed, 17 insertions(+)
src/handshake.c +16 -0
@@ -1280,3 +1280,19 @@ void handshake_state_cache_pmksa(struct handshake_state *s)if (L_WARN_ON (pmksa_cache_put (pmksa) <0 ))l_free (pmksa); } + +bool handshake_state_remove_pmksa (struct handshake_state *s) +{ +struct pmksa *pmksa; + +if (!s->have_pmksa) +return false; + + pmksa =handshake_state_steal_pmksa (s); +if (!pmksa) +return false; + +l_free (pmksa); + +return true; +}
src/handshake.h +1 -0
@@ -310,6 +310,7 @@ int handshake_state_verify_oci(struct handshake_state *s, const uint8_t *oci,bool handshake_state_set_pmksa (struct handshake_state *s,struct pmksa *pmksa);void handshake_state_cache_pmksa (struct handshake_state *s); +bool handshake_state_remove_pmksa (struct handshake_state *s);bool handshake_util_ap_ie_matches (const struct ie_rsn_info *msg_info,const uint8_t *scan_ie,bool is_wpa);
Signature · 1 line
2.34.1
PATCH 11/15 netdev: add support to use PMKSA over SAE if available
In reply to James PrestwoodThis was quite simple and only requiring caching the PMKSA after a successful handshake, and using the correct authentication type for connections if we have a prior PMKSA cached.
This is only being added for initial SAE associations for now since this is where we gain the biggest improvement, in addition to the requirement by the WiFi alliance to label products as "WPA3 capable"
--- src/netdev.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
src/netdev.c +25 -1
@@ -65,6 +65,7 @@#include "src/frame-xchg.h" #include "src/diagnostic.h" #include "src/band.h" +#include "src/pmksa.h" #ifndef ENOTSUPP #define ENOTSUPP 524
@@ -1517,6 +1518,8 @@ static void try_handshake_complete(struct netdev_handshake_state *nhs)l_debug ("Invoking handshake_event()" ); +handshake_state_cache_pmksa (&nhs->super); +if (handshake_event (&nhs->super,HANDSHAKE_EVENT_COMPLETE ))return ;
@@ -2458,7 +2461,19 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, {struct netdev_handshake_state *nhs = l_container_of(hs, struct netdev_handshake_state, super); -uint32_t auth_type =IE_AKM_IS_SAE (hs->akm_suite) ? +/* +* Choose Open system auth type if PMKSA caching is used for an SAE AKM: +* +* IEEE 802.11-2020 Table 9-151 +* - SAE authentication: +* 3 (SAE) for SAE Authentication +* 0 (open) for PMKSA caching +* - FT authentication over SAE: +* 3 (SAE) for FT Initial Mobility Domain Association +* 0 (open) for FT Initial Mobility Domain Association over +* PMKSA caching +*/ +uint32_t auth_type =IE_AKM_IS_SAE (hs->akm_suite) && !hs->have_pmksa ?NL80211_AUTHTYPE_SAE :NL80211_AUTHTYPE_OPEN_SYSTEM ; enum mpdu_management_subtype subtype = prev_bssid ?
@@ -4027,6 +4042,15 @@ static void netdev_connect_common(struct netdev *netdev, goto done; } +/* +* If SAE, and we have a valid PMKSA cache we can skip the entire SAE +* protocol and authenticate using the cached keys. +*/ +if (IE_AKM_IS_SAE (hs->akm_suite) && hs->have_pmksa) { +l_debug ("Skipping SAE by using PMKSA cache" ); + goto build_cmd_connect; + } +if (!IE_AKM_IS_SAE (hs->akm_suite) || nhs->type ==CONNECTION_TYPE_SAE_OFFLOAD ) goto build_cmd_connect;
Signature · 1 line
2.34.1
PATCH 12/15 station: hold reference to handshake object
In reply to James PrestwoodTo prepare for PMKSA support station needs access to the handshake object. This is because if PMKSA fails due to an expired/missing PMKSA on the AP station should retry using the standard association. This poses a problem currently because netdev frees the handshake prior to calling the connect callback.
--- src/station.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
src/station.c +28 -0
@@ -135,6 +135,8 @@ struct station {unsigned int affinity_watch;char *affinity_client; +struct handshake_state *hs; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1;
@@ -1771,6 +1773,11 @@ static void station_enter_state(struct station *station, station->affinity_watch =0 ; } +if (station->hs) { +handshake_state_unref (station->hs); + station->hs =NULL ; + } +break ;case STATION_STATE_DISCONNECTING :case STATION_STATE_NETCONFIG :
@@ -2487,6 +2494,9 @@ static void station_preauthenticate_cb(struct netdev *netdev,handshake_state_unref (new_hs);station_roam_failed (station); } + +handshake_state_unref (station->hs); + station->hs =handshake_state_ref (new_hs); }static void station_transition_start (struct station *station);
@@ -2691,6 +2701,9 @@ static bool station_try_next_transition(struct station *station,return false; } +handshake_state_unref (station->hs); + station->hs =handshake_state_ref (new_hs); +return true; }
@@ -3721,6 +3734,15 @@ int __station_connect_network(struct station *station, struct network *network,struct handshake_state *hs;int r; +/* +* If we already have a handshake_state ref this is due to a retry, +* unref that now +*/ +if (station->hs) { +handshake_state_unref (station->hs); + station->hs =NULL ; + } +if (station->netconfig && !netconfig_load_settings ( station->netconfig,network_get_settings (network)))
@@ -3747,6 +3769,7 @@ int __station_connect_network(struct station *station, struct network *network, station->connected_bss = bss; station->connected_network = network; + station->hs =handshake_state_ref (hs);if (station->state != state)station_enter_state (station, state);
@@ -5039,6 +5062,11 @@ static void station_free(struct station *station)l_queue_destroy (station->owe_hidden_scan_ids,NULL ); } +if (station->hs) { +handshake_state_unref (station->hs); + station->hs =NULL ; + } +station_roam_state_clear (station);l_queue_destroy (station->networks_sorted,NULL );
Signature · 1 line
2.34.1
PATCH 13/15 station: support PMKSA connections
In reply to James PrestwoodThe actual connection piece of this is very minimal, and only requires station to check if there is a PMKSA cached, and if so include the PMKID in the RSNE. Netdev then takes care of the rest.
The remainder of this patch is the error handling if a PMKSA connection fails with INVALID_PMKID. In this case IWD should retry the same BSS without PMKSA.
An option was also added to disable PMKSA if a user wants to do that. In theory PMKSA is actually less secure compared to SAE so it could be something a user wants to disable. Going forward though it will be enabled by default as its a requirement from the WiFi alliance for WPA3 certification.
--- src/station.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
src/station.c +53 -1
@@ -63,6 +63,7 @@#include "src/eap.h" #include "src/eap-tls-common.h" #include "src/storage.h" +#include "src/pmksa.h" #define STATION_RECENT_NETWORK_LIMIT 5#define STATION_RECENT_FREQS_LIMIT 5
@@ -78,6 +79,7 @@ static bool supports_drop_gratuitous_arp;static bool supports_drop_unsolicited_na;static bool supports_ipv4_drop_unicast_in_l2_multicast;static bool supports_ipv6_drop_unicast_in_l2_multicast; +static bool pmksa_disabled;static struct watchlist event_watches;static uint32_t known_networks_watch;static uint32_t allowed_bands;
@@ -1157,6 +1159,7 @@ static int station_build_handshake_rsn(struct handshake_state *hs,struct network *network, struct scan_bss *bss) { + struct netdev *netdev = netdev_find(hs->ifindex);const struct l_settings *settings =iwd_get_config ();enum security security =network_get_security (network);bool add_mde = false;
@@ -1167,6 +1170,7 @@ static int station_build_handshake_rsn(struct handshake_state *hs,uint8_t *ap_ie;bool disable_ocv;enum band_freq band; +struct pmksa *pmksa;memset (&info,0 ,sizeof (info));
@@ -1300,6 +1304,17 @@ build_ie: IE_CIPHER_IS_GCMP_CCMP(info.pairwise_ciphers)) info.extended_key_id = true; +if (IE_AKM_IS_SAE (info.akm_suites) && !pmksa_disabled) { + pmksa =pmksa_cache_get (netdev_get_address (netdev), bss->addr, + bss->ssid, bss->ssid_len, + info.akm_suites); +if (pmksa) { +handshake_state_set_pmksa (hs, pmksa); + info.num_pmkids =1 ; + info.pmkids = hs->pmksa->pmkid; + } + } +/* RSN takes priority */ if (bss->rsne) { ap_ie = bss->rsne;
@@ -3391,6 +3406,39 @@ try_next:return station_try_next_bss (station); } +static bool station_pmksa_fallback (struct station *station,uint16_t status) +{ +/* +* IEEE 802.11-2020 12.6.10.3 Cached PMKSAs and RSNA key management +* +* "If the Authenticator does not have a PMKSA for the PMKIDs in the +* (re)association request or the AKM does not match, its behavior +* depends on how the PMKSA was established. If SAE authentication was +* used to establish the PMKSA, then the AP shall reject (re)association +* by sending a (Re)Association Response frame with status code +* STATUS_INVALID_PMKID. Note that this allows the non-AP STA to fall +* back to full SAE authentication to establish another PMKSA" +*/ +if (status !=MMPDU_STATUS_CODE_INVALID_PMKID ) +return false; + +if (L_WARN_ON (!station->hs)) +return false; + +if (!IE_AKM_IS_SAE (station->hs->akm_suite) || !station->hs->have_pmksa) +return false; + +/* +* Remove the PMKSA from the handshake and return true to re-try the +* same BSS without PMKSA. +*/ +handshake_state_remove_pmksa (station->hs); + +station_debug_event (station,"pmksa-invalid-pmkid" ); + +return true; +} +/* A bit more concise for trying to fit these into 80 characters */ #define IS_TEMPORARY_STATUS (code) \ ((code) == MMPDU_STATUS_CODE_DENIED_UNSUFFICIENT_BANDWIDTH || \
@@ -3414,7 +3462,7 @@ static bool station_retry_with_status(struct station *station,if (IS_TEMPORARY_STATUS (status_code))network_blacklist_add (station->connected_network, station->connected_bss); -else +else if (!station_pmksa_fallback (station, status_code))blacklist_add_bss (station->connected_bss->addr);iwd_notice (IWD_NOTICE_CONNECT_FAILED ,"status: %u" , status_code);
@@ -5830,6 +5878,10 @@ static int station_init(void) &anqp_disabled)) anqp_disabled = true; +if (!l_settings_get_bool (iwd_get_config (),"General" ,"DisablePMKSA" , + &pmksa_disabled)) + pmksa_disabled = false; +if (!netconfig_enabled ())l_info ("station: Network configuration is disabled." );
Signature · 1 line
2.34.1
PATCH 14/15 auto-t: add PMKSA tests
In reply to James PrestwoodAdds a test for just PMKSA and testing expiration as well as includes some PMKSA tests in the SAE roaming test to ensure FT/reassociation works.
--- autotests/testPMKSA-SAE/connection_test.py | 114 +++++++++++++++++++++ autotests/testPMKSA-SAE/hw.conf | 7 ++ autotests/testPMKSA-SAE/ssidSAE.conf | 12 +++ autotests/testSAE-roam/connection_test.py | 60 ++++++++++- 4 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 autotests/testPMKSA-SAE/connection_test.py create mode 100644 autotests/testPMKSA-SAE/hw.conf create mode 100644 autotests/testPMKSA-SAE/ssidSAE.conf
autotests/testPMKSA-SAE/connection_test.py new file +114 -0
@@ -0,0 +1,114 @@ +#!/usr/bin/python3 + +import unittest +import sys + +sys.path.append('../util') +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType +from hostapd import HostapdCLI +import testutil + +class Test(unittest.TestCase): + + def validate_connection(self, wd, ssid, hostapd, expected_group): + psk_agent = PSKAgent("secret123") + wd.register_psk_agent(psk_agent) + + devices = wd.list_devices(1) + self.assertIsNotNone(devices) + device = devices[0] + + device.disconnect() + + network = device.get_ordered_network(ssid, full_scan=True) + + self.assertEqual(network.type, NetworkType.psk) + + network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + wd.wait(2) + + testutil.test_iface_operstate(intf=device.name) + testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) + + # Initial connection PMKSA should not be used. So we should see the + # SAE group set. + sta_status = hostapd.sta_status(device.address) + self.assertEqual(int(sta_status["sae_group"]), expected_group) + + device.disconnect() + + condition = 'not obj.connected' + wd.wait_for_object_condition(network.network_object, condition) + + wd.unregister_psk_agent(psk_agent) + + network.network_object.connect(wait=False) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + wd.wait(2) + + testutil.test_iface_operstate(intf=device.name) + testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) + + # Having connected once prior we should have a PMKSA and SAE should not + # have been used. + sta_status = hostapd.sta_status(device.address) + self.assertNotIn("sae_group", sta_status.keys()) + + device.disconnect() + + condition = 'not obj.connected' + wd.wait_for_object_condition(network.network_object, condition) + + hostapd.pmksa_flush() + + wd.wait(5) + + network.network_object.connect() + + device.wait_for_event("pmksa-invalid-pmkid") + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + wd.wait(2) + + testutil.test_iface_operstate(intf=device.name) + testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) + + # Manually flushing the PMKSA from the AP then reconnecting we should + # have failed (INVALID_PMKID) then retried the same BSS with SAE, not + # PMKSA. + sta_status = hostapd.sta_status(device.address) + self.assertEqual(int(sta_status["sae_group"]), expected_group) + + def test_pmksa_sae(self): + self.hostapd.wait_for_event("AP-ENABLED") + self.validate_connection(self.wd, "ssidSAE", self.hostapd, 19) + + def setUp(self): + self.hostapd.default() + self.wd = IWD(True) + + def tearDown(self): + self.wd.clear_storage() + self.wd = None + + @classmethod + def setUpClass(cls): + cls.hostapd = HostapdCLI(config='ssidSAE.conf') + + @classmethod + def tearDownClass(cls): + pass + +if __name__ == '__main__': + unittest.main(exit=True)
autotests/testPMKSA-SAE/hw.conf new file +7 -0
@@ -0,0 +1,7 @@ +[SETUP] +num_radios=2 +start_iwd=0 +hwsim_medium=yes + +[HOSTAPD] +rad0=ssidSAE.conf
autotests/testPMKSA-SAE/ssidSAE.conf new file +12 -0
@@ -0,0 +1,12 @@ +hw_mode=g +channel=1 +ssid=ssidSAE + +wpa=2 +wpa_key_mgmt=SAE +wpa_pairwise=CCMP +sae_password=secret123 +sae_groups=19 +ieee80211w=2 +sae_pwe=0 +rsn_preauth=1
autotests/testSAE-roam/connection_test.py +59 -1
84 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 15/15 doc: document DisablePMKSA option
In reply to James Prestwood--- src/iwd.config.rst | 5 +++++ 1 file changed, 5 insertions(+)
src/iwd.config.rst +5 -0
@@ -225,6 +225,11 @@ The group ``[General]`` contains general settings. request is just a 'hint' and ultimately left up to the kernel to set the country. + * - DisablePMKSA + - Value: **false**, true + + Disable PMKSA support in IWD + Network -------
Signature · 1 line
2.34.1