mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13602 from balajicyp/topic/wep_security_fix
WEP Security fix for Cypress Target Kitspull/13545/head
commit
c4562be8d8
|
@ -234,7 +234,7 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
|
||||||
if ((ssid == NULL) ||
|
if ((ssid == NULL) ||
|
||||||
(strlen(ssid) == 0) ||
|
(strlen(ssid) == 0) ||
|
||||||
(pass == NULL && (security != NSAPI_SECURITY_NONE && security != NSAPI_SECURITY_WPA2_ENT)) ||
|
(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 ||
|
(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))
|
security == NSAPI_SECURITY_WPA_WPA2 || security == NSAPI_SECURITY_WPA3 || security == NSAPI_SECURITY_WPA3_WPA2))
|
||||||
) {
|
) {
|
||||||
|
@ -245,7 +245,7 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
|
||||||
strncpy(_ssid, ssid, sizeof(_ssid));
|
strncpy(_ssid, ssid, sizeof(_ssid));
|
||||||
|
|
||||||
memset(_pass, 0, sizeof(_pass));
|
memset(_pass, 0, sizeof(_pass));
|
||||||
strncpy(_pass, pass, sizeof(_pass));
|
memcpy(_pass, pass, sizeof(_pass));
|
||||||
|
|
||||||
_security = security;
|
_security = security;
|
||||||
|
|
||||||
|
@ -324,15 +324,29 @@ nsapi_error_t WhdSTAInterface::connect()
|
||||||
#endif
|
#endif
|
||||||
// join the network
|
// join the network
|
||||||
for (i = 0; i < MAX_RETRY_COUNT; i++) {
|
for (i = 0; i < MAX_RETRY_COUNT; i++) {
|
||||||
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
|
|
||||||
&ssid,
|
if (security != WHD_SECURITY_WEP_PSK)
|
||||||
security,
|
{
|
||||||
(const uint8_t *)_pass, strlen(_pass));
|
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
|
||||||
if (res == WHD_SUCCESS) {
|
&ssid,
|
||||||
break;
|
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) {
|
if (res != WHD_SUCCESS) {
|
||||||
return whd_toerror(res);
|
return whd_toerror(res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue