prwskey=pattrib->dot118021x_UncstKey.skey;
}
-#ifdef CONFIG_TDLS //swencryption
+#ifdef CONFIG_TDLS
{
+ /* Swencryption */
struct sta_info *ptdls_sta;
ptdls_sta=rtw_get_stainfo(&padapter->stapriv ,&pattrib->dst[0] );
if((ptdls_sta != NULL) && (ptdls_sta->tdls_sta_state & TDLS_LINKED_STATE) )
* added by the KDF anyway..
*/
- if (os_memcmp(myid(&(padapter->eeprompriv)), psta->hwaddr, ETH_ALEN) < 0) {
- _rtw_memcpy(data, myid(&(padapter->eeprompriv)), ETH_ALEN);
+ if (os_memcmp(adapter_mac_addr(padapter), psta->hwaddr, ETH_ALEN) < 0) {
+ _rtw_memcpy(data, adapter_mac_addr(padapter), ETH_ALEN);
_rtw_memcpy(data + ETH_ALEN, psta->hwaddr, ETH_ALEN);
} else {
_rtw_memcpy(data, psta->hwaddr, ETH_ALEN);
- _rtw_memcpy(data + ETH_ALEN, myid(&(padapter->eeprompriv)), ETH_ALEN);
+ _rtw_memcpy(data + ETH_ALEN, adapter_mac_addr(padapter), ETH_ALEN);
}
_rtw_memcpy(data + 2 * ETH_ALEN, get_bssid(pmlmepriv), ETH_ALEN);
}
+/**
+ * wpa_tdls_teardown_ftie_mic - Calculate TDLS TEARDOWN FTIE MIC
+ * @kck: TPK-KCK
+ * @lnkid: Pointer to the beginning of Link Identifier IE
+ * @reason: Reason code of TDLS Teardown
+ * @dialog_token: Dialog token that was used in the MIC calculation for TPK Handshake Message 3
+ * @trans_seq: Transaction Sequence number (1 octet) which shall be set to the value 4
+ * @ftie: Pointer to the beginning of FT IE
+ * @mic: Pointer for writing MIC
+ *
+ * Calculate MIC for TDLS TEARDOWN frame according to Section 10.22.5 in IEEE 802.11 - 2012.
+ */
+int wpa_tdls_teardown_ftie_mic(u8 *kck, u8 *lnkid, u16 reason,
+ u8 dialog_token, u8 trans_seq, u8 *ftie, u8 *mic)
+{
+ u8 *buf, *pos;
+ struct wpa_tdls_ftie *_ftie;
+ int ret;
+ int len = 2 + lnkid[1] + 2 + 1 + 1 + 2 + ftie[1];
+
+ buf = rtw_zmalloc(len);
+ if (!buf) {
+ DBG_871X("TDLS: No memory for MIC calculation\n");
+ return -1;
+ }
+
+ pos = buf;
+ /* 1) Link Identifier IE */
+ _rtw_memcpy(pos, lnkid, 2 + lnkid[1]);
+ pos += 2 + lnkid[1];
+ /* 2) Reason Code */
+ _rtw_memcpy(pos, (u8 *)&reason, 2);
+ pos += 2;
+ /* 3) Dialog Token */
+ *pos++ = dialog_token;
+ /* 4) Transaction Sequence number */
+ *pos++ = trans_seq;
+ /* 5) FTIE, with the MIC field of the FTIE set to 0 */
+ _rtw_memcpy(pos, ftie, 2 + ftie[1]);
+ _ftie = (struct wpa_tdls_ftie *) pos;
+ _rtw_memset(_ftie->mic, 0, TDLS_MIC_LEN);
+ pos += 2 + ftie[1];
+
+ ret = omac1_aes_128(kck, buf, pos - buf, mic);
+ rtw_mfree(buf, len);
+ return ret;
+
+}
+
int tdls_verify_mic(u8 *kck, u8 trans_seq,
u8 *lnkid, u8 *rsnie, u8 *timeoutie, u8 *ftie)
{
if (lnkid == NULL || rsnie == NULL ||
timeoutie == NULL || ftie == NULL){
- return 0;
+ return _FAIL;
}
len = 2 * ETH_ALEN + 1 + 2 + 18 + 2 + *(rsnie+1) + 2 + *(timeoutie+1) + 2 + *(ftie+1);
buf = rtw_zmalloc(len);
if (buf == NULL)
- return 0;
+ return _FAIL;
pos = buf;
/* 1) TDLS initiator STA MAC address */
ret = omac1_aes_128(kck, buf, pos - buf, mic);
rtw_mfree(buf, len);
if (ret)
- return 0;
+ return _FAIL;
rx_ftie = ftie+4;
if (os_memcmp(mic, rx_ftie, 16) == 0) {
//Valid MIC
- return 1;
+ return _SUCCESS;
}
//Invalid MIC
DBG_871X( "[%s] Invalid MIC\n", __FUNCTION__);
- return 0;
+ return _FAIL;
}
#endif //CONFIG_TDLS