2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
34 -------- ---------- ----------------------------------------------
35 Jan Lee 03-07-22 Initial
36 Paul Lin 03-11-28 Modify for supplicant
38 #include "../rt_config.h"
40 UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00};
41 UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01};
42 UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02};
43 UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04};
44 UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01};
45 UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02};
47 UCHAR OUI_WPA2_WEP40[4] = {0x00, 0x0F, 0xAC, 0x01};
48 UCHAR OUI_WPA2_TKIP[4] = {0x00, 0x0F, 0xAC, 0x02};
49 UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04};
50 UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01};
51 UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02};
53 UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06
54 UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06
57 ========================================================================
60 The pseudo-random function(PRF) that hashes various inputs to
61 derive a pseudo-random value. To add liveness to the pseudo-random
62 value, a nonce should be one of the inputs.
64 It is used to generate PTK, GTK or some specific random value.
67 UCHAR *key, - the key material for HMAC_SHA1 use
68 INT key_len - the length of key
69 UCHAR *prefix - a prefix label
70 INT prefix_len - the length of the label
71 UCHAR *data - a specific data with variable length
72 INT data_len - the length of a specific data
73 INT len - the output lenght
76 UCHAR *output - the calculated result
79 802.11i-2004 Annex H.3
81 ========================================================================
98 // Allocate memory for input
99 os_alloc_mem(NULL, (PUCHAR *)&input, 1024);
103 DBGPRINT(RT_DEBUG_ERROR, ("!!!PRF: no memory!!!\n"));
107 // Generate concatenation input
108 NdisMoveMemory(input, prefix, prefix_len);
110 // Concatenate a single octet containing 0
111 input[prefix_len] = 0;
113 // Concatenate specific data
114 NdisMoveMemory(&input[prefix_len + 1], data, data_len);
115 total_len = prefix_len + 1 + data_len;
117 // Concatenate a single octet containing 0
118 // This octet shall be update later
119 input[total_len] = 0;
122 // Iterate to calculate the result by hmac-sha-1
123 // Then concatenate to last result
124 for (i = 0; i < (len + 19) / 20; i++)
126 HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
129 // update the last octet
130 input[total_len - 1]++;
132 os_free_mem(NULL, input);
136 ========================================================================
139 It utilizes PRF-384 or PRF-512 to derive session-specific keys from a PMK.
140 It shall be called by 4-way handshake processing.
143 pAd - pointer to our pAdapter context
145 ANonce - pointer to ANonce
146 AA - pointer to Authenticator Address
147 SNonce - pointer to SNonce
148 SA - pointer to Supplicant Address
149 len - indicate the length of PTK (octet)
152 Output pointer to the PTK
155 Refer to IEEE 802.11i-2004 8.5.1.2
157 ========================================================================
160 IN PRTMP_ADAPTER pAd,
169 UCHAR concatenation[76];
172 UCHAR Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
173 'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'};
175 // initiate the concatenation input
176 NdisZeroMemory(temp, sizeof(temp));
177 NdisZeroMemory(concatenation, 76);
179 // Get smaller address
180 if (RTMPCompareMemory(SA, AA, 6) == 1)
181 NdisMoveMemory(concatenation, AA, 6);
183 NdisMoveMemory(concatenation, SA, 6);
186 // Get larger address
187 if (RTMPCompareMemory(SA, AA, 6) == 1)
188 NdisMoveMemory(&concatenation[CurrPos], SA, 6);
190 NdisMoveMemory(&concatenation[CurrPos], AA, 6);
192 // store the larger mac address for backward compatible of
193 // ralink proprietary STA-key issue
194 NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);
198 if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
199 NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
200 else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
201 NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
203 NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
207 if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
208 NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
209 else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
210 NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
212 NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
215 hex_dump("concatenation=", concatenation, 76);
217 // Use PRF to generate PTK
218 PRF(PMK, LEN_MASTER_KEY, Prefix, 22, concatenation, 76, output, len);
223 ========================================================================
226 Generate random number by software.
229 pAd - pointer to our pAdapter context
230 macAddr - pointer to local MAC address
235 802.1ii-2004 Annex H.5
237 ========================================================================
240 IN PRTMP_ADAPTER pAd,
245 UCHAR local[80], KeyCounter[32];
248 UCHAR prefix[] = {'I', 'n', 'i', 't', ' ', 'C', 'o', 'u', 'n', 't', 'e', 'r'};
250 // Zero the related information
251 NdisZeroMemory(result, 80);
252 NdisZeroMemory(local, 80);
253 NdisZeroMemory(KeyCounter, 32);
255 for (i = 0; i < 32; i++)
257 // copy the local MAC address
258 COPY_MAC_ADDR(local, macAddr);
261 // concatenate the current time
262 NdisGetSystemUpTime(&CurrentTime);
263 NdisMoveMemory(&local[curr], &CurrentTime, sizeof(CurrentTime));
264 curr += sizeof(CurrentTime);
266 // concatenate the last result
267 NdisMoveMemory(&local[curr], result, 32);
270 // concatenate a variable
271 NdisMoveMemory(&local[curr], &i, 2);
274 // calculate the result
275 PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
278 NdisMoveMemory(random, result, 32);
282 ========================================================================
285 Build cipher suite in RSN-IE.
286 It only shall be called by RTMPMakeRSNIE.
289 pAd - pointer to our pAdapter context
290 ElementID - indicate the WPA1 or WPA2
291 WepStatus - indicate the encryption type
292 bMixCipher - a boolean to indicate the pairwise cipher and group
293 cipher are the same or not
299 ========================================================================
301 static VOID RTMPInsertRsnIeCipher(
302 IN PRTMP_ADAPTER pAd,
305 IN BOOLEAN bMixCipher,
306 IN UCHAR FlexibleCipher,
314 // decide WPA2 or WPA1
315 if (ElementID == Wpa2Ie)
317 RSNIE2 *pRsnie_cipher = (RSNIE2*)pRsnIe;
319 // Assign the verson as 1
320 pRsnie_cipher->version = 1;
325 case Ndis802_11Encryption2Enabled:
326 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
327 pRsnie_cipher->ucount = 1;
328 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
329 *rsn_len = sizeof(RSNIE2);
333 case Ndis802_11Encryption3Enabled:
335 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
337 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_CCMP, 4);
338 pRsnie_cipher->ucount = 1;
339 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
340 *rsn_len = sizeof(RSNIE2);
344 case Ndis802_11Encryption4Enabled:
345 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
348 // Insert WPA2 TKIP as the first pairwise cipher
349 if (MIX_CIPHER_WPA2_TKIP_ON(FlexibleCipher))
351 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
352 // Insert WPA2 AES as the secondary pairwise cipher
353 if (MIX_CIPHER_WPA2_AES_ON(FlexibleCipher))
355 NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA2_CCMP, 4);
361 // Insert WPA2 AES as the first pairwise cipher
362 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
365 pRsnie_cipher->ucount = PairwiseCnt;
366 *rsn_len = sizeof(RSNIE2) + (4 * (PairwiseCnt - 1));
370 // swap for big-endian platform
371 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
372 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
376 RSNIE *pRsnie_cipher = (RSNIE*)pRsnIe;
378 // Assign OUI and version
379 NdisMoveMemory(pRsnie_cipher->oui, OUI_WPA_VERSION, 4);
380 pRsnie_cipher->version = 1;
385 case Ndis802_11Encryption2Enabled:
386 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
387 pRsnie_cipher->ucount = 1;
388 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
389 *rsn_len = sizeof(RSNIE);
393 case Ndis802_11Encryption3Enabled:
395 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
397 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_CCMP, 4);
398 pRsnie_cipher->ucount = 1;
399 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
400 *rsn_len = sizeof(RSNIE);
404 case Ndis802_11Encryption4Enabled:
405 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
408 // Insert WPA TKIP as the first pairwise cipher
409 if (MIX_CIPHER_WPA_TKIP_ON(FlexibleCipher))
411 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
412 // Insert WPA AES as the secondary pairwise cipher
413 if (MIX_CIPHER_WPA_AES_ON(FlexibleCipher))
415 NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA_CCMP, 4);
421 // Insert WPA AES as the first pairwise cipher
422 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
425 pRsnie_cipher->ucount = PairwiseCnt;
426 *rsn_len = sizeof(RSNIE) + (4 * (PairwiseCnt - 1));
430 // swap for big-endian platform
431 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
432 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
438 ========================================================================
441 Build AKM suite in RSN-IE.
442 It only shall be called by RTMPMakeRSNIE.
445 pAd - pointer to our pAdapter context
446 ElementID - indicate the WPA1 or WPA2
447 AuthMode - indicate the authentication mode
448 apidx - indicate the interface index
454 ========================================================================
456 static VOID RTMPInsertRsnIeAKM(
457 IN PRTMP_ADAPTER pAd,
464 RSNIE_AUTH *pRsnie_auth;
466 pRsnie_auth = (RSNIE_AUTH*)(pRsnIe + (*rsn_len));
468 // decide WPA2 or WPA1
469 if (ElementID == Wpa2Ie)
473 case Ndis802_11AuthModeWPA2:
474 case Ndis802_11AuthModeWPA1WPA2:
475 pRsnie_auth->acount = 1;
476 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_8021X_AKM, 4);
479 case Ndis802_11AuthModeWPA2PSK:
480 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
481 pRsnie_auth->acount = 1;
482 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_PSK_AKM, 4);
490 case Ndis802_11AuthModeWPA:
491 case Ndis802_11AuthModeWPA1WPA2:
492 pRsnie_auth->acount = 1;
493 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_8021X_AKM, 4);
496 case Ndis802_11AuthModeWPAPSK:
497 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
498 pRsnie_auth->acount = 1;
499 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_PSK_AKM, 4);
502 case Ndis802_11AuthModeWPANone:
503 pRsnie_auth->acount = 1;
504 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_NONE_AKM, 4);
509 pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
511 (*rsn_len) += sizeof(RSNIE_AUTH); // update current RSNIE length
516 ========================================================================
519 Build capability in RSN-IE.
520 It only shall be called by RTMPMakeRSNIE.
523 pAd - pointer to our pAdapter context
524 ElementID - indicate the WPA1 or WPA2
525 apidx - indicate the interface index
531 ========================================================================
533 static VOID RTMPInsertRsnIeCap(
534 IN PRTMP_ADAPTER pAd,
540 RSN_CAPABILITIES *pRSN_Cap;
542 // it could be ignored in WPA1 mode
543 if (ElementID == WpaIe)
546 pRSN_Cap = (RSN_CAPABILITIES*)(pRsnIe + (*rsn_len));
549 pRSN_Cap->word = cpu2le16(pRSN_Cap->word);
551 (*rsn_len) += sizeof(RSN_CAPABILITIES); // update current RSNIE length
557 ========================================================================
560 Build RSN IE context. It is not included element-ID and length.
563 pAd - pointer to our pAdapter context
564 AuthMode - indicate the authentication mode
565 WepStatus - indicate the encryption type
566 apidx - indicate the interface index
572 ========================================================================
575 IN PRTMP_ADAPTER pAd,
580 PUCHAR pRsnIe = NULL; // primary RSNIE
581 UCHAR *rsnielen_cur_p = 0; // the length of the primary RSNIE
582 UCHAR *rsnielen_ex_cur_p = 0; // the length of the secondary RSNIE
584 BOOLEAN bMixCipher = FALSE; // indicate the pairwise and group cipher are different
586 WPA_MIX_PAIR_CIPHER FlexibleCipher = MIX_CIPHER_NOTUSE; // it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
588 rsnielen_cur_p = NULL;
589 rsnielen_ex_cur_p = NULL;
592 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
594 #ifdef WPA_SUPPLICANT_SUPPORT
595 if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
597 if (AuthMode < Ndis802_11AuthModeWPA)
601 #endif // WPA_SUPPLICANT_SUPPORT //
603 // Support WPAPSK or WPA2PSK in STA-Infra mode
604 // Support WPANone in STA-Adhoc mode
605 if ((AuthMode != Ndis802_11AuthModeWPAPSK) &&
606 (AuthMode != Ndis802_11AuthModeWPA2PSK) &&
607 (AuthMode != Ndis802_11AuthModeWPANone)
612 DBGPRINT(RT_DEBUG_TRACE,("==> RTMPMakeRSNIE(STA)\n"));
614 // Zero RSNIE context
615 pAd->StaCfg.RSNIE_Len = 0;
616 NdisZeroMemory(pAd->StaCfg.RSN_IE, MAX_LEN_OF_RSNIE);
619 rsnielen_cur_p = &pAd->StaCfg.RSNIE_Len;
620 pRsnIe = pAd->StaCfg.RSN_IE;
622 bMixCipher = pAd->StaCfg.bMixCipher;
626 // indicate primary RSNIE as WPA or WPA2
627 if ((AuthMode == Ndis802_11AuthModeWPA) ||
628 (AuthMode == Ndis802_11AuthModeWPAPSK) ||
629 (AuthMode == Ndis802_11AuthModeWPANone) ||
630 (AuthMode == Ndis802_11AuthModeWPA1WPA2) ||
631 (AuthMode == Ndis802_11AuthModeWPA1PSKWPA2PSK))
632 PrimaryRsnie = WpaIe;
634 PrimaryRsnie = Wpa2Ie;
637 // Build the primary RSNIE
638 // 1. insert cipher suite
639 RTMPInsertRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher, FlexibleCipher, pRsnIe, &p_offset);
642 RTMPInsertRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe, &p_offset);
644 // 3. insert capability
645 RTMPInsertRsnIeCap(pAd, PrimaryRsnie, apidx, pRsnIe, &p_offset);
648 // 4. update the RSNIE length
649 *rsnielen_cur_p = p_offset;
651 hex_dump("The primary RSNIE", pRsnIe, (*rsnielen_cur_p));
657 ==========================================================================
659 Check whether the received frame is EAP frame.
662 pAd - pointer to our pAdapter context
663 pEntry - pointer to active entry
664 pData - the received frame
665 DataByteCount - the received frame's length
666 FromWhichBSSID - indicate the interface index
669 TRUE - This frame is EAP frame
671 ==========================================================================
673 BOOLEAN RTMPCheckWPAframe(
674 IN PRTMP_ADAPTER pAd,
675 IN PMAC_TABLE_ENTRY pEntry,
677 IN ULONG DataByteCount,
678 IN UCHAR FromWhichBSSID)
684 if(DataByteCount < (LENGTH_802_1_H + LENGTH_EAPOL_H))
689 if (NdisEqualMemory(SNAP_802_1H, pData, 6) ||
690 // Cisco 1200 AP may send packet with SNAP_BRIDGE_TUNNEL
691 NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6))
695 // Skip 2-bytes EAPoL type
696 if (NdisEqualMemory(EAPOL, pData, 2))
706 Body_len = (*(pData+2)<<8) | (*(pData+3));
707 DBGPRINT(RT_DEBUG_TRACE, ("Receive EAP-Packet frame, TYPE = 0, Length = %ld\n", Body_len));
710 DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Start frame, TYPE = 1 \n"));
711 if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
713 DBGPRINT(RT_DEBUG_TRACE, ("Cancel the EnqueueEapolStartTimerRunning \n"));
714 RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
715 pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
719 DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLLogoff frame, TYPE = 2 \n"));
722 Body_len = (*(pData+2)<<8) | (*(pData+3));
723 DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Key frame, TYPE = 3, Length = %ld\n", Body_len));
726 DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLASFAlert frame, TYPE = 4 \n"));
737 ==========================================================================
739 ENCRYPT AES GTK before sending in EAPOL frame.
740 AES GTK length = 128 bit, so fix blocks for aes-key-wrap as 2 in this function.
741 This function references to RFC 3394 for aes key wrap algorithm.
743 ==========================================================================
745 VOID AES_GTK_KEY_WRAP(
749 OUT UCHAR *ciphertext)
751 UCHAR A[8], BIN[16], BOUT[16];
753 INT num_blocks = p_len/8; // unit:64bits
758 rtmp_aes_set_key(&aesctx, key, 128);
761 for (i = 0; i < 8; i++)
765 for (i = 0; i < num_blocks; i++)
767 for (j = 0 ; j < 8; j++)
768 R[8 * (i + 1) + j] = plaintext[8 * i + j];
772 for (j = 0; j < 6; j++)
774 for(i = 1; i <= num_blocks; i++)
777 NdisMoveMemory(BIN, A, 8);
778 NdisMoveMemory(&BIN[8], &R[8 * i], 8);
779 rtmp_aes_encrypt(&aesctx, BIN, BOUT);
781 NdisMoveMemory(A, &BOUT[0], 8);
782 xor = num_blocks * j + i;
783 A[7] = BOUT[7] ^ xor;
784 NdisMoveMemory(&R[8 * i], &BOUT[8], 8);
789 NdisMoveMemory(ciphertext, A, 8);
791 for (i = 1; i <= num_blocks; i++)
793 for (j = 0 ; j < 8; j++)
794 ciphertext[8 * i + j] = R[8 * i + j];
800 ========================================================================
803 Misc function to decrypt AES body
810 This function references to RFC 3394 for aes key unwrap algorithm.
812 ========================================================================
814 VOID AES_GTK_KEY_UNWRAP(
816 OUT UCHAR *plaintext,
818 IN UCHAR *ciphertext)
821 UCHAR A[8], BIN[16], BOUT[16];
826 INT num_blocks = c_len/8; // unit:64bits
829 os_alloc_mem(NULL, (PUCHAR *)&R, 512);
833 DBGPRINT(RT_DEBUG_ERROR, ("!!!AES_GTK_KEY_UNWRAP: no memory!!!\n"));
838 NdisMoveMemory(A, ciphertext, 8);
840 for(i = 0; i < (c_len-8); i++)
842 R[ i] = ciphertext[i + 8];
845 rtmp_aes_set_key(&aesctx, key, 128);
847 for(j = 5; j >= 0; j--)
849 for(i = (num_blocks-1); i > 0; i--)
851 xor = (num_blocks -1 )* j + i;
852 NdisMoveMemory(BIN, A, 8);
854 NdisMoveMemory(&BIN[8], &R[(i-1)*8], 8);
855 rtmp_aes_decrypt(&aesctx, BIN, BOUT);
856 NdisMoveMemory(A, &BOUT[0], 8);
857 NdisMoveMemory(&R[(i-1)*8], &BOUT[8], 8);
862 for(i = 0; i < c_len; i++)
868 os_free_mem(NULL, R);
872 ==========================================================================
874 Report the EAP message type
877 msg - EAPOL_PAIR_MSG_1
887 ==========================================================================
889 CHAR *GetEapolMsgType(CHAR msg)
891 if(msg == EAPOL_PAIR_MSG_1)
892 return "Pairwise Message 1";
893 else if(msg == EAPOL_PAIR_MSG_2)
894 return "Pairwise Message 2";
895 else if(msg == EAPOL_PAIR_MSG_3)
896 return "Pairwise Message 3";
897 else if(msg == EAPOL_PAIR_MSG_4)
898 return "Pairwise Message 4";
899 else if(msg == EAPOL_GROUP_MSG_1)
900 return "Group Message 1";
901 else if(msg == EAPOL_GROUP_MSG_2)
902 return "Group Message 2";
904 return "Invalid Message";
909 ========================================================================
912 Check Sanity RSN IE of EAPoL message
919 ========================================================================
921 BOOLEAN RTMPCheckRSNIE(
922 IN PRTMP_ADAPTER pAd,
925 IN MAC_TABLE_ENTRY *pEntry,
931 BOOLEAN result = FALSE;
937 while (len > sizeof(RSNIE2))
939 pEid = (PEID_STRUCT) pVIE;
941 if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
943 if ((pEntry->AuthMode == Ndis802_11AuthModeWPA || pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) &&
944 (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
945 (pEntry->RSNIE_Len == (pEid->Len + 2)))
950 *Offset += (pEid->Len + 2);
953 else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
955 if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2 || pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK) &&
956 (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
957 (pEntry->RSNIE_Len == (pEid->Len + 2))/* ToDo-AlbertY for mesh*/)
962 *Offset += (pEid->Len + 2);
969 pVIE += (pEid->Len + 2);
970 len -= (pEid->Len + 2);
980 ========================================================================
983 Parse KEYDATA field. KEYDATA[] May contain 2 RSN IE and optionally GTK.
984 GTK is encaptulated in KDE format at p.83 802.11i D10
993 ========================================================================
995 BOOLEAN RTMPParseEapolKeyData(
996 IN PRTMP_ADAPTER pAd,
999 IN UCHAR GroupKeyIndex,
1002 IN MAC_TABLE_ENTRY *pEntry)
1004 PKDE_ENCAP pKDE = NULL;
1005 PUCHAR pMyKeyData = pKeyData;
1006 UCHAR KeyDataLength = KeyDataLen;
1008 UCHAR DefaultIdx = 0;
1011 // Verify The RSN IE contained in pairewise_msg_2 && pairewise_msg_3 and skip it
1012 if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_3)
1014 // Check RSN IE whether it is WPA2/WPA2PSK
1015 if (!RTMPCheckRSNIE(pAd, pKeyData, KeyDataLen, pEntry, &skip_offset))
1017 // send wireless event - for RSN IE different
1018 if (pAd->CommonCfg.bWirelessEvent)
1019 RTMPSendWirelessEvent(pAd, IW_RSNIE_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
1021 DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in msg %d of 4-way handshake!\n", MsgType));
1022 hex_dump("Receive RSN_IE ", pKeyData, KeyDataLen);
1023 hex_dump("Desired RSN_IE ", pEntry->RSN_IE, pEntry->RSNIE_Len);
1029 if (bWPA2 && MsgType == EAPOL_PAIR_MSG_3)
1032 pMyKeyData += skip_offset;
1033 KeyDataLength -= skip_offset;
1034 DBGPRINT(RT_DEBUG_TRACE, ("RTMPParseEapolKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
1041 DBGPRINT(RT_DEBUG_TRACE,("RTMPParseEapolKeyData ==> KeyDataLength %d without RSN_IE \n", KeyDataLength));
1043 // Parse EKD format in pairwise_msg_3_WPA2 && group_msg_1_WPA2
1044 if (bWPA2 && (MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1))
1046 if (KeyDataLength >= 8) // KDE format exclude GTK length
1048 pKDE = (PKDE_ENCAP) pMyKeyData;
1051 DefaultIdx = pKDE->GTKEncap.Kid;
1053 // Sanity check - KED length
1054 if (KeyDataLength < (pKDE->Len + 2))
1056 DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
1060 // Get GTK length - refer to IEEE 802.11i-2004 p.82
1061 GTKLEN = pKDE->Len -6;
1062 if (GTKLEN < LEN_AES_KEY)
1064 DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
1071 DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KDE format length is too short \n"));
1075 DBGPRINT(RT_DEBUG_TRACE, ("GTK in KDE format ,DefaultKeyID=%d, KeyLen=%d \n", DefaultIdx, GTKLEN));
1081 else if (!bWPA2 && MsgType == EAPOL_GROUP_MSG_1)
1083 DefaultIdx = GroupKeyIndex;
1084 DBGPRINT(RT_DEBUG_TRACE, ("GTK DefaultKeyID=%d \n", DefaultIdx));
1087 // Sanity check - shared key index must be 1 ~ 3
1088 if (DefaultIdx < 1 || DefaultIdx > 3)
1090 DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index(%d) is invalid in %s %s \n", DefaultIdx, ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
1100 ========================================================================
1102 Routine Description:
1103 Construct EAPoL message for WPA handshaking
1104 Its format is below,
1106 +--------------------+
1107 | Protocol Version | 1 octet
1108 +--------------------+
1109 | Protocol Type | 1 octet
1110 +--------------------+
1111 | Body Length | 2 octets
1112 +--------------------+
1113 | Descriptor Type | 1 octet
1114 +--------------------+
1115 | Key Information | 2 octets
1116 +--------------------+
1117 | Key Length | 1 octet
1118 +--------------------+
1119 | Key Repaly Counter | 8 octets
1120 +--------------------+
1121 | Key Nonce | 32 octets
1122 +--------------------+
1123 | Key IV | 16 octets
1124 +--------------------+
1125 | Key RSC | 8 octets
1126 +--------------------+
1127 | Key ID or Reserved | 8 octets
1128 +--------------------+
1129 | Key MIC | 16 octets
1130 +--------------------+
1131 | Key Data Length | 2 octets
1132 +--------------------+
1133 | Key Data | n octets
1134 +--------------------+
1138 pAd Pointer to our adapter
1145 ========================================================================
1147 VOID ConstructEapolMsg(
1148 IN PRTMP_ADAPTER pAd,
1151 IN UCHAR GroupKeyWepStatus,
1153 IN UCHAR DefaultKeyIdx,
1154 IN UCHAR *ReplayCounter,
1161 OUT PEAPOL_PACKET pMsg)
1163 BOOLEAN bWPA2 = FALSE;
1165 // Choose WPA2 or not
1166 if ((AuthMode == Ndis802_11AuthModeWPA2) || (AuthMode == Ndis802_11AuthModeWPA2PSK))
1169 // Init Packet and Fill header
1170 pMsg->ProVer = EAPOL_VER;
1171 pMsg->ProType = EAPOLKey;
1173 // Default 95 bytes, the EAPoL-Key descriptor exclude Key-data field
1174 pMsg->Body_Len[1] = LEN_EAPOL_KEY_MSG;
1176 // Fill in EAPoL descriptor
1178 pMsg->KeyDesc.Type = WPA2_KEY_DESC;
1180 pMsg->KeyDesc.Type = WPA1_KEY_DESC;
1182 // Fill in Key information, refer to IEEE Std 802.11i-2004 page 78
1183 // When either the pairwise or the group cipher is AES, the DESC_TYPE_AES(2) shall be used.
1184 pMsg->KeyDesc.KeyInfo.KeyDescVer =
1185 (((WepStatus == Ndis802_11Encryption3Enabled) || (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
1187 // Specify Key Type as Group(0) or Pairwise(1)
1188 if (MsgType >= EAPOL_GROUP_MSG_1)
1189 pMsg->KeyDesc.KeyInfo.KeyType = GROUPKEY;
1191 pMsg->KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
1193 // Specify Key Index, only group_msg1_WPA1
1194 if (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))
1195 pMsg->KeyDesc.KeyInfo.KeyIndex = DefaultKeyIdx;
1197 if (MsgType == EAPOL_PAIR_MSG_3)
1198 pMsg->KeyDesc.KeyInfo.Install = 1;
1200 if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1))
1201 pMsg->KeyDesc.KeyInfo.KeyAck = 1;
1203 if (MsgType != EAPOL_PAIR_MSG_1)
1204 pMsg->KeyDesc.KeyInfo.KeyMic = 1;
1206 if ((bWPA2 && (MsgType >= EAPOL_PAIR_MSG_3)) || (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1)))
1208 pMsg->KeyDesc.KeyInfo.Secure = 1;
1211 if (bWPA2 && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
1213 pMsg->KeyDesc.KeyInfo.EKD_DL = 1;
1216 // key Information element has done.
1217 *(USHORT *)(&pMsg->KeyDesc.KeyInfo) = cpu2le16(*(USHORT *)(&pMsg->KeyDesc.KeyInfo));
1219 // Fill in Key Length
1221 if (MsgType >= EAPOL_GROUP_MSG_1)
1223 // the length of group key cipher
1224 pMsg->KeyDesc.KeyLength[1] = ((GroupKeyWepStatus == Ndis802_11Encryption2Enabled) ? TKIP_GTK_LENGTH : LEN_AES_KEY);
1228 // the length of pairwise key cipher
1229 pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
1233 // Fill in replay counter
1234 NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, ReplayCounter, LEN_KEY_DESC_REPLAY);
1236 // Fill Key Nonce field
1237 // ANonce : pairwise_msg1 & pairwise_msg3
1238 // SNonce : pairwise_msg2
1239 // GNonce : group_msg1_wpa1
1240 if ((MsgType <= EAPOL_PAIR_MSG_3) || ((!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))))
1241 NdisMoveMemory(pMsg->KeyDesc.KeyNonce, KeyNonce, LEN_KEY_DESC_NONCE);
1243 // Fill key IV - WPA2 as 0, WPA1 as random
1244 if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
1246 // Suggest IV be random number plus some number,
1247 NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16], LEN_KEY_DESC_IV);
1248 pMsg->KeyDesc.KeyIv[15] += 2;
1251 // Fill Key RSC field
1252 // It contains the RSC for the GTK being installed.
1253 if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
1255 NdisMoveMemory(pMsg->KeyDesc.KeyRsc, TxRSC, 6);
1258 // Clear Key MIC field for MIC calculation later
1259 NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
1261 ConstructEapolKeyData(pAd,
1274 // Calculate MIC and fill in KeyMic Field except Pairwise Msg 1.
1275 if (MsgType != EAPOL_PAIR_MSG_1)
1277 CalculateMIC(pAd, WepStatus, PTK, pMsg);
1280 DBGPRINT(RT_DEBUG_TRACE, ("===> ConstructEapolMsg for %s %s\n", ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
1281 DBGPRINT(RT_DEBUG_TRACE, (" Body length = %d \n", pMsg->Body_Len[1]));
1282 DBGPRINT(RT_DEBUG_TRACE, (" Key length = %d \n", pMsg->KeyDesc.KeyLength[1]));
1288 ========================================================================
1290 Routine Description:
1291 Construct the Key Data field of EAPoL message
1294 pAd Pointer to our adapter
1302 ========================================================================
1304 VOID ConstructEapolKeyData(
1305 IN PRTMP_ADAPTER pAd,
1308 IN UCHAR GroupKeyWepStatus,
1310 IN UCHAR DefaultKeyIdx,
1311 IN BOOLEAN bWPA2Capable,
1316 OUT PEAPOL_PACKET pMsg)
1318 UCHAR *mpool, *Key_Data, *Rc4GTK;
1319 UCHAR ekey[(LEN_KEY_DESC_IV+LEN_EAP_EK)];
1323 if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)
1326 // allocate memory pool
1327 os_alloc_mem(pAd, (PUCHAR *)&mpool, 1500);
1332 /* Rc4GTK Len = 512 */
1333 Rc4GTK = (UCHAR *) ROUND_UP(mpool, 4);
1334 /* Key_Data Len = 512 */
1335 Key_Data = (UCHAR *) ROUND_UP(Rc4GTK + 512, 4);
1337 NdisZeroMemory(Key_Data, 512);
1338 pMsg->KeyDesc.KeyDataLen[1] = 0;
1341 // Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3
1342 if (RSNIE_LEN && ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3)))
1345 Key_Data[data_offset + 0] = IE_WPA2;
1347 Key_Data[data_offset + 0] = IE_WPA;
1349 Key_Data[data_offset + 1] = RSNIE_LEN;
1350 NdisMoveMemory(&Key_Data[data_offset + 2], RSNIE, RSNIE_LEN);
1351 data_offset += (2 + RSNIE_LEN);
1354 // Encapsulate KDE format in pairwise_msg3_WPA2 & group_msg1_WPA2
1355 if (bWPA2Capable && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
1357 // Key Data Encapsulation (KDE) format - 802.11i-2004 Figure-43w and Table-20h
1358 Key_Data[data_offset + 0] = 0xDD;
1360 if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
1362 Key_Data[data_offset + 1] = 0x16;// 4+2+16(OUI+DataType+DataField)
1366 Key_Data[data_offset + 1] = 0x26;// 4+2+32(OUI+DataType+DataField)
1369 Key_Data[data_offset + 2] = 0x00;
1370 Key_Data[data_offset + 3] = 0x0F;
1371 Key_Data[data_offset + 4] = 0xAC;
1372 Key_Data[data_offset + 5] = 0x01;
1374 // GTK KDE format - 802.11i-2004 Figure-43x
1375 Key_Data[data_offset + 6] = (DefaultKeyIdx & 0x03);
1376 Key_Data[data_offset + 7] = 0x00; // Reserved Byte
1382 // Encapsulate GTK and encrypt the key-data field with KEK.
1383 // Only for pairwise_msg3_WPA2 and group_msg1
1384 if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable) || (MsgType == EAPOL_GROUP_MSG_1))
1387 if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
1389 NdisMoveMemory(&Key_Data[data_offset], GTK, LEN_AES_KEY);
1390 data_offset += LEN_AES_KEY;
1394 NdisMoveMemory(&Key_Data[data_offset], GTK, TKIP_GTK_LENGTH);
1395 data_offset += TKIP_GTK_LENGTH;
1398 // Still dont know why, but if not append will occur "GTK not include in MSG3"
1399 // Patch for compatibility between zero config and funk
1400 if (MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable)
1402 if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
1404 Key_Data[data_offset + 0] = 0xDD;
1405 Key_Data[data_offset + 1] = 0;
1410 Key_Data[data_offset + 0] = 0xDD;
1411 Key_Data[data_offset + 1] = 0;
1412 Key_Data[data_offset + 2] = 0;
1413 Key_Data[data_offset + 3] = 0;
1414 Key_Data[data_offset + 4] = 0;
1415 Key_Data[data_offset + 5] = 0;
1420 // Encrypt the data material in key data field
1421 if (WepStatus == Ndis802_11Encryption3Enabled)
1423 AES_GTK_KEY_WRAP(&PTK[16], Key_Data, data_offset, Rc4GTK);
1424 // AES wrap function will grow 8 bytes in length
1429 // PREPARE Encrypted "Key DATA" field. (Encrypt GTK with RC4, usinf PTK[16]->[31] as Key, IV-field as IV)
1430 // put TxTsc in Key RSC field
1431 pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
1433 // ekey is the contanetion of IV-field, and PTK[16]->PTK[31]
1434 NdisMoveMemory(ekey, pMsg->KeyDesc.KeyIv, LEN_KEY_DESC_IV);
1435 NdisMoveMemory(&ekey[LEN_KEY_DESC_IV], &PTK[16], LEN_EAP_EK);
1436 ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, ekey, sizeof(ekey)); //INIT SBOX, KEYLEN+3(IV)
1437 pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, Key_Data, data_offset);
1438 WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK, Key_Data, data_offset);
1441 NdisMoveMemory(pMsg->KeyDesc.KeyData, Rc4GTK, data_offset);
1445 NdisMoveMemory(pMsg->KeyDesc.KeyData, Key_Data, data_offset);
1448 // set key data length field and total length
1449 pMsg->KeyDesc.KeyDataLen[1] = data_offset;
1450 pMsg->Body_Len[1] += data_offset;
1452 os_free_mem(pAd, mpool);
1457 ========================================================================
1459 Routine Description:
1460 Calcaulate MIC. It is used during 4-ways handsharking.
1463 pAd - pointer to our pAdapter context
1464 PeerWepStatus - indicate the encryption type
1470 ========================================================================
1473 IN PRTMP_ADAPTER pAd,
1474 IN UCHAR PeerWepStatus,
1476 OUT PEAPOL_PACKET pMsg)
1480 UCHAR mic[LEN_KEY_DESC_MIC];
1483 // allocate memory for MIC calculation
1484 os_alloc_mem(pAd, (PUCHAR *)&OutBuffer, 512);
1486 if (OutBuffer == NULL)
1488 DBGPRINT(RT_DEBUG_ERROR, ("!!!CalculateMIC: no memory!!!\n"));
1492 // make a frame for calculating MIC.
1493 MakeOutgoingFrame(OutBuffer, &FrameLen,
1494 pMsg->Body_Len[1] + 4, pMsg,
1497 NdisZeroMemory(mic, sizeof(mic));
1500 if (PeerWepStatus == Ndis802_11Encryption3Enabled)
1502 HMAC_SHA1(OutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
1503 NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
1507 hmac_md5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, mic);
1510 // store the calculated MIC
1511 NdisMoveMemory(pMsg->KeyDesc.KeyMic, mic, LEN_KEY_DESC_MIC);
1513 os_free_mem(pAd, OutBuffer);
1517 ========================================================================
1519 Routine Description:
1520 Some received frames can't decrypt by Asic, so decrypt them by software.
1523 pAd - pointer to our pAdapter context
1524 PeerWepStatus - indicate the encryption type
1527 NDIS_STATUS_SUCCESS - decryption successful
1528 NDIS_STATUS_FAILURE - decryption failure
1530 ========================================================================
1532 NDIS_STATUS RTMPSoftDecryptBroadCastData(
1533 IN PRTMP_ADAPTER pAd,
1535 IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
1536 IN PCIPHER_KEY pShard_key)
1538 PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
1542 // handle WEP decryption
1543 if (GroupCipher == Ndis802_11Encryption1Enabled)
1545 if (RTMPSoftDecryptWEP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, pShard_key))
1548 //Minus IV[4] & ICV[4]
1549 pRxWI->MPDUtotalByteCount -= 8;
1553 DBGPRINT(RT_DEBUG_ERROR, ("ERROR : Software decrypt WEP data fails.\n"));
1554 // give up this frame
1555 return NDIS_STATUS_FAILURE;
1558 // handle TKIP decryption
1559 else if (GroupCipher == Ndis802_11Encryption2Enabled)
1561 if (RTMPSoftDecryptTKIP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, 0, pShard_key))
1564 //Minus 8 bytes MIC, 8 bytes IV/EIV, 4 bytes ICV
1565 pRxWI->MPDUtotalByteCount -= 20;
1569 DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptTKIP Failed\n"));
1570 // give up this frame
1571 return NDIS_STATUS_FAILURE;
1574 // handle AES decryption
1575 else if (GroupCipher == Ndis802_11Encryption3Enabled)
1577 if (RTMPSoftDecryptAES(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount , pShard_key))
1580 //8 bytes MIC, 8 bytes IV/EIV (CCMP Header)
1581 pRxWI->MPDUtotalByteCount -= 16;
1585 DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptAES Failed\n"));
1586 // give up this frame
1587 return NDIS_STATUS_FAILURE;
1592 // give up this frame
1593 return NDIS_STATUS_FAILURE;
1596 return NDIS_STATUS_SUCCESS;