Skip to content

Commit 8b97e4c

Browse files
committed
Add WPA3 support for green tea tests
1 parent 5863415 commit 8b97e4c

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

TESTS/network/wifi/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The general test environment consists of DUTs, base stations, a network connecti
3737
- Time protocol, [RFC 868](https://tools.ietf.org/html/rfc868) in both TCP and UDP. Port 37.
3838
- Channels to be used must be different for both APs. For secure on channel number is later referred as `<ch:secure>` and for unsecure on `<ch:unsecure>`.
3939
- MAC addresses of Wi-Fi APs must be known. These are later referred to as `<mac:secure>` and `<mac:unsecure>`.
40+
- WPA3 may not be supported for all target platforms, Refer to target specifications before updating security protocol to WPA3 or WPA3/WPA2 in `mbed_app.json`
4041

4142
**NOTE:** This document refers to an echo server because it is a requirement for running Socket API tests. The test cases defined in this document do not directly use it.
4243

@@ -58,6 +59,8 @@ Please refer to the following table for priorities of test cases. Priorities are
5859
| | | NSAPI_SECURITY_WPA | SHOULD |
5960
| | | NSAPI_SECURITY_WPA2 | SHOULD |
6061
| | | NSAPI_SECURITY_WPA_WPA2 | MUST |
62+
| | | NSAPI_SECURITY_WPA3_WPA2 | SHOULD |
63+
| | | NSAPI_SECURITY_WPA3 | SHOULD |
6164
| 9 | WIFI_CONNECT_PARAMS_CHANNEL | | SHOULD |
6265
| 10 | WIFI_CONNECT_PARAMS_CHANNEL_FAIL | | SHOULD |
6366
| 11 | WIFI_CONNECT | | MUST |
@@ -67,6 +70,8 @@ Please refer to the following table for priorities of test cases. Priorities are
6770
| | | NSAPI_SECURITY_WPA | SHOULD |
6871
| | | NSAPI_SECURITY_WPA2 | SHOULD |
6972
| | | NSAPI_SECURITY_WPA_WPA2 | MUST |
73+
| | | NSAPI_SECURITY_WPA3_WPA2 | SHOULD |
74+
| | | NSAPI_SECURITY_WPA3 | SHOULD |
7075
| 14 | WIFI_CONNECT_SECURE_FAIL | | MUST |
7176
| 15 | WIFI_CONNECT_DISCONNECT_REPEAT | | MUST |
7277
| 16 | WIFI_SCAN_NULL | | SHOULD |
@@ -167,15 +172,19 @@ Call `set_credentials()` with various parameters described in "Expected results"
167172
|------------|---------------------------|----------------------------------|-----------------------------------------------------|
168173
| ssid=NULL | NULL | NSAPI_SECURITY_NONE | NSAPI_ERROR_PARAMETER |
169174
| ssid="OK" | NULL | NSAPI_SECURITY_WPA_WPA2 | NSAPI_ERROR_PARAMETER |
175+
| ssid="OK" | NULL | NSAPI_SECURITY_WPA3_WPA2 | NSAPI_ERROR_PARAMETER |
170176
| ssid="OK" | NULL | NSAPI_SECURITY_WEP | NSAPI_ERROR_PARAMETER because password is missing. |
171177
| ssid="OK" | NULL | NSAPI_SECURITY_NONE | NSAPI_ERROR_OK |
172178
| ssid="OK" | [any 64 character string] | NSAPI_SECURITY_WPA2 | NSAPI_ERROR_PARAMETER because password is too long |
173179
| ssid="OK" | [any 63 character string] | NSAPI_SECURITY_WPA2 | NSAPI_ERROR_OK |
174180
| ssid="OK" | "" | NSAPI_SECURITY_WPA_WPA2 | NSAPI_ERROR_PARAMETER |
181+
| ssid="OK" | "" | NSAPI_SECURITY_WPA3_WPA2 | NSAPI_ERROR_PARAMETER |
175182
| ssid="OK" | "" | NSAPI_SECURITY_WEP | NSAPI_ERROR_PARAMETER because password is missing. |
176183
| ssid="OK" | "" | NSAPI_SECURITY_NONE | NSAPI_ERROR_OK |
177184
| ssid="OK" | "12345678" | NSAPI_SECURITY_WPA_WPA2 | NSAPI_ERROR_OK |
185+
| ssid="OK" | "12345678" | NSAPI_SECURITY_WPA3_WPA2 | NSAPI_ERROR_OK |
178186
| ssid="OK" | "12345678" | NSAPI_SECURITY_WPA2 | NSAPI_ERROR_OK |
187+
| ssid="OK" | "12345678" | NSAPI_SECURITY_WPA3 | NSAPI_ERROR_OK |
179188
| ssid="OK" | "12345678" | NSAPI_SECURITY_WPA | NSAPI_ERROR_OK |
180189
| ssid="OK" | "12345678" | NSAPI_SECURITY_WEP | NSAPI_ERROR_OK or NSAPI_ERROR_UNSUPPORTED |
181190
| ssid="" | "" | NSAPI_SECURITY_NONE | NSAPI_ERROR_PARAMETER |

TESTS/network/wifi/get_security.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ nsapi_security get_security()
2626
static const char *SEC_WPA = "WPA";
2727
static const char *SEC_WPA2 = "WPA2";
2828
static const char *SEC_WPA_WPA2 = "WPA/WPA2";
29+
static const char *SEC_WPA3 = "WPA3";
30+
static const char *SEC_WPA3_WPA2 = "WPA3/WPA2";
2931

3032
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WEP) == 0) {
3133
return NSAPI_SECURITY_WEP;
@@ -39,6 +41,12 @@ nsapi_security get_security()
3941
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA_WPA2) == 0) {
4042
return NSAPI_SECURITY_WPA_WPA2;
4143
}
44+
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA3) == 0) {
45+
return NSAPI_SECURITY_WPA3;
46+
}
47+
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA3_WPA2) == 0) {
48+
return NSAPI_SECURITY_WPA3_WPA2;
49+
}
4250
#endif
4351
return NSAPI_SECURITY_NONE;
4452
}

