static BOOL iwprivSetPsk(void) { if ( iwprivCb.securityType != WF_SECURITY_WPA_AUTO_WITH_KEY ) { WFConsolePrintRomStr("WPA-PSK encryption mode is not selected", TRUE); return FALSE; } if (ARGC < 3u) { WFConsolePrintRomStr("Missing value for last parameter", TRUE); return FALSE; } if ( convertAsciiToHexInPlace(ARGV[2], WF_WPA_KEY_LENGTH) ) { memcpy((void*)iwprivCb.securityKey, (const void*)ARGV[2], WF_WPA_KEY_LENGTH); iwprivCb.securityKeyLength = WF_WPA_KEY_LENGTH; } else { WFConsolePrintRomStr("WPA PSK must be exactly 32 bytes", TRUE); return FALSE; } WF_CPSetSecurity(iwprivCb.cpId, iwprivCb.securityType, 0, iwprivCb.securityKey, iwprivCb.securityKeyLength); return TRUE; }
/***************************************************************************** * FUNCTION: iwprivSetPsk * * RETURNS: true or false * * PARAMS: none * * NOTES: Set PSK key * Valid key length: * The PSK is 32 bytes (256 bits), * often displayed as 64 hexadecimal characters. *****************************************************************************/ static bool iwprivSetPsk(void) { if ( iwprivCb.securityType != WF_SECURITY_WPA_AUTO_WITH_KEY ) { WFConsolePrintRomStr("WPA-PSK encryption mode is not selected", true); return false; } if (ARGC < 3u) { WFConsolePrintRomStr("Missing value for last parameter", true); return false; } if ( convertAsciiToHexInPlace(ARGV[2], WF_WPA_KEY_LENGTH) ) { memcpy((void*)iwprivCb.securityKey, (const void *)ARGV[2], WF_WPA_KEY_LENGTH); iwprivCb.securityKeyLength = WF_WPA_KEY_LENGTH; } else { WFConsolePrintRomStr("WPA-PSK Key length must be exactly 32 bytes long. It is often displayed as 64 hex characters.", true); return false; } WF_CPSetSecurity(iwprivCb.cpId, iwprivCb.securityType, 0, iwprivCb.securityKey, iwprivCb.securityKeyLength); return true; }
static BOOL iwprivSetKey(void) { UINT8 webKey; if (iwprivCb.securityType != WF_SECURITY_WEP_40 && iwprivCb.securityType != WF_SECURITY_WEP_104) { WFConsolePrintRomStr("WEP encryption mode is not selected", TRUE); return FALSE; } if (ARGC < 3u) { WFConsolePrintRomStr("Missing value for last parameter", TRUE); return FALSE; } if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "[1]") == 0) ) { webKey = 0u; } else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "[2]") == 0) ) { webKey = 1u; } else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "[3]") == 0) ) { webKey = 2u; } else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "[4]") == 0) ) { webKey = 3u; } else { WFConsolePrintRomStr("Invalid WEP key index", TRUE); return FALSE; } if (4u <= ARGC) { if ( convertAsciiToHexInPlace(ARGV[3], IWPRIV_WEB_LONG_KEY_LEN) ) // for long web key { iwprivCb.securityType = WF_SECURITY_WEP_104; memcpy((void*)(iwprivCb.securityKey + webKey * IWPRIV_WEB_LONG_KEY_LEN), (const void*)ARGV[3], IWPRIV_WEB_LONG_KEY_LEN); iwprivCb.securityKeyLength = IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_LONG_KEY_LEN; WF_CPSetSecurity(iwprivCb.cpId, iwprivCb.securityType, webKey, iwprivCb.securityKey + webKey * IWPRIV_WEB_LONG_KEY_LEN, IWPRIV_WEB_LONG_KEY_LEN); } else if ( convertAsciiToHexInPlace(ARGV[3], IWPRIV_WEB_SHORT_KEY_LEN) ) // for short web key { iwprivCb.securityType = WF_SECURITY_WEP_40; memcpy((void*)(iwprivCb.securityKey + webKey * IWPRIV_WEB_SHORT_KEY_LEN), (const void*)ARGV[3], IWPRIV_WEB_SHORT_KEY_LEN); iwprivCb.securityKeyLength = IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_SHORT_KEY_LEN; WF_CPSetSecurity(iwprivCb.cpId, iwprivCb.securityType, webKey, iwprivCb.securityKey + webKey * IWPRIV_WEB_SHORT_KEY_LEN, IWPRIV_WEB_SHORT_KEY_LEN); } else { WFConsolePrintRomStr("64/128bit WEP key format not valid", TRUE); return FALSE; } } else // ARGC == 3u { WF_CPSetDefaultWepKeyIndex(iwprivCb.cpId, webKey); } return TRUE; }