feat(esp_wifi): Add improvements for privacy extension

1) Add support for MAC randomization in Active scan and connect
  2) Add support for randomizaton of sequence numbers
  3) Add support for randomization of dialog token for GAS frames
This commit is contained in:
Aditi
2026-05-25 11:22:45 +08:00
committed by BOT
parent 3bf83125b4
commit 18cbdbf2b1
15 changed files with 130 additions and 15 deletions
+15
View File
@@ -925,6 +925,21 @@ menu "Wi-Fi"
Select this option to enable/disable support for station connections
to hidden APs using passive scan when the country policy is set to auto.
config ESP_WIFI_STA_RANDOM_MAC_ENABLED
bool "Station Mac-Randomization enabled"
default y
help
Select this option to enable Mac Randomization for Station
config ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL
int "Station Mac-Randomization Auto-Reset Interval time"
depends on ESP_WIFI_STA_RANDOM_MAC_ENABLED
range 1 24
default 12
help
Interval in hours to rotate the STA random MAC while not connected to an AP.
Values below 1 or above 24 are not allowed.
endif # wifi enabled
endmenu # Wi-Fi
+4
View File
@@ -120,6 +120,8 @@ typedef struct {
int espnow_max_encrypt_num; /**< Maximum encrypt number of peers supported by espnow */
int tx_hetb_queue_num; /**< WiFi TX HE TB QUEUE number for STA HE TB PPDU transmission */
bool dump_hesigb_enable; /**< enable dump sigb field */
bool sta_random_mac; /**< STA MAC randomization. Supported on station interface only; softAP may be added in future */
uint8_t sta_rmac_auto_reset_int;/**< STA random MAC auto-reset interval in hours (1-24) while not connected */
int magic; /**< WiFi init magic number, it should be the last field */
} wifi_init_config_t;
@@ -347,6 +349,8 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs;
.espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, \
.tx_hetb_queue_num = WIFI_TX_HETB_QUEUE_NUM, \
.dump_hesigb_enable = WIFI_DUMP_HESIGB_ENABLED, \
.sta_random_mac = CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED, \
.sta_rmac_auto_reset_int = CONFIG_ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL, \
.magic = WIFI_INIT_CONFIG_MAGIC\
}
@@ -904,6 +904,21 @@ config WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT
Select this option to enable/disable support for station connections
to hidden APs using passive scan when the country policy is set to auto.
config WIFI_RMT_STA_RANDOM_MAC_ENABLED
bool "Station Mac-Randomization enabled"
default y
help
Select this option to enable Mac Randomization for Station
config WIFI_RMT_STA_RANDOM_MAC_AUTO_RESET_INTERVAL
int "Station Mac-Randomization Auto-Reset Interval time"
depends on WIFI_RMT_STA_RANDOM_MAC_ENABLED
range 1 24
default 12
help
Interval in hours to rotate the STA random MAC while not connected to an AP.
Values below 1 or above 24 are not allowed.
if !ESP_WIFI_ENABLED
rsource "Kconfig.wifi_is_remote.in"
endif # ESP_WIFI_ENABLED
@@ -512,3 +512,14 @@ if WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT
bool
default WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT
endif
if WIFI_RMT_STA_RANDOM_MAC_ENABLED
config ESP_WIFI_STA_RANDOM_MAC_ENABLED # ignore: multiple-definition
bool
default WIFI_RMT_STA_RANDOM_MAC_ENABLED
endif
config ESP_WIFI_STA_RANDOM_MAC_AUTO_RESET_INTERVAL # ignore: multiple-definition
int
depends on WIFI_RMT_STA_RANDOM_MAC_ENABLED
default WIFI_RMT_STA_RANDOM_MAC_AUTO_RESET_INTERVAL
@@ -120,6 +120,8 @@ typedef struct {
int espnow_max_encrypt_num; /**< Maximum encrypt number of peers supported by espnow */
int tx_hetb_queue_num; /**< WiFi TX HE TB QUEUE number for STA HE TB PPDU transmission */
bool dump_hesigb_enable; /**< enable dump sigb field */
bool sta_random_mac; /**< STA MAC randomization. Supported on station interface only; softAP may be added in future */
uint8_t sta_rmac_auto_reset_int;/**< STA random MAC auto-reset interval in hours (1-24) while not connected */
int magic; /**< WiFi init magic number, it should be the last field */
} wifi_init_config_t;
@@ -347,6 +349,8 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs;
.espnow_max_encrypt_num = CONFIG_WIFI_RMT_ESPNOW_MAX_ENCRYPT_NUM, \
.tx_hetb_queue_num = WIFI_TX_HETB_QUEUE_NUM, \
.dump_hesigb_enable = WIFI_DUMP_HESIGB_ENABLED, \
.sta_random_mac = CONFIG_WIFI_RMT_STA_RANDOM_MAC_ENABLED, \
.sta_rmac_auto_reset_int = CONFIG_WIFI_RMT_STA_RANDOM_MAC_AUTO_RESET_INTERVAL, \
.magic = WIFI_INIT_CONFIG_MAGIC\
}
+7
View File
@@ -119,6 +119,13 @@ static void wifi_default_action_sta_connected(void *arg, esp_event_base_t base,
}
}
#if CONFIG_ESP_WIFI_STA_RANDOM_MAC_ENABLED
/* Sync netif MAC when STA random MAC was set internally by the Wi-Fi driver */
uint8_t mac[6];
esp_wifi_get_mac(WIFI_IF_STA, mac);
esp_netif_set_mac(esp_netif, mac);
#endif
esp_netif_action_connected(s_wifi_netifs[WIFI_IF_STA], base, event_id, data);
}
}