Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEP Security fix for Cypress Target Kits #13602

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
if ((ssid == NULL) ||
(strlen(ssid) == 0) ||
(pass == NULL && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT)) ||
(strlen(pass) == 0 && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT)) ||
(strlen(pass) == 0 && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT && security != NSAPI_SECURITY_WEP)) ||
(strlen(pass) > 63 && (security == NSAPI_SECURITY_WPA2 || security == NSAPI_SECURITY_WPA ||
security == NSAPI_SECURITY_WPA_WPA2 || security == NSAPI_SECURITY_WPA3 || security == NSAPI_SECURITY_WPA3_WPA2))
) {
Expand All @@ -245,7 +245,7 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
strncpy(_ssid, ssid, sizeof(_ssid));

memset(_pass, 0, sizeof(_pass));
strncpy(_pass, pass, sizeof(_pass));
memcpy(_pass, pass, sizeof(_pass));

_security = security;

Expand Down Expand Up @@ -324,15 +324,29 @@ nsapi_error_t WhdSTAInterface::connect()
#endif
// join the network
for (i = 0; i < MAX_RETRY_COUNT; i++) {
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
&ssid,
security,
(const uint8_t *)_pass, strlen(_pass));
if (res == WHD_SUCCESS) {
break;

if (security != WHD_SECURITY_WEP_PSK)
{
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
&ssid,
security,
(const uint8_t *)_pass, strlen(_pass));
}
else
{
uint8_t key_length = 0;

/* key_length = (index field + length field + _pass[1] ( length ) ) * 4 ( for key index 0, 1, 2, 3) */
key_length = (_pass[1] + 2 )* 4;
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
&ssid,
security,
(const uint8_t *)_pass, key_length);
}
if (res == WHD_SUCCESS) {
break;
}
}

if (res != WHD_SUCCESS) {
return whd_toerror(res);
}
Expand Down