Skip to content

Commit 4b6b9c0

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'fix/config_param_gtk_rekeying' into 'master'
Add config param for gtk rekeying on softAP side Closes WIFI-4897 See merge request espressif/esp-idf!38383
2 parents fc69f69 + 004abeb commit 4b6b9c0

File tree

7 files changed

+46
-1
lines changed

7 files changed

+46
-1
lines changed

components/esp_wifi/include/esp_wifi_types_generic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ typedef struct {
539539
uint8_t transition_disable; /**< Whether to enable transition disable feature */
540540
uint8_t sae_ext; /**< Enable SAE EXT feature. SOC_GCMP_SUPPORT is required for this feature. */
541541
wifi_bss_max_idle_config_t bss_max_idle_cfg; /**< Configuration for bss max idle, effective if CONFIG_WIFI_BSS_MAX_IDLE_SUPPORT is enabled */
542+
uint16_t gtk_rekey_interval; /**< GTK rekeying interval in seconds. If set to 0, GTK rekeying is disabled. Range: 60 ~ 65535 including 0. */
542543
} wifi_ap_config_t;
543544

544545
#define SAE_H2E_IDENTIFIER_LEN 32 /**< Length of the password identifier for H2E */

components/wpa_supplicant/esp_supplicant/src/esp_hostap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ void *hostap_init(void)
8484

8585
hapd->conf->sae_pwe = esp_wifi_get_config_sae_pwe_h2e_internal(WIFI_IF_AP);
8686
auth_conf->sae_pwe = hapd->conf->sae_pwe;
87+
auth_conf->wpa_group_rekey = esp_wifi_ap_get_gtk_rekeying_config_internal();
88+
#define MIN_GTK_REKEYING_INTERVAL 60
89+
if (auth_conf->wpa_group_rekey && auth_conf->wpa_group_rekey < MIN_GTK_REKEYING_INTERVAL) {
90+
auth_conf->wpa_group_rekey = MIN_GTK_REKEYING_INTERVAL;
91+
}
92+
#undef MIN_GTK_REKEYING_INTERVAL
8793

8894
authmode = esp_wifi_ap_get_prof_authmode_internal();
8995
if (authmode_has_wpa(authmode)) {

components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ esp_err_t esp_wifi_register_mgmt_frame_internal(uint32_t type, uint32_t subtype)
285285
esp_err_t esp_wifi_send_mgmt_frm_internal(const wifi_mgmt_frm_req_t *req);
286286
uint8_t esp_wifi_ap_get_prof_pairwise_cipher_internal(void);
287287
uint8_t esp_wifi_ap_get_sae_ext_config_internal(void);
288+
uint16_t esp_wifi_ap_get_gtk_rekeying_config_internal(void);
288289
bool esp_wifi_is_mbo_enabled_internal(uint8_t if_index);
289290
void esp_wifi_get_pmf_config_internal(wifi_pmf_config_t *pmf_cfg, uint8_t ifx);
290291
bool esp_wifi_is_ft_enabled_internal(uint8_t if_index);

components/wpa_supplicant/src/ap/wpa_auth.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
211211
int (*cb)(struct wpa_state_machine *sm, void *ctx),
212212
void *cb_ctx)
213213
{
214+
struct hostapd_data *hapd = hostapd_get_hapd_data();
215+
struct sta_info *sta;
216+
217+
if (hapd == NULL)
218+
return 1;
219+
220+
for (sta = hapd->sta_list; sta; sta = sta->next) {
221+
if (sta->wpa_sm && cb(sta->wpa_sm, cb_ctx))
222+
return 1;
223+
}
214224
return 0;
215225
}
216226

@@ -397,6 +407,11 @@ struct wpa_authenticator * wpa_init(const u8 *addr,
397407
return NULL;
398408
}
399409

410+
if (wpa_auth->conf.wpa_group_rekey) {
411+
eloop_register_timeout(wpa_auth->conf.wpa_group_rekey,
412+
0, wpa_rekey_gtk, wpa_auth, NULL);
413+
}
414+
400415
#ifdef CONFIG_IEEE80211R_AP
401416
wpa_auth->ft_pmk_cache = wpa_ft_pmk_cache_init();
402417
if (wpa_auth->ft_pmk_cache == NULL) {
@@ -2565,6 +2580,7 @@ static int wpa_sm_step(struct wpa_state_machine *sm)
25652580
void wpa_deinit(struct wpa_authenticator *wpa_auth)
25662581
{
25672582
struct wpa_group *group, *prev;
2583+
eloop_cancel_timeout(wpa_rekey_gtk, wpa_auth, NULL);
25682584
pmksa_cache_auth_deinit(wpa_auth->pmksa);
25692585
if (wpa_auth->wpa_ie != NULL) {
25702586
os_free(wpa_auth->wpa_ie);

examples/wifi/getting_started/softAP/main/Kconfig.projbuild

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@ menu "Example Configuration"
2323
default 4
2424
help
2525
Max number of the STA connects to AP.
26+
27+
config ESP_GTK_REKEYING_ENABLE
28+
bool "Enable GTK Rekeying"
29+
default y
30+
help
31+
Flag to enable GTK rekeying.
32+
33+
config ESP_GTK_REKEY_INTERVAL
34+
int "GTK rekey interval"
35+
depends on ESP_GTK_REKEYING_ENABLE
36+
range 60 65535
37+
default 600
38+
help
39+
GTK rekeying interval in seconds.
2640
endmenu

examples/wifi/getting_started/softAP/main/softap_example_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
#define EXAMPLE_ESP_WIFI_CHANNEL CONFIG_ESP_WIFI_CHANNEL
2929
#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN
3030

31+
#if CONFIG_ESP_GTK_REKEYING_ENABLE
32+
#define EXAMPLE_GTK_REKEY_INTERVAL CONFIG_ESP_GTK_REKEY_INTERVAL
33+
#else
34+
#define EXAMPLE_GTK_REKEY_INTERVAL 0
35+
#endif
36+
3137
static const char *TAG = "wifi softAP";
3238

3339
static void wifi_event_handler(void* arg, esp_event_base_t event_base,
@@ -81,6 +87,7 @@ void wifi_init_softap(void)
8187
.protected_keep_alive = 1,
8288
},
8389
#endif
90+
.gtk_rekey_interval = EXAMPLE_GTK_REKEY_INTERVAL,
8491
},
8592
};
8693
if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {

0 commit comments

Comments
 (0)