Skip to content

Commit 92dd07e

Browse files
gangli02kartben
authored andcommitted
drivers: wifi: nxp: add WPA2-PSK-SHA256 support for l2
Add WPA2-PSK-SHA256 security type support for embedded supplicant. Convert wifi key_mgmt to zephyr security type. Signed-off-by: Gang Li <[email protected]>
1 parent 907d3b7 commit 92dd07e

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

drivers/wifi/nxp/nxp_wifi_drv.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ static int nxp_wifi_start_ap(const struct device *dev, struct wifi_connect_req_p
506506
nxp_wlan_uap_network.security.type = WLAN_SECURITY_WPA2;
507507
nxp_wlan_uap_network.security.psk_len = params->psk_length;
508508
strncpy(nxp_wlan_uap_network.security.psk, params->psk, params->psk_length);
509+
} else if (params->security == WIFI_SECURITY_TYPE_PSK_SHA256) {
510+
nxp_wlan_uap_network.security.type = WLAN_SECURITY_WPA2;
511+
nxp_wlan_uap_network.security.key_mgmt = WLAN_KEY_MGMT_PSK_SHA256;
512+
nxp_wlan_uap_network.security.psk_len = params->psk_length;
513+
strncpy(nxp_wlan_uap_network.security.psk, params->psk, params->psk_length);
509514
} else if (params->security == WIFI_SECURITY_TYPE_SAE) {
510515
nxp_wlan_uap_network.security.type = WLAN_SECURITY_WPA3_SAE;
511516
nxp_wlan_uap_network.security.password_len = params->psk_length;
@@ -702,11 +707,9 @@ static int nxp_wifi_process_results(unsigned int count)
702707
if (scan_result.wpa2) {
703708
res.security = WIFI_SECURITY_TYPE_PSK;
704709
}
705-
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT
706710
if (scan_result.wpa2_sha256) {
707711
res.security = WIFI_SECURITY_TYPE_PSK_SHA256;
708712
}
709-
#endif
710713
if (scan_result.wpa3_sae) {
711714
res.security = WIFI_SECURITY_TYPE_SAE;
712715
}
@@ -923,6 +926,11 @@ static int nxp_wifi_connect(const struct device *dev, struct wifi_connect_req_pa
923926
nxp_wlan_network.security.type = WLAN_SECURITY_WPA2;
924927
nxp_wlan_network.security.psk_len = params->psk_length;
925928
strncpy(nxp_wlan_network.security.psk, params->psk, params->psk_length);
929+
} else if (params->security == WIFI_SECURITY_TYPE_PSK_SHA256) {
930+
nxp_wlan_network.security.type = WLAN_SECURITY_WPA2;
931+
nxp_wlan_network.security.key_mgmt = WLAN_KEY_MGMT_PSK_SHA256;
932+
nxp_wlan_network.security.psk_len = params->psk_length;
933+
strncpy(nxp_wlan_network.security.psk, params->psk, params->psk_length);
926934
} else if (params->security == WIFI_SECURITY_TYPE_SAE) {
927935
nxp_wlan_network.security.type = WLAN_SECURITY_WPA3_SAE;
928936
nxp_wlan_network.security.password_len = params->psk_length;
@@ -1011,15 +1019,26 @@ static int nxp_wifi_disconnect(const struct device *dev)
10111019
return 0;
10121020
}
10131021

1014-
static inline enum wifi_security_type nxp_wifi_security_type(enum wlan_security_type type)
1022+
static inline enum wifi_security_type nxp_wifi_key_mgmt_to_zephyr(int key_mgmt, int pwe)
10151023
{
1016-
switch (type) {
1017-
case WLAN_SECURITY_NONE:
1024+
switch (key_mgmt) {
1025+
case WLAN_KEY_MGMT_NONE:
10181026
return WIFI_SECURITY_TYPE_NONE;
1019-
case WLAN_SECURITY_WPA2:
1027+
case WLAN_KEY_MGMT_PSK:
10201028
return WIFI_SECURITY_TYPE_PSK;
1021-
case WLAN_SECURITY_WPA3_SAE:
1029+
case WLAN_KEY_MGMT_PSK_SHA256:
1030+
return WIFI_SECURITY_TYPE_PSK_SHA256;
1031+
case WLAN_KEY_MGMT_SAE:
1032+
if (pwe == 1) {
1033+
return WIFI_SECURITY_TYPE_SAE_H2E;
1034+
} else if (pwe == 2) {
1035+
return WIFI_SECURITY_TYPE_SAE_AUTO;
1036+
} else {
1037+
return WIFI_SECURITY_TYPE_SAE_HNP;
1038+
}
10221039
return WIFI_SECURITY_TYPE_SAE;
1040+
case WLAN_KEY_MGMT_SAE | WLAN_KEY_MGMT_PSK:
1041+
return WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL;
10231042
default:
10241043
return WIFI_SECURITY_TYPE_UNKNOWN;
10251044
}
@@ -1086,8 +1105,9 @@ static int nxp_wifi_uap_status(const struct device *dev, struct wifi_iface_statu
10861105

10871106
status->band = nxp_wlan_uap_network.channel > 14 ? WIFI_FREQ_BAND_5_GHZ
10881107
: WIFI_FREQ_BAND_2_4_GHZ;
1089-
status->security =
1090-
nxp_wifi_security_type(nxp_wlan_uap_network.security.type);
1108+
status->security = nxp_wifi_key_mgmt_to_zephyr(
1109+
nxp_wlan_uap_network.security.key_mgmt,
1110+
nxp_wlan_uap_network.security.pwe_derivation);
10911111
status->mfp =
10921112
nxp_wlan_uap_network.security.mfpr
10931113
? WIFI_MFP_REQUIRED
@@ -1167,7 +1187,9 @@ static int nxp_wifi_status(const struct device *dev, struct wifi_iface_status *s
11671187

11681188
status->band = nxp_wlan_network.channel > 14 ? WIFI_FREQ_BAND_5_GHZ
11691189
: WIFI_FREQ_BAND_2_4_GHZ;
1170-
status->security = nxp_wifi_security_type(nxp_wlan_network.security.type);
1190+
status->security = nxp_wifi_key_mgmt_to_zephyr(
1191+
nxp_wlan_network.security.key_mgmt,
1192+
nxp_wlan_network.security.pwe_derivation);
11711193
status->mfp = nxp_wlan_network.security.mfpr ? WIFI_MFP_REQUIRED :
11721194
(nxp_wlan_network.security.mfpc ? WIFI_MFP_OPTIONAL : 0);
11731195
}

0 commit comments

Comments
 (0)