TESTS/network/wifi/wifi_set_credential.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ void wifi_set_credential(void)
5252
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WPA_WPA2);
5353
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
5454

55+
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WPA3_WPA2);
56+
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
57+
58+
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WPA3_WPA2);
59+
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
60+
5561
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE);
5662
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
5763

@@ -64,9 +70,15 @@ void wifi_set_credential(void)
6470
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA2);
6571
TEST_ASSERT((error == NSAPI_ERROR_OK) || (error == NSAPI_ERROR_UNSUPPORTED));
6672

73+
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA3);
74+
TEST_ASSERT((error == NSAPI_ERROR_OK) || (error == NSAPI_ERROR_UNSUPPORTED));
75+
6776
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA_WPA2);
6877
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
6978

79+
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA3_WPA2);
80+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
81+
7082
error = iface->set_credentials("OK", "kUjd0PHHeAqaDoyfcDDEOvbyiVbYMpUHDukGoR6EJZnO5iLzWsfwiM9JQqOngni", get_security());
7183
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
7284

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ static nsapi_security_t whd_tosecurity(whd_security_t sec)
125125
case WHD_SECURITY_WPA2_FBT_PSK:
126126
case WHD_SECURITY_WPA2_FBT_ENT:
127127
return NSAPI_SECURITY_WPA2;
128+
case WHD_SECURITY_WPA3_SAE:
129+
return NSAPI_SECURITY_WPA3;
130+
case WHD_SECURITY_WPA3_WPA2_PSK:
131+
return NSAPI_SECURITY_WPA3_WPA2;
128132
default:
129133
return NSAPI_SECURITY_UNKNOWN;
130134
}
@@ -145,6 +149,10 @@ whd_security_t whd_fromsecurity(nsapi_security_t sec)
145149
return WHD_SECURITY_WPA2_MIXED_PSK;
146150
case NSAPI_SECURITY_WPA2_ENT:
147151
return WHD_SECURITY_WPA2_MIXED_ENT;
152+
case NSAPI_SECURITY_WPA3:
153+
return WHD_SECURITY_WPA3_SAE;
154+
case NSAPI_SECURITY_WPA3_WPA2:
155+
return WHD_SECURITY_WPA3_WPA2_PSK;
148156
default:
149157
return WHD_SECURITY_UNKNOWN;
150158
}
@@ -224,7 +232,8 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
224232
(strlen(ssid) == 0) ||
225233
(pass == NULL && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT)) ||
226234
(strlen(pass) == 0 && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT)) ||
227-
(strlen(pass) > 63 && (security == NSAPI_SECURITY_WPA2 || security == NSAPI_SECURITY_WPA || security == NSAPI_SECURITY_WPA_WPA2))
235+
(strlen(pass) > 63 && (security == NSAPI_SECURITY_WPA2 || security == NSAPI_SECURITY_WPA ||
236+
security == NSAPI_SECURITY_WPA_WPA2 || security == NSAPI_SECURITY_WPA3 || security == NSAPI_SECURITY_WPA3_WPA2))
228237
) {
229238
return NSAPI_ERROR_PARAMETER;
230239
}
@@ -292,6 +301,19 @@ nsapi_error_t WhdSTAInterface::connect()
292301
// choose network security
293302
whd_security_t security = whd_fromsecurity(_security);
294303

304+
#if defined MBED_CONF_APP_WIFI_PASSWORD_WPA2PSK
305+
/* Set PSK password for WPA3_WPA2 */
306+
if (security == WHD_SECURITY_WPA3_WPA2_PSK) {
307+
res = (whd_result_t)whd_wifi_enable_sup_set_passphrase( _whd_emac.ifp, (const uint8_t *)MBED_CONF_APP_WIFI_PASSWORD_WPA2PSK,
308+
strlen(MBED_CONF_APP_WIFI_PASSWORD_WPA2PSK), WHD_SECURITY_WPA3_WPA2_PSK );
309+
}
310+
#else
311+
/* Set PSK password for WPA3_WPA2 */
312+
if (security == WHD_SECURITY_WPA3_WPA2_PSK) {
313+
res = (whd_result_t)whd_wifi_enable_sup_set_passphrase( _whd_emac.ifp, (const uint8_t *)_pass,
314+
strlen(_pass), WHD_SECURITY_WPA3_WPA2_PSK );
315+
}
316+
#endif
295317
// join the network
296318
for (i = 0; i < MAX_RETRY_COUNT; i++) {
297319
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,

features/netsocket/nsapi_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ typedef enum nsapi_security {
128128
NSAPI_SECURITY_EAP_TLS = 0x7, /*!< phrase conforms to EAP-TLS */
129129
NSAPI_SECURITY_PEAP = 0x8, /*!< phrase conforms to PEAP */
130130
NSAPI_SECURITY_WPA2_ENT = 0x9, /*!< phrase conforms to WPA2-AES and WPA-TKIP with enterprise security */
131+
NSAPI_SECURITY_WPA3 = 0xA, /*!< phrase conforms to WPA3 */
132+
NSAPI_SECURITY_WPA3_WPA2 = 0xB, /*!< phrase conforms to WPA3_WPA2 */
131133
NSAPI_SECURITY_UNKNOWN = 0xFF, /*!< unknown/unsupported security in scan results */
132134
} nsapi_security_t;
133135

0 commit comments

Comments
 (0)