PageRenderTime 62ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/net/wireless/tiwlan1251/common/src/core/rsn/rsn.c

http://github.com/CyanogenMod/cm-kernel
C | 2166 lines | 1201 code | 352 blank | 613 comment | 219 complexity | 86df6769104261fb9dcfd337370d01c5 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. /** \file rsn.c
  36. * \brief 802.11 rsniation SM source
  37. *
  38. * \see rsnSM.h
  39. */
  40. #include "osApi.h"
  41. #include "paramOut.h"
  42. #include "paramIn.h"
  43. #include "utils.h"
  44. #include "report.h"
  45. #include "Ethernet.h"
  46. #include "whalCtrl_api.h"
  47. #include "whalCtrl_prm.h"
  48. #include "DataCtrl_Api.h"
  49. #include "memMngrEx.h"
  50. #include "siteMgrApi.h"
  51. #include "smeApi.h"
  52. #include "mainSecSm.h"
  53. #include "admCtrl.h"
  54. #include "rsnApi.h"
  55. #include "rsn.h"
  56. #include "keyParser.h"
  57. #include "EvHandler.h"
  58. #include "TI_IPC_Api.h"
  59. #include "smeSmApi.h"
  60. #include "apConn.h"
  61. #include "802_11Defs.h"
  62. #include "public_infoele.h"
  63. #ifdef EXC_MODULE_INCLUDED
  64. #include "admCtrlWpa.h"
  65. #include "excMngr.h"
  66. #include "admCtrlExc.h"
  67. #endif
  68. /* Constants */
  69. /* Enumerations */
  70. /* Typedefs */
  71. /* Structures */
  72. /* External data definitions */
  73. /* External functions definitions */
  74. /* Global variables */
  75. /* Local function prototypes */
  76. TI_STATUS rsn_sendKeysNotSet(rsn_t *pRsn);
  77. void rsn_groupReKeyTimeout(TI_HANDLE hRsn);
  78. void rsn_micFailureReportTimeout(TI_HANDLE hRsn);
  79. static rsn_siteBanEntry_t * findEntryForInsert(TI_HANDLE hRsn);
  80. static rsn_siteBanEntry_t * findBannedSiteAndCleanup(TI_HANDLE hRsn, macAddress_t siteBssid);
  81. /* Comment out the call to clearBannedSiteList due to fail in WiFi mic attack test */
  82. /*static void clearBannedSiteList(TI_HANDLE hRsn);*/
  83. /* functions */
  84. /**
  85. *
  86. * rsn_Create - allocate memory for rsniation SM
  87. *
  88. * \b Description:
  89. *
  90. * Allocate memory for rsniation SM. \n
  91. * Allocates memory for Rsniation context. \n
  92. * Allocates memory for rsniation timer. \n
  93. * Allocates memory for rsniation SM matrix. \n
  94. *
  95. * \b ARGS:
  96. *
  97. * I - hOs - OS context \n
  98. *
  99. * \b RETURNS:
  100. *
  101. * OK if successful, NOK otherwise.
  102. *
  103. * \sa rsn_mainSecKeysOnlyStop()
  104. */
  105. TI_HANDLE rsn_create(TI_HANDLE hOs)
  106. {
  107. rsn_t *pRsn;
  108. /* allocate rsniation context memory */
  109. pRsn = (rsn_t*)os_memoryAlloc (hOs, sizeof(rsn_t));
  110. if (pRsn == NULL)
  111. {
  112. return NULL;
  113. }
  114. os_memoryZero (hOs, pRsn, sizeof(rsn_t));
  115. /* create admission control */
  116. pRsn->pAdmCtrl = admCtrl_create (hOs);
  117. if (pRsn->pAdmCtrl == NULL)
  118. {
  119. os_memoryFree (hOs, pRsn, sizeof(rsn_t));
  120. return NULL;
  121. }
  122. /* create main security SM */
  123. pRsn->pMainSecSm = mainSec_create (hOs);
  124. if (pRsn->pMainSecSm == NULL)
  125. {
  126. admCtrl_unload (pRsn->pAdmCtrl);
  127. os_memoryFree (hOs, pRsn, sizeof(rsn_t));
  128. return NULL;
  129. }
  130. pRsn->pKeyParser = pRsn->pMainSecSm->pKeyParser;
  131. pRsn->micFailureReportWaitTimer = os_timerCreate (hOs, rsn_micFailureReportTimeout, pRsn);
  132. if (pRsn->micFailureReportWaitTimer == NULL)
  133. {
  134. mainSec_unload (pRsn->pMainSecSm);
  135. admCtrl_unload (pRsn->pAdmCtrl);
  136. os_memoryFree (hOs, pRsn, sizeof(rsn_t));
  137. return NULL;
  138. }
  139. pRsn->micFailureReKeyTimer = os_timerCreate (hOs, rsn_groupReKeyTimeout, pRsn);
  140. if (pRsn->micFailureReKeyTimer == NULL)
  141. {
  142. os_timerDestroy (hOs, pRsn->micFailureReportWaitTimer);
  143. mainSec_unload (pRsn->pMainSecSm);
  144. admCtrl_unload (pRsn->pAdmCtrl);
  145. os_memoryFree (hOs, pRsn, sizeof(rsn_t));
  146. return NULL;
  147. }
  148. pRsn->hOs = hOs;
  149. return pRsn;
  150. }
  151. /**
  152. *
  153. * rsn_Unload - unload rsniation SM from memory
  154. *
  155. * \b Description:
  156. *
  157. * Unload rsniation SM from memory
  158. *
  159. * \b ARGS:
  160. *
  161. * I - hRsn - rsniation SM context \n
  162. *
  163. * \b RETURNS:
  164. *
  165. * OK if successful, NOK otherwise.
  166. *
  167. * \sa rsn_mainSecKeysOnlyStop()
  168. */
  169. TI_STATUS rsn_unload (TI_HANDLE hRsn)
  170. {
  171. rsn_t *pRsn;
  172. TI_STATUS status;
  173. if (hRsn == NULL)
  174. {
  175. return NOK;
  176. }
  177. pRsn = (rsn_t*)hRsn;
  178. os_timerStop (pRsn->hOs, pRsn->micFailureReportWaitTimer);
  179. os_timerDestroy (pRsn->hOs, pRsn->micFailureReportWaitTimer);
  180. os_timerStop (pRsn->hOs, pRsn->micFailureReKeyTimer);
  181. os_timerDestroy (pRsn->hOs, pRsn->micFailureReKeyTimer);
  182. status = admCtrl_unload (pRsn->pAdmCtrl);
  183. status = mainSec_unload (pRsn->pMainSecSm);
  184. os_memoryFree (pRsn->hOs, hRsn, sizeof(rsn_t));
  185. return status;
  186. }
  187. /**
  188. *
  189. * rsn_smConfig - configure a new rsniation SM
  190. *
  191. * \b Description:
  192. *
  193. * Configure a new rsniation SM.
  194. *
  195. * \b ARGS:
  196. *
  197. * I - hRsn - Rsniation SM context \n
  198. * I - hMlme - MLME SM context \n
  199. * I - hSiteMgr - Site manager context \n
  200. * I - hCtrlData - Control data context \n
  201. * I - hTxData - TX data context \n
  202. * I - hHalCtrl - Hal control context \n
  203. * I - hReport - Report context \n
  204. * I - hOs - OS context \n
  205. * I - rsnTimeout - Rsniation SM timeout \n
  206. * I - rsnMaxCount - Max number of rsniation requests to send \n
  207. *
  208. * \b RETURNS:
  209. *
  210. * OK if successful, NOK otherwise.
  211. *
  212. * \sa rsn_Create, rsn_Unload
  213. */
  214. TI_STATUS rsn_config (TI_HANDLE hRsn,
  215. TI_HANDLE hTx,
  216. TI_HANDLE hRx,
  217. TI_HANDLE hConn,
  218. TI_HANDLE hMlme,
  219. TI_HANDLE hCtrlData,
  220. TI_HANDLE hWhalCtrl,
  221. TI_HANDLE hMemMgr,
  222. TI_HANDLE hSiteMgr,
  223. TI_HANDLE hReport,
  224. TI_HANDLE hOs,
  225. TI_HANDLE hExcMngr,
  226. TI_HANDLE hPowerMgr,
  227. TI_HANDLE hEvHandler,
  228. TI_HANDLE hSmeSm,
  229. TI_HANDLE hAPConn,
  230. rsnInitParams_t *pInitParam)
  231. {
  232. rsn_t *pRsn;
  233. TI_STATUS status;
  234. UINT8 keyIndex;
  235. if (hRsn == NULL)
  236. {
  237. return NOK;
  238. }
  239. pRsn = (rsn_t*)hRsn;
  240. pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_FALSE;
  241. pRsn->PrivacyOptionImplemented = TRUE;
  242. pRsn->hTx = hTx;
  243. pRsn->hRx = hRx;
  244. pRsn->hConn = hConn;
  245. pRsn->hWhalCtrl = hWhalCtrl;
  246. pRsn->hCtrlData = hCtrlData;
  247. pRsn->hMemMgr = hMemMgr;
  248. pRsn->hSiteMgr= hSiteMgr;
  249. pRsn->hReport = hReport;
  250. pRsn->hOs = hOs;
  251. pRsn->hExcMngr = hExcMngr;
  252. pRsn->hEvHandler = hEvHandler;
  253. pRsn->hSmeSm = hSmeSm;
  254. pRsn->hAPConn = hAPConn;
  255. pRsn->setPaeConfig = rsn_setPaeConfig;
  256. pRsn->getNetworkMode = rsn_getNetworkMode;
  257. pRsn->setKey = rsn_setKey;
  258. pRsn->removeKey = rsn_removeKey;
  259. pRsn->reportStatus = rsn_reportStatus;
  260. pRsn->setDefaultKeyId = rsn_setDefaultKeyId;
  261. pRsn->defaultKeysOn = TRUE;
  262. pRsn->eapType = OS_EAP_TYPE_NONE;
  263. pRsn->numOfBannedSites = 0;
  264. /* config the admission control with the authentication suite selected.
  265. Admission control will configure the main security SM. */
  266. status = admCtrl_config (pRsn->pAdmCtrl, hMlme, hRx, hReport, hOs, pRsn, hExcMngr, hPowerMgr, hEvHandler, pInitParam);
  267. if (status != OK)
  268. {
  269. return status;
  270. }
  271. /* Configure keys from registry */
  272. if (pInitParam->privacyOn)
  273. {
  274. pRsn->wepStaticKey = TRUE;
  275. }
  276. pRsn->defaultKeyId = pInitParam->defaultKeyId;
  277. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  278. {
  279. os_memoryCopy (hOs, &pRsn->keys[keyIndex], &pInitParam->keys[keyIndex], sizeof(securityKeys_t));
  280. if (pRsn->keys[keyIndex].keyType != NULL_KEY)
  281. {
  282. pRsn->wepDefaultKeys[keyIndex] = TRUE;
  283. }
  284. pRsn->keys_en [keyIndex] = FALSE;
  285. }
  286. return status;
  287. }
  288. /**
  289. *
  290. * rsn_reconfig - re-configure a rsniation
  291. *
  292. * \b Description:
  293. *
  294. * Re-configure rsniation
  295. *
  296. * \b ARGS:
  297. *
  298. * I - hRsn - Rsniation SM context \n
  299. *
  300. * \b RETURNS:
  301. *
  302. * OK if successful, NOK otherwise.
  303. *
  304. * \sa rsn_Create, rsn_Unload
  305. */
  306. TI_STATUS rsn_reconfig (TI_HANDLE hRsn)
  307. {
  308. rsn_t *pRsn = (rsn_t *)hRsn;
  309. UINT8 keyIndex;
  310. /* Mark all keys as removed */
  311. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  312. pRsn->keys_en [keyIndex] = FALSE;
  313. return OK;
  314. }
  315. /**
  316. *
  317. * rsn_setDefaultKeys -
  318. *
  319. * \b Description:
  320. *
  321. *
  322. *
  323. * \b ARGS:
  324. *
  325. * I - hRsn - Rsn SM context \n
  326. *
  327. * \b RETURNS:
  328. *
  329. * OK if successful, NOK otherwise.
  330. *
  331. * \sa rsn_Stop, rsn_Recv
  332. */
  333. TI_STATUS rsn_setDefaultKeys(rsn_t *pRsn)
  334. {
  335. TI_STATUS status = OK;
  336. whalParamInfo_t whalParam;
  337. UINT8 keyIndex;
  338. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  339. {
  340. /* Set the WEP key to the HAL */
  341. if (pRsn->wepDefaultKeys[keyIndex] /*pRsn->keys[keyIndex].encLen>0*/)
  342. {
  343. /* Change key type to WEP-key before setting*/
  344. pRsn->keys[keyIndex].keyType = WEP_KEY;
  345. status = pRsn->pMainSecSm->setKey (pRsn->pMainSecSm, &pRsn->keys[keyIndex]);
  346. if (status != OK)
  347. {
  348. WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG,
  349. ("RSN: Setting key #%d failed \n", keyIndex));
  350. return status;
  351. }
  352. }
  353. }
  354. /* Now we configure default key ID to the HAL */
  355. if (pRsn->defaultKeyId < MAX_KEYS_NUM)
  356. {
  357. whalParam.paramType = HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM;
  358. whalParam.content.configureCmdCBParams.CB_buf = &pRsn->defaultKeyId;
  359. whalParam.content.configureCmdCBParams.CB_Func = NULL;
  360. whalParam.content.configureCmdCBParams.CB_handle = NULL;
  361. status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
  362. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  363. ("RSN: default key ID =%d \n", pRsn->defaultKeyId));
  364. }
  365. return status;
  366. }
  367. /**
  368. *
  369. * rsn_Start - Start event for the rsniation SM
  370. *
  371. * \b Description:
  372. *
  373. * Start event for the rsniation SM
  374. *
  375. * \b ARGS:
  376. *
  377. * I - hRsn - Rsniation SM context \n
  378. *
  379. * \b RETURNS:
  380. *
  381. * OK if successful, NOK otherwise.
  382. *
  383. * \sa rsn_Stop, rsn_Recv
  384. */
  385. TI_STATUS rsn_start(TI_HANDLE hRsn)
  386. {
  387. TI_STATUS status;
  388. rsn_t *pRsn;
  389. cipherSuite_e suite;
  390. externalAuthMode_e extAuthMode;
  391. whalParamInfo_t whalParam;
  392. pRsn = (rsn_t*)hRsn;
  393. if (pRsn == NULL)
  394. {
  395. return NOK;
  396. }
  397. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_start ...\n"));
  398. pRsn->rsnStartedTs = os_timeStampMs (pRsn->hOs);
  399. status = pRsn->pMainSecSm->start (pRsn->pMainSecSm);
  400. /* Set keys that need to be set */
  401. pRsn->defaultKeysOn = FALSE;
  402. pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &suite);
  403. pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
  404. if (pRsn->wepStaticKey && ((suite == RSN_CIPHER_WEP) || (suite == RSN_CIPHER_CKIP)))
  405. { /* set default WEP keys */
  406. status = rsn_sendKeysNotSet (pRsn);
  407. pRsn->eapType = OS_EAP_TYPE_NONE;
  408. }
  409. else if (suite == RSN_CIPHER_NONE && extAuthMode != RSN_EXT_AUTH_MODE_OPEN)
  410. { /* remove previously WEP key for SHARED */
  411. pRsn->wepStaticKey = FALSE;
  412. status = rsn_removedDefKeys (pRsn);
  413. /* Set None to HAL */
  414. whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
  415. whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_NONE;
  416. status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
  417. }
  418. else if (suite==RSN_CIPHER_NONE)
  419. {
  420. pRsn->eapType = OS_EAP_TYPE_NONE;
  421. }
  422. return status;
  423. }
  424. TI_STATUS rsn_sendKeysNotSet(rsn_t *pRsn)
  425. {
  426. UINT8 keyIndex;
  427. OS_802_11_KEY rsnOsKey;
  428. TI_STATUS status = OK;
  429. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  430. {
  431. if (pRsn->wepDefaultKeys[keyIndex])
  432. {
  433. rsnOsKey.KeyIndex = pRsn->keys[keyIndex].keyIndex;
  434. rsnOsKey.KeyLength = pRsn->keys[keyIndex].encLen;
  435. rsnOsKey.Length = sizeof(rsnOsKey);
  436. /* Change key type to WEP-key before setting*/
  437. pRsn->keys[keyIndex].keyType = WEP_KEY;
  438. os_memoryCopy (pRsn->hOs, rsnOsKey.BSSID,
  439. (void *)pRsn->keys[keyIndex].macAddress.addr,
  440. MAC_ADDR_LEN);
  441. os_memoryCopy (pRsn->hOs, &rsnOsKey.KeyRSC,
  442. (void *)pRsn->keys[keyIndex].keyRsc,
  443. KEY_RSC_LEN);
  444. os_memoryCopy (pRsn->hOs, rsnOsKey.KeyMaterial,
  445. (void *)pRsn->keys[keyIndex].encKey,
  446. MAX_KEY_LEN /*pRsn->keys[keyIndex].encLen*/);
  447. /* Set WEP transmit key mask on the default key */
  448. if (keyIndex == pRsn->defaultKeyId)
  449. {
  450. rsnOsKey.KeyIndex |= 0x80000000;
  451. }
  452. status = pRsn->pKeyParser->recv (pRsn->pKeyParser, (UINT8*)&rsnOsKey, sizeof(rsnOsKey));
  453. }
  454. }
  455. return status;
  456. }
  457. TI_STATUS rsn_removedDefKeys (TI_HANDLE hRsn)
  458. {
  459. UINT8 keyIndex;
  460. rsn_t *pRsn = (rsn_t*)hRsn;
  461. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  462. ("rsn_removedDefKeys Enter \n"));
  463. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  464. {
  465. securityKeys_t key;
  466. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  467. ("rsn_removedDefKeys, Remove keyId=%d\n", keyIndex));
  468. pRsn->wepDefaultKeys[keyIndex] = FALSE;
  469. os_memoryCopy (pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
  470. pRsn->removeKey (pRsn, &key);
  471. /* Set WEP transmit key mask on the default key */
  472. if (keyIndex == pRsn->defaultKeyId)
  473. {
  474. pRsn->defaultKeyId = 0;
  475. }
  476. }
  477. /* Clear the band site list */
  478. /* Comment out the call to clearBannedSiteList due to fail in WiFi mic attack test */
  479. /*clearBannedSiteList(hRsn);*/
  480. return OK;
  481. }
  482. /**
  483. *
  484. * rsn_Stop - Stop event for the rsniation SM
  485. *
  486. * \b Description:
  487. *
  488. * Stop event for the rsniation SM
  489. *
  490. * \b ARGS:
  491. *
  492. * I - hRsn - Rsniation SM context \n
  493. *
  494. * \b RETURNS:
  495. *
  496. * OK if successful, NOK otherwise.
  497. *
  498. * \sa rsn_Start, rsn_Recv
  499. */
  500. TI_STATUS rsn_stop (TI_HANDLE hRsn, BOOL removeKeys)
  501. {
  502. TI_STATUS status;
  503. rsn_t *pRsn;
  504. UINT8 keyIndex;
  505. securityKeys_t key;
  506. pRsn = (rsn_t*)hRsn;
  507. if (pRsn == NULL)
  508. {
  509. return NOK;
  510. }
  511. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  512. ("RSN: calling STOP... removeKeys=%d\n", removeKeys));
  513. for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
  514. {
  515. os_memoryCopy (pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
  516. if (!pRsn->wepDefaultKeys[keyIndex])
  517. { /* Remove only dynamic keys. Default keys are removed by calling: rsn_removedDefKeys() */
  518. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  519. ("rsn_stop, Remove keyIndex=%d, key.keyIndex=%d\n",keyIndex, key.keyIndex));
  520. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)key.macAddress.addr, 6);
  521. pRsn->removeKey (pRsn, &key);
  522. }
  523. }
  524. os_timerStop (pRsn->hOs, pRsn->micFailureReportWaitTimer);
  525. /* Stop the pre-authentication timer in case we are disconnecting */
  526. os_timerStop (pRsn->hOs, pRsn->pAdmCtrl->preAuthTimerWpa2);
  527. status = pRsn->pMainSecSm->stop (pRsn->pMainSecSm);
  528. pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_FALSE;
  529. pRsn->defaultKeysOn = TRUE;
  530. if (removeKeys)
  531. { /* reset PMKID list if exist */
  532. pRsn->pAdmCtrl->resetPmkidList (pRsn->pAdmCtrl);
  533. }
  534. return status;
  535. }
  536. /**
  537. *
  538. * rsn_GetParam - Get a specific parameter from the rsniation SM
  539. *
  540. * \b Description:
  541. *
  542. * Get a specific parameter from the rsniation SM.
  543. *
  544. * \b ARGS:
  545. *
  546. * I - hRsn - Rsniation SM context \n
  547. * I/O - pParam - Parameter \n
  548. *
  549. * \b RETURNS:
  550. *
  551. * OK if successful, NOK otherwise.
  552. *
  553. * \sa rsn_Start, rsn_Stop
  554. */
  555. TI_STATUS rsn_getParam(TI_HANDLE hRsn, paramInfo_t *pParam)
  556. {
  557. rsn_t *pRsn;
  558. TI_STATUS status = OK;
  559. pRsn = (rsn_t*)hRsn;
  560. if ((pRsn == NULL) || (pParam == NULL))
  561. {
  562. return NOK;
  563. }
  564. switch (pParam->paramType)
  565. {
  566. case RSN_PRIVACY_OPTION_IMPLEMENTED_PARAM:
  567. pParam->content.rsnPrivacyOptionImplemented = TRUE;
  568. break;
  569. case RSN_KEY_PARAM:
  570. pParam->content.pRsnKey = &pRsn->keys[pParam->content.pRsnKey->keyIndex];
  571. if (pParam->content.pRsnKey->keyIndex == pRsn->defaultKeyId)
  572. {
  573. pParam->content.pRsnKey->keyIndex |= 0x80000000;
  574. WLAN_REPORT_WARNING(pRsn->hReport, RSN_MODULE_LOG, ("default Key: %d\n", pRsn->defaultKeyId));
  575. }
  576. break;
  577. case RSN_SECURITY_STATE_PARAM:
  578. status = pRsn->pMainSecSm->getAuthState (pRsn->pMainSecSm, (TIWLN_SECURITY_STATE*)&(pParam->content.rsnAuthState));
  579. break;
  580. case RSN_ENCRYPTION_STATUS_PARAM:
  581. status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &pParam->content.rsnEncryptionStatus);
  582. break;
  583. case RSN_EXT_AUTHENTICATION_MODE:
  584. status = pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &pParam->content.rsnExtAuthneticationMode);
  585. break;
  586. case RSN_MIXED_MODE:
  587. status = pRsn->pAdmCtrl->getMixedMode (pRsn->pAdmCtrl, &pParam->content.rsnMixedMode);
  588. break;
  589. case RSN_AUTH_ENCR_CAPABILITY:
  590. status = pRsn->pAdmCtrl->getAuthEncrCap(pRsn->pAdmCtrl, pParam->content.pRsnAuthEncrCapability);
  591. break;
  592. case RSN_PMKID_LIST:
  593. pParam->content.rsnPMKIDList.Length = pParam->paramLength;
  594. status = pRsn->pAdmCtrl->getPmkidList (pRsn->pAdmCtrl, &pParam->content.rsnPMKIDList);
  595. pParam->paramLength = pParam->content.rsnPMKIDList.Length + 2 * sizeof(UINT32);
  596. break;
  597. case RSN_PRE_AUTH_STATUS:
  598. {
  599. UINT8 cacheIndex;
  600. pParam->content.rsnPreAuthStatus = pRsn->pAdmCtrl->getPreAuthStatus (pRsn->pAdmCtrl, &pParam->content.rsnApMac, &cacheIndex);
  601. }
  602. break;
  603. case RSN_WPA_PROMOTE_AVAILABLE_OPTIONS:
  604. status = pRsn->pAdmCtrl->getWPAMixedModeSupport (pRsn->pAdmCtrl, &pParam->content.rsnWPAMixedModeSupport);
  605. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  606. ("RSN: Get WPA Mixed MODE support %d \n",pParam->content.rsnWPAMixedModeSupport));
  607. break;
  608. case RSN_WPA_PROMOTE_OPTIONS:
  609. status = pRsn->pAdmCtrl->getPromoteFlags (pRsn->pAdmCtrl,
  610. &pParam->content.rsnWPAPromoteFlags);
  611. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  612. ("RSN: Get WPA promote flags %d \n",pParam->content.rsnWPAPromoteFlags));
  613. break;
  614. #ifdef EXC_MODULE_INCLUDED
  615. case RSN_EXC_NETWORK_EAP:
  616. status = pRsn->pAdmCtrl->getNetworkEap (pRsn->pAdmCtrl, &pParam->content.networkEap);
  617. break;
  618. #endif
  619. case RSN_EAP_TYPE:
  620. pParam->content.eapType = pRsn->eapType;
  621. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  622. ("RSN: Get RSN_EAP_TYPE eapType %d \n",
  623. pParam->content.eapType));
  624. break;
  625. case WPA_801_1X_AKM_EXISTS:
  626. status = pRsn->pAdmCtrl->get802_1x_AkmExists(pRsn->pAdmCtrl, &pParam->content.wpa_802_1x_AkmExists);
  627. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  628. ("RSN: Get WPA_801_1X_AKM_EXISTS %d \n",
  629. pParam->content.wpa_802_1x_AkmExists));
  630. break;
  631. case RSN_DEFAULT_KEY_ID:
  632. pParam->content.rsnDefaultKeyID = pRsn->defaultKeyId;
  633. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  634. ("RSN: Get RSN_DEFAULT_KEY_ID %d \n",
  635. pParam->content.rsnDefaultKeyID));
  636. break;
  637. default:
  638. return NOK;
  639. }
  640. return status;
  641. }
  642. /**
  643. *
  644. * rsn_getParamPartial - Get a specific parameter from the rsniation SM
  645. *
  646. * \b Description:
  647. *
  648. * Get a specific parameter from the rsniation SM.
  649. *
  650. * \b ARGS:
  651. *
  652. * I - hRsn - Rsniation SM context \n
  653. * I/O - pParam - Parameter \n
  654. *
  655. * \b RETURNS:
  656. *
  657. * OK if successful, NOK otherwise.
  658. *
  659. * \sa rsn_Start, rsn_Stop
  660. */
  661. /* note: rsn_getParamPartial() is part of rsn_getParam() it was implemented to reduce Stack usage */
  662. TI_STATUS rsn_getParamPartial(TI_HANDLE hRsn, paramInfoPartial_t *pParam)
  663. {
  664. rsn_t *pRsn;
  665. TI_STATUS status = OK;
  666. pRsn = (rsn_t*)hRsn;
  667. if ((pRsn == NULL) || (pParam == NULL))
  668. {
  669. return NOK;
  670. }
  671. switch (pParam->paramType)
  672. {
  673. case RSN_PRE_AUTH_STATUS:
  674. {
  675. UINT8 cacheIndex;
  676. pParam->content.rsnPreAuthStatus = pRsn->pAdmCtrl->getPreAuthStatus (pRsn->pAdmCtrl, &pParam->content.rsnApMac, &cacheIndex);
  677. }
  678. break;
  679. case RSN_ENCRYPTION_STATUS_PARAM:
  680. status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &pParam->content.rsnEncryptionStatus);
  681. break;
  682. case RSN_MIXED_MODE:
  683. status = pRsn->pAdmCtrl->getMixedMode (pRsn->pAdmCtrl, &pParam->content.rsnMixedMode);
  684. break;
  685. default:
  686. return NOK;
  687. }
  688. return status;
  689. }
  690. /**
  691. *
  692. * rsn_SetParam - Set a specific parameter to the rsniation SM
  693. *
  694. * \b Description:
  695. *
  696. * Set a specific parameter to the rsniation SM.
  697. *
  698. * \b ARGS:
  699. *
  700. * I - hRsn - Rsniation SM context \n
  701. * I/O - pParam - Parameter \n
  702. *
  703. * \b RETURNS:
  704. *
  705. * OK if successful, NOK otherwise.
  706. *
  707. * \sa rsn_Start, rsn_Stop
  708. */
  709. TI_STATUS rsn_setParam (TI_HANDLE hRsn, paramInfo_t *pParam)
  710. {
  711. rsn_t *pRsn;
  712. TI_STATUS status=OK;
  713. whalParamInfo_t whalParam;
  714. pRsn = (rsn_t*)hRsn;
  715. if ((pRsn == NULL) || (pParam == NULL))
  716. {
  717. return NOK;
  718. }
  719. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  720. ("RSN: Set rsn_setParam %X \n",
  721. pParam->paramType));
  722. switch (pParam->paramType)
  723. {
  724. case RSN_DEFAULT_KEY_ID:
  725. {
  726. UINT8 defKeyId, i;
  727. defKeyId = pParam->content.rsnDefaultKeyID;
  728. if(defKeyId >= MAX_KEYS_NUM)
  729. {
  730. WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG,
  731. ("RSN: Error - the value of the default Key Id is incorrect \n"));
  732. return NOK;
  733. }
  734. /* Clean transmit flag (1 in the bit31) in the previous default key */
  735. for(i = 0; i < MAX_KEYS_NUM; i++)
  736. {
  737. pRsn->keys[i].keyIndex &= 0x7FFFFFFF;
  738. }
  739. /* Set the default key ID value in the RSN data structure */
  740. pRsn->defaultKeyId = defKeyId;
  741. /* Set the default key ID in the HAL */
  742. whalParam.paramType = HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM;
  743. whalParam.content.configureCmdCBParams.CB_buf = &pRsn->defaultKeyId;
  744. whalParam.content.configureCmdCBParams.CB_Func = NULL;
  745. whalParam.content.configureCmdCBParams.CB_handle = NULL;
  746. status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
  747. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  748. ("RSN: default key ID =%d \n", pRsn->defaultKeyId));
  749. status = RE_SCAN_NEEDED;
  750. break;
  751. }
  752. case RSN_ADD_KEY_PARAM:
  753. {
  754. UINT8 keyIndex, i = 0;
  755. cipherSuite_e cipherSuite;
  756. status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
  757. if (status !=OK)
  758. {
  759. return status;
  760. }
  761. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  762. ("RSN: Set RSN_ADD_KEY_PARAM KeyIndex %x , keyLength=%d\n",
  763. pParam->content.rsnOsKey.KeyIndex,pParam->content.rsnOsKey.KeyLength));
  764. keyIndex = (UINT8)pParam->content.rsnOsKey.KeyIndex;
  765. if (keyIndex >= MAX_KEYS_NUM)
  766. {
  767. return NOK;
  768. }
  769. status = pRsn->pKeyParser->recv (pRsn->pKeyParser, (UINT8*)&pParam->content.rsnOsKey, sizeof(pParam->content.rsnOsKey));
  770. if (status==STATUS_BAD_KEY_PARAM)
  771. {
  772. return NOK;
  773. }
  774. /* If the Key is not BAD, it may be that WEP key is sent before WEP status is set,
  775. save the key, and set it later at rsn_start */
  776. pRsn->keys[keyIndex].keyIndex = pParam->content.rsnOsKey.KeyIndex;
  777. pRsn->keys[keyIndex].encLen = pParam->content.rsnOsKey.KeyLength;
  778. os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].macAddress.addr, pParam->content.rsnOsKey.BSSID, MAC_ADDR_LEN);
  779. os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].keyRsc, (UINT8*)&(pParam->content.rsnOsKey.KeyRSC), KEY_RSC_LEN);
  780. os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].encKey, pParam->content.rsnOsKey.KeyMaterial, MAX_KEY_LEN);
  781. /* Process the transmit flag (31-st bit of keyIndex). */
  782. /* If the added key has the TX bit set to TRUE (i.e. the key */
  783. /* is the new transmit key (default key), update */
  784. /* RSN data def.key Id and clean this bit in all other keys */
  785. if (pParam->content.rsnOsKey.KeyIndex & 0x80000000)
  786. {
  787. pRsn->defaultKeyId = keyIndex;
  788. for (i = 0; i < MAX_KEYS_NUM; i ++)
  789. {
  790. if (i != keyIndex)
  791. {
  792. pRsn->keys[i].keyIndex &= 0x7FFFFFFF;
  793. }
  794. }
  795. }
  796. if (pRsn->defaultKeysOn)
  797. { /* This is a WEP default key */
  798. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  799. ("RSN_ADD_KEY_PARAM, Default key configured - keyIndex=%d-TRUE\n", keyIndex));
  800. pRsn->wepDefaultKeys[keyIndex] = TRUE;
  801. pRsn->wepStaticKey = TRUE;
  802. status = OK;
  803. }
  804. break;
  805. }
  806. case RSN_REMOVE_KEY_PARAM:
  807. {
  808. UINT8 keyIndex;
  809. cipherSuite_e cipherSuite;
  810. status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
  811. if (status !=OK)
  812. {
  813. return status;
  814. }
  815. /*if (cipherSuite == RSN_CIPHER_NONE)
  816. {
  817. WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG,
  818. ("RSN: Error Remove Wep/Key when no encryption \n"));
  819. return NOK;
  820. }*/
  821. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  822. ("RSN: Set RSN_REMOVE_KEY_PARAM KeyIndex %x \n",
  823. pParam->content.rsnOsKey.KeyIndex));
  824. keyIndex = (UINT8)pParam->content.rsnOsKey.KeyIndex;
  825. if (keyIndex >= MAX_KEYS_NUM)
  826. {
  827. return NOK;
  828. }
  829. status = pRsn->pKeyParser->remove (pRsn->pKeyParser,
  830. (UINT8*)&pParam->content.rsnOsKey,
  831. sizeof(pParam->content.rsnOsKey));
  832. if (status == OK)
  833. {
  834. pRsn->keys[keyIndex].keyType = NULL_KEY;
  835. pRsn->keys[keyIndex].keyIndex &= 0x000000FF;
  836. }
  837. break;
  838. }
  839. case RSN_ENCRYPTION_STATUS_PARAM:
  840. {
  841. cipherSuite_e cipherSuite;
  842. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  843. ("RSN: Set RSN_ENCRYPTION_STATUS_PARAM rsnEncryptionStatus %d \n",
  844. pParam->content.rsnEncryptionStatus));
  845. pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
  846. if (cipherSuite != pParam->content.rsnEncryptionStatus)
  847. {
  848. status = pRsn->pAdmCtrl->setUcastSuite (pRsn->pAdmCtrl, pParam->content.rsnEncryptionStatus);
  849. status = pRsn->pAdmCtrl->setBcastSuite (pRsn->pAdmCtrl, pParam->content.rsnEncryptionStatus);
  850. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (" status = %d \n", status));
  851. }
  852. pRsn->defaultKeysOn = TRUE;
  853. }
  854. break;
  855. case RSN_EXT_AUTHENTICATION_MODE:
  856. {
  857. externalAuthMode_e extAuthMode;
  858. pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
  859. if (pParam->content.rsnExtAuthneticationMode!=extAuthMode)
  860. {
  861. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  862. ("RSN: Set RSN_EXT_AUTHENTICATION_MODE rsnExtAuthneticationMode %d \n",
  863. pParam->content.rsnExtAuthneticationMode));
  864. /*WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  865. ("RSN: remove all Keys\n"));
  866. for (keyIndex=0; keyIndex<MAX_KEYS_NUM; keyIndex++)
  867. {
  868. os_memoryCopy(pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
  869. pRsn->removeKey(pRsn, &key);
  870. }*/
  871. status = pRsn->pAdmCtrl->setExtAuthMode (pRsn->pAdmCtrl, pParam->content.rsnExtAuthneticationMode);
  872. }
  873. pRsn->defaultKeysOn = TRUE;
  874. }
  875. break;
  876. #ifdef EXC_MODULE_INCLUDED
  877. case RSN_EXC_NETWORK_EAP:
  878. {
  879. OS_EXC_NETWORK_EAP networkEap;
  880. pRsn->pAdmCtrl->getNetworkEap (pRsn->pAdmCtrl, &networkEap);
  881. if (networkEap != pParam->content.networkEap)
  882. {
  883. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  884. ("RSN: Set RSN_EXC_NETWORK_EAP networkEap %d \n",
  885. pParam->content.networkEap));
  886. status = pRsn->pAdmCtrl->setNetworkEap (pRsn->pAdmCtrl, pParam->content.networkEap);
  887. if (status == OK)
  888. {
  889. /*status = RE_SCAN_NEEDED;*/
  890. }
  891. }
  892. }
  893. break;
  894. #endif
  895. case RSN_MIXED_MODE:
  896. {
  897. BOOL mixedMode;
  898. pRsn->pAdmCtrl->getMixedMode (pRsn->pAdmCtrl, &mixedMode);
  899. if (mixedMode!=pParam->content.rsnMixedMode)
  900. {
  901. status = pRsn->pAdmCtrl->setMixedMode (pRsn->pAdmCtrl, pParam->content.rsnMixedMode);
  902. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  903. ("RSN: Set RSN_MIXED_MODE mixedMode %d, status=%d \n",
  904. pParam->content.rsnMixedMode, status));
  905. }
  906. break;
  907. }
  908. case RSN_PMKID_LIST:
  909. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  910. ("RSN: Set RSN_PMKID_LIST \n"));
  911. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  912. (UINT8*)&pParam->content.rsnPMKIDList ,pParam->content.rsnPMKIDList.Length);
  913. status = pRsn->pAdmCtrl->setPmkidList (pRsn->pAdmCtrl,
  914. &pParam->content.rsnPMKIDList);
  915. if(status == OK)
  916. {
  917. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  918. ("RSN: Set RSN_PMKID_LIST: %d PMKID entries has been added to the cache.\n",
  919. pParam->content.rsnPMKIDList.BSSIDInfoCount));
  920. }
  921. else
  922. {
  923. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  924. ("RSN: Set RSN_PMKID_LIST failure"));
  925. }
  926. break;
  927. case RSN_WPA_PROMOTE_OPTIONS:
  928. status = pRsn->pAdmCtrl->setPromoteFlags (pRsn->pAdmCtrl,
  929. pParam->content.rsnWPAPromoteFlags);
  930. if(status == OK)
  931. {
  932. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  933. ("RSN: Set WPA promote options: %d \n", pParam->content.rsnWPAPromoteFlags));
  934. }
  935. else
  936. {
  937. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  938. ("RSN: Set WPA promote options failure"));
  939. }
  940. break;
  941. case RSN_EAP_TYPE:
  942. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  943. ("RSN: Set RSN_EAP_TYPE eapType %d \n",
  944. pParam->content.eapType));
  945. pRsn->eapType = pParam->content.eapType;
  946. pRsn->defaultKeysOn = TRUE;
  947. break;
  948. default:
  949. return NOK;
  950. }
  951. return status;
  952. }
  953. /**
  954. *
  955. * rsn_eventRecv - Set a specific parameter to the rsniation SM
  956. *
  957. * \b Description:
  958. *
  959. * Set a specific parameter to the rsniation SM.
  960. *
  961. * \b ARGS:
  962. *
  963. * I - hRsn - Rsniation SM context \n
  964. * I/O - pParam - Parameter \n
  965. *
  966. * \b RETURNS:
  967. *
  968. * OK if successful, NOK otherwise.
  969. *
  970. * \sa rsn_Start, rsn_Stop
  971. */
  972. TI_STATUS rsn_reportStatus (rsn_t *pRsn, TI_STATUS rsnStatus)
  973. {
  974. TI_STATUS status = OK;
  975. paramInfo_t param;
  976. externalAuthMode_e extAuthMode;
  977. if (pRsn == NULL)
  978. {
  979. return NOK;
  980. }
  981. if (rsnStatus == OK)
  982. {
  983. /* set EAPOL encryption status according to authentication protocol */
  984. pRsn->rsnCompletedTs = os_timeStampMs (pRsn->hOs);
  985. status = pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
  986. if (status != OK)
  987. {
  988. return status;
  989. }
  990. if (extAuthMode >= RSN_EXT_AUTH_MODE_WPA)
  991. {
  992. param.content.txDataEapolEncryptionStatus = TRUE;
  993. } else {
  994. param.content.txDataEapolEncryptionStatus = FALSE;
  995. }
  996. param.paramType = TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM;
  997. txData_setParam (pRsn->hTx, &param);
  998. /* set WEP invoked mode according to cipher suite */
  999. switch (pRsn->paeConfig.unicastSuite)
  1000. {
  1001. case RSN_CIPHER_NONE:
  1002. param.content.txDataCurrentPrivacyInvokedMode = FALSE;
  1003. break;
  1004. default:
  1005. param.content.txDataCurrentPrivacyInvokedMode = TRUE;
  1006. break;
  1007. }
  1008. param.paramType = TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM;
  1009. txData_setParam (pRsn->hTx, &param);
  1010. /* The value of exclude unencrypted should be as privacy invoked */
  1011. param.paramType = RX_DATA_EXCLUDE_UNENCRYPTED_PARAM;
  1012. rxData_setParam (pRsn->hRx, &param);
  1013. param.paramType = RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM;
  1014. if (pRsn->pAdmCtrl->mixedMode)
  1015. { /* do not exclude Broadcast packets */
  1016. param.content.txDataCurrentPrivacyInvokedMode = FALSE;
  1017. }
  1018. rxData_setParam (pRsn->hRx, &param);
  1019. }
  1020. else
  1021. rsnStatus = (TI_STATUS)STATUS_SECURITY_FAILURE;
  1022. status = conn_reportRsnStatus (pRsn->hConn, (mgmtStatus_e)rsnStatus);
  1023. if (status!=OK)
  1024. {
  1025. return status;
  1026. }
  1027. if (rsnStatus == OK)
  1028. {
  1029. EvHandlerSendEvent (pRsn->hEvHandler, IPC_EVENT_AUTH_SUCC, NULL, 0);
  1030. }
  1031. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1032. ("RSN: rsn_reportStatus \n"));
  1033. return OK;
  1034. }
  1035. /**
  1036. *
  1037. * rsn_eventRecv - Set a specific parameter to the rsniation SM
  1038. *
  1039. * \b Description:
  1040. *
  1041. * Set a specific parameter to the rsniation SM.
  1042. *
  1043. * \b ARGS:
  1044. *
  1045. * I - hRsn - Rsniation SM context \n
  1046. * I/O - pParam - Parameter \n
  1047. *
  1048. * \b RETURNS:
  1049. *
  1050. * OK if successful, NOK otherwise.
  1051. *
  1052. * \sa rsn_Start, rsn_Stop
  1053. */
  1054. TI_STATUS rsn_setPaeConfig(rsn_t *pRsn, rsn_paeConfig_t *pPaeConfig)
  1055. {
  1056. TI_STATUS status;
  1057. mainSecInitData_t initData;
  1058. if ((pRsn == NULL) || (pPaeConfig == NULL))
  1059. {
  1060. return NOK;
  1061. }
  1062. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1063. ("RSN: Calling set PAE config..., unicastSuite = %d, broadcastSuite = %d \n",
  1064. pPaeConfig->unicastSuite, pPaeConfig->broadcastSuite));
  1065. os_memoryCopy(pRsn->hOs, &pRsn->paeConfig, pPaeConfig, sizeof(rsn_paeConfig_t));
  1066. initData.pPaeConfig = &pRsn->paeConfig;
  1067. status = mainSec_config (pRsn->pMainSecSm,
  1068. &initData,
  1069. pRsn,
  1070. pRsn->hReport,
  1071. pRsn->hOs,
  1072. pRsn->hCtrlData,
  1073. pRsn->hEvHandler,
  1074. pRsn->hConn,
  1075. pRsn->hWhalCtrl);
  1076. return status;
  1077. }
  1078. /**
  1079. *
  1080. * rsn_eventRecv - Set a specific parameter to the rsniation SM
  1081. *
  1082. * \b Description:
  1083. *
  1084. * Set a specific parameter to the rsniation SM.
  1085. *
  1086. * \b ARGS:
  1087. *
  1088. * I - hRsn - Rsniation SM context \n
  1089. * I/O - pParam - Parameter \n
  1090. *
  1091. * \b RETURNS:
  1092. *
  1093. * OK if successful, NOK otherwise.
  1094. *
  1095. * \sa rsn_Start, rsn_Stop
  1096. */
  1097. TI_STATUS rsn_getNetworkMode(rsn_t *pRsn, rsn_networkMode_t *pNetMode)
  1098. {
  1099. paramInfo_t param;
  1100. TI_STATUS status;
  1101. param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
  1102. status = ctrlData_getParam (pRsn->hCtrlData, &param);
  1103. if (status == OK)
  1104. {
  1105. if (param.content.ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)
  1106. {
  1107. *pNetMode = RSN_INFRASTRUCTURE;
  1108. }
  1109. else
  1110. {
  1111. *pNetMode = RSN_IBSS;
  1112. }
  1113. }
  1114. else
  1115. {
  1116. return NOK;
  1117. }
  1118. return OK;
  1119. }
  1120. /**
  1121. *
  1122. * rsn_eventRecv - Set a specific parameter to the rsniation SM
  1123. *
  1124. * \b Description:
  1125. *
  1126. * Set a specific parameter to the rsniation SM.
  1127. *
  1128. * \b ARGS:
  1129. *
  1130. * I - hRsn - Rsniation SM context \n
  1131. * I/O - pParam - Parameter \n
  1132. *
  1133. * \b RETURNS:
  1134. *
  1135. * OK if successful, NOK otherwise.
  1136. *
  1137. * \sa rsn_Start, rsn_Stop
  1138. */
  1139. TI_STATUS rsn_evalSite(TI_HANDLE hRsn, rsnData_t *pRsnData, bssType_e bssType, macAddress_t bssid, UINT32 *pMetric)
  1140. {
  1141. rsn_t *pRsn;
  1142. TI_STATUS status;
  1143. if ((pRsnData == NULL) || (hRsn == NULL))
  1144. {
  1145. *pMetric = 0;
  1146. return NOK;
  1147. }
  1148. pRsn = (rsn_t*)hRsn;
  1149. if (rsn_isSiteBanned(hRsn, bssid) == TRUE)
  1150. {
  1151. *pMetric = 0;
  1152. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site is banned!\n", __FUNCTION__));
  1153. return NOK;
  1154. }
  1155. status = pRsn->pAdmCtrl->evalSite (pRsn->pAdmCtrl, pRsnData, bssType, pMetric);
  1156. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: pMetric=%d status=%d\n", __FUNCTION__, *pMetric, status));
  1157. return status;
  1158. }
  1159. /**
  1160. *
  1161. * rsn_getInfoElement -
  1162. *
  1163. * \b Description:
  1164. *
  1165. * Get the RSN information element.
  1166. *
  1167. * \b ARGS:
  1168. *
  1169. * I - hRsn - Rsn SM context \n
  1170. * I/O - pRsnIe - Pointer to the return information element \n
  1171. * I/O - pRsnIeLen - Pointer to the returned IE's length \n
  1172. *
  1173. * \b RETURNS:
  1174. *
  1175. * OK if successful, NOK otherwise.
  1176. *
  1177. * \sa
  1178. */
  1179. TI_STATUS rsn_getInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen)
  1180. {
  1181. rsn_t *pRsn;
  1182. TI_STATUS status;
  1183. if ((hRsn == NULL) || (pRsnIe == NULL) || (pRsnIeLen == NULL))
  1184. {
  1185. return NOK;
  1186. }
  1187. pRsn = (rsn_t*)hRsn;
  1188. status = pRsn->pAdmCtrl->getInfoElement (pRsn->pAdmCtrl, pRsnIe, pRsnIeLen);
  1189. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_getInfoElement pRsnIeLen= %d\n",*pRsnIeLen));
  1190. return status;
  1191. }
  1192. #ifdef EXC_MODULE_INCLUDED
  1193. /**
  1194. *
  1195. * rsn_getExcExtendedInfoElement -
  1196. *
  1197. * \b Description:
  1198. *
  1199. * Get the Aironet information element.
  1200. *
  1201. * \b ARGS:
  1202. *
  1203. * I - hRsn - Rsn SM context \n
  1204. * I/O - pRsnIe - Pointer to the return information element \n
  1205. * I/O - pRsnIeLen - Pointer to the returned IE's length \n
  1206. *
  1207. * \b RETURNS:
  1208. *
  1209. * OK if successful, NOK otherwise.
  1210. *
  1211. * \sa
  1212. */
  1213. TI_STATUS rsn_getExcExtendedInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen)
  1214. {
  1215. rsn_t *pRsn;
  1216. TI_STATUS status;
  1217. if ((hRsn == NULL) || (pRsnIe == NULL) || (pRsnIeLen == NULL))
  1218. {
  1219. return NOK;
  1220. }
  1221. pRsn = (rsn_t*)hRsn;
  1222. status = admCtrlExc_getInfoElement (pRsn->pAdmCtrl, pRsnIe, pRsnIeLen);
  1223. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_getExcExtendedInfoElement pRsnIeLen= %d\n",*pRsnIeLen));
  1224. return status;
  1225. }
  1226. #endif
  1227. /**
  1228. *
  1229. * rsn_eventRecv - Set a specific parameter to the rsniation SM
  1230. *
  1231. * \b Description:
  1232. *
  1233. * Set a specific parameter to the rsniation SM.
  1234. *
  1235. * \b ARGS:
  1236. *
  1237. * I - hRsn - Rsniation SM context \n
  1238. * I/O - pParam - Parameter \n
  1239. *
  1240. * \b RETURNS:
  1241. *
  1242. * OK if successful, NOK otherwise.
  1243. *
  1244. * \sa rsn_Start, rsn_Stop
  1245. */
  1246. TI_STATUS rsn_setSite(TI_HANDLE hRsn, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
  1247. {
  1248. rsn_t *pRsn;
  1249. TI_STATUS status;
  1250. if ((pRsnData == NULL) || (hRsn == NULL))
  1251. {
  1252. *pAssocIeLen = 0;
  1253. return NOK;
  1254. }
  1255. pRsn = (rsn_t*)hRsn;
  1256. status = pRsn->pAdmCtrl->setSite (pRsn->pAdmCtrl, pRsnData, pAssocIe, pAssocIeLen);
  1257. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_setSite ieLen= %d\n",pRsnData->ieLen));
  1258. return status;
  1259. }
  1260. TI_STATUS rsn_setKey (rsn_t *pRsn, securityKeys_t *pKey)
  1261. {
  1262. TI_STATUS status = OK;
  1263. whalParamInfo_t whalParam;
  1264. paramInfo_t param;
  1265. UINT8 keyIndex;
  1266. BOOL macIsBroadcast = FALSE;
  1267. keyIndex = (UINT8)pKey->keyIndex;
  1268. if ((pRsn == NULL) || (pKey == NULL) || (keyIndex >= MAX_KEYS_NUM))
  1269. {
  1270. return NOK;
  1271. }
  1272. /*
  1273. * In full driver we use only WEP default keys. That's why we make sure that the macAddress is cleared.
  1274. * In GWSI we use WEP mapping key if the macAddress is not NULL.
  1275. */
  1276. if (pKey->keyType == WEP_KEY)
  1277. {
  1278. os_memoryZero(pRsn->hOs,(void*)pKey->macAddress.addr,
  1279. sizeof(macAddress_t));
  1280. }
  1281. if (pKey->keyType != NULL_KEY)
  1282. {
  1283. /* set the size to reserve for encryption to the tx */
  1284. /* update this parameter only in accordance with pairwise key setting */
  1285. if (!MAC_BROADCAST((&pKey->macAddress)))
  1286. {
  1287. param.paramType = TX_DATA_ENCRYPTION_FIELD_SIZE;
  1288. switch (pKey->keyType)
  1289. {
  1290. case TKIP_KEY:
  1291. param.content.txDataEncryptionFieldSize = IV_FIELD_SIZE;
  1292. break;
  1293. case AES_KEY:
  1294. param.content.txDataEncryptionFieldSize = AES_AFTER_HEADER_FIELD_SIZE;
  1295. break;
  1296. case NULL_KEY:
  1297. case WEP_KEY:
  1298. case EXC_KEY:
  1299. default:
  1300. param.content.txDataEncryptionFieldSize = 0;
  1301. break;
  1302. }
  1303. txData_setParam (pRsn->hTx, &param);
  1304. }
  1305. macIsBroadcast = MAC_BROADCAST((&pKey->macAddress));
  1306. if ((pRsn->keys[keyIndex].keyType != NULL_KEY )&&
  1307. macIsBroadcast && !MAC_BROADCAST((&pRsn->keys[keyIndex].macAddress)))
  1308. { /* In case a new Group key is set instead of a Unicast key,
  1309. first remove the UNIcast key from FW */
  1310. rsn_removeKey(pRsn, &pRsn->keys[keyIndex]);
  1311. }
  1312. pRsn->keys[keyIndex].keyType = pKey->keyType;
  1313. pRsn->keys[keyIndex].keyIndex = keyIndex;
  1314. whalParam.paramType = HAL_CTRL_RSN_KEY_ADD_PARAM;
  1315. whalParam.content.configureCmdCBParams.CB_buf = (UINT8*) pKey;
  1316. whalParam.content.configureCmdCBParams.CB_Func = NULL;
  1317. whalParam.content.configureCmdCBParams.CB_handle = NULL;
  1318. if (macIsBroadcast)
  1319. {
  1320. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1321. ("RSN: rsn_setKey, Group ReKey timer started\n"));
  1322. os_timerStop (pRsn->hOs, pRsn->micFailureReKeyTimer);
  1323. os_timerStart (pRsn->hOs, pRsn->micFailureReKeyTimer, RSN_MIC_FAILURE_RE_KEY, FALSE);
  1324. pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_TRUE;
  1325. }
  1326. /* Mark key as added */
  1327. pRsn->keys_en [keyIndex] = TRUE;
  1328. status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
  1329. }
  1330. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1331. ("RSN: rsn_setKey, KeyType=%d, KeyId = 0x%lx,encLen=0x%x\n",
  1332. pKey->keyType,pKey->keyIndex, pKey->encLen));
  1333. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nEncKey = "));
  1334. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->encKey, pKey->encLen);
  1335. if (pKey->keyType != WEP_KEY)
  1336. {
  1337. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMac address = "));
  1338. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->macAddress.addr, MAC_ADDR_LEN);
  1339. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nRSC = "));
  1340. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->keyRsc, KEY_RSC_LEN);
  1341. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMic RX = "));
  1342. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->micRxKey, MAX_KEY_LEN);
  1343. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMic TX = "));
  1344. WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->micTxKey, MAX_KEY_LEN);
  1345. }
  1346. return status;
  1347. }
  1348. TI_STATUS rsn_removeKey (rsn_t *pRsn, securityKeys_t *pKey)
  1349. {
  1350. TI_STATUS status = OK;
  1351. whalParamInfo_t whalParam;
  1352. UINT8 keyIndex;
  1353. keyIndex = (UINT8)pKey->keyIndex;
  1354. if ((pRsn == NULL) || (pKey == NULL) || (keyIndex >= MAX_KEYS_NUM))
  1355. {
  1356. return NOK;
  1357. }
  1358. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1359. ("rsn_removeKey Entry, keyType=%d, keyIndex=0x%lx\n",pKey->keyType, keyIndex));
  1360. /* Now set to the RSN structure. */
  1361. if (pKey->keyType != NULL_KEY && pRsn->keys_en[keyIndex])
  1362. {
  1363. whalParam.paramType = HAL_CTRL_RSN_KEY_REMOVE_PARAM;
  1364. /*os_memoryCopy(pRsn->hOs, &whalParam.content.rsnKey, pKey, sizeof(securityKeys_t));*/
  1365. whalParam.content.configureCmdCBParams.CB_buf = (UINT8*) pKey;
  1366. whalParam.content.configureCmdCBParams.CB_Func = NULL;
  1367. whalParam.content.configureCmdCBParams.CB_handle = NULL;
  1368. /* If keyType is TKIP or AES, set the encLen to the KEY enc len - 16 */
  1369. if (pKey->keyType == TKIP_KEY || pKey->keyType == AES_KEY)
  1370. {
  1371. pKey->encLen = 16;
  1372. if (keyIndex != 0)
  1373. {
  1374. const UINT8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  1375. /*
  1376. * if keyType is TKIP or AES, and the key index is broadcast, overwrite the MAC address as broadcast
  1377. * for removing the Broadcast key from the FW
  1378. */
  1379. os_memoryCopy (pRsn->hOs, (void *)&pKey->macAddress.addr[0], (void*)broadcast, MAC_ADDR_LEN);
  1380. }
  1381. }
  1382. else if (pKey->keyType == WEP_KEY)
  1383. {
  1384. /* In full driver we use only WEP default keys. To remove it we make sure that the MAC address is NULL */
  1385. os_memoryZero(pRsn->hOs,(void*)pKey->macAddress.addr,sizeof(macAddress_t));
  1386. }
  1387. /* Mark key as deleted */
  1388. pRsn->keys_en[keyIndex] = FALSE;
  1389. status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
  1390. WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
  1391. ("rsn_removeKey in whal, status =%d\n", status));
  1392. /* clean the key flags*/
  1393. pRsn->keys[keyIndex].keyIndex &= 0x000000FF;
  1394. pRsn->keys[keyIndex].keyType = NULL_KEY;
  1395. pRsn->keys[keyIndex].encLen = 0;
  1396. pRsn->wepDefaultKeys[keyIndex] = FALSE;
  1397. }
  1398. return status;
  1399. }
  1400. TI_STATUS rsn_setDefaultKeyId(rsn_t *pRsn, UINT8 keyId)
  1401. {
  1402. TI_STATUS status = OK;
  1403. whalParamInfo_t whalParam;
  1404. if (pRsn == NULL)
  1405. {
  1406. retu

Large files files are truncated, but you can click here to view the full file