mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-16 18:30:16 +00:00
esp_wifi: WPA3-SAE support for softAP
This commit is contained in:

committed by
Jiang Jiang Jian

parent
ad19981af8
commit
2b8e40e760
@@ -12,6 +12,7 @@
|
||||
#include "crypto/sha1.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
#include "common/eapol_common.h"
|
||||
#include "common/sae.h"
|
||||
#include "ap/wpa_auth.h"
|
||||
#include "ap/ap_config.h"
|
||||
#include "utils/wpa_debug.h"
|
||||
@@ -144,10 +145,39 @@ static int hostapd_derive_psk(struct hostapd_ssid *ssid)
|
||||
}
|
||||
|
||||
|
||||
int hostapd_setup_sae_pt(struct hostapd_bss_config *conf)
|
||||
{
|
||||
#ifdef CONFIG_SAE
|
||||
struct hostapd_ssid *ssid = &conf->ssid;
|
||||
if ((conf->sae_pwe == SAE_PWE_HUNT_AND_PECK ||
|
||||
!wpa_key_mgmt_sae(conf->wpa_key_mgmt)))
|
||||
return 0; /* PT not needed */
|
||||
|
||||
sae_deinit_pt(ssid->pt);
|
||||
ssid->pt = NULL;
|
||||
if (ssid->wpa_passphrase) {
|
||||
ssid->pt = sae_derive_pt(conf->sae_groups, ssid->ssid,
|
||||
ssid->ssid_len,
|
||||
(const u8 *) ssid->wpa_passphrase,
|
||||
os_strlen(ssid->wpa_passphrase),
|
||||
NULL);
|
||||
if (!ssid->pt)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SAE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
|
||||
{
|
||||
struct hostapd_ssid *ssid = &conf->ssid;
|
||||
|
||||
if (hostapd_setup_sae_pt(conf) < 0)
|
||||
return -1;
|
||||
|
||||
if (ssid->wpa_passphrase != NULL) {
|
||||
if (ssid->wpa_psk != NULL) {
|
||||
wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK "
|
||||
@@ -245,3 +275,25 @@ const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l)
|
||||
{
|
||||
struct hostapd_wpa_psk *psk, *tmp;
|
||||
|
||||
for (psk = *l; psk;) {
|
||||
tmp = psk;
|
||||
psk = psk->next;
|
||||
bin_clear_free(tmp, sizeof(*tmp));
|
||||
}
|
||||
*l = NULL;
|
||||
}
|
||||
|
||||
void hostapd_config_free_bss(struct hostapd_bss_config *conf)
|
||||
{
|
||||
hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
|
||||
str_clear_free(conf->ssid.wpa_passphrase);
|
||||
#ifdef CONFIG_SAE
|
||||
sae_deinit_pt(conf->ssid.pt);
|
||||
#endif /* CONFIG_SAE */
|
||||
os_free(conf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user