1 #ifndef __RTL871X_SECURITY_H_
2 #define __RTL871X_SECURITY_H_
4 #include "osdep_service.h"
7 #define _NO_PRIVACY_ 0x0
10 #define _TKIP_WTMIC_ 0x3
14 #define _WPA_IE_ID_ 0xdd
15 #define _WPA2_IE_ID_ 0x30
17 #ifndef Ndis802_11AuthModeWPA2
18 #define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
21 #ifndef Ndis802_11AuthModeWPA2PSK
22 #define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
26 #if defined(__BIG_ENDIAN)
56 struct RT_PMKID_LIST {
65 struct security_priv {
66 u32 AuthAlgrthm; /* 802.11 auth, could be open, shared,
67 * 8021x and authswitch */
68 u32 PrivacyAlgrthm; /* This specify the privacy for shared
70 u32 PrivacyKeyIndex; /* this is only valid for legendary
71 * wep, 0~3 for key id. */
72 union Keytype DefKey[4]; /* this is only valid for def. key */
74 u32 XGrpPrivacy; /* This specify the privacy algthm.
76 u32 XGrpKeyid; /* key id used for Grp Key */
77 union Keytype XGrpKey[2]; /* 802.1x Group Key, for
79 union Keytype XGrptxmickey[2];
80 union Keytype XGrprxmickey[2];
81 union pn48 Grptxpn; /* PN48 used for Grp Key xmit. */
82 union pn48 Grprxpn; /* PN48 used for Grp Key recv. */
83 u8 wps_hw_pbc_pressed;/*for hw pbc pressed*/
84 u8 wps_phase;/*for wps*/
85 u8 wps_ie[MAX_WPA_IE_LEN<<2];
89 struct timer_list tkip_timer;
92 s32 sw_encrypt; /* from registry_priv */
93 s32 sw_decrypt; /* from registry_priv */
94 s32 hw_decrypted; /* if the rx packets is hw_decrypted==false,
95 * it means the hw has not been ready. */
96 u32 ndisauthtype; /* keeps the auth_type & enc_status from upper
97 * layer ioctl(wpa_supplicant or wzc) */
98 u32 ndisencryptstatus;
99 struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
100 struct NDIS_802_11_WEP ndiswep;
102 u8 szofcapability[256]; /* for wpa2 usage */
103 u8 oidassociation[512]; /* for wpa/wpa2 usage */
104 u8 authenticator_ie[256]; /* store ap security information element */
105 u8 supplicant_ie[256]; /* store sta security information element */
106 /* for tkip countermeasure */
107 u32 last_mic_err_time;
108 u8 btkip_countermeasure;
109 u8 btkip_wait_report;
110 u32 btkip_countermeasure_time;
111 /*-------------------------------------------------------------------
112 * For WPA2 Pre-Authentication.
113 *------------------------------------------------------------------ */
114 struct RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
118 #define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \
120 switch (psecuritypriv->AuthAlgrthm) { \
124 encry_algo = (u8)psecuritypriv->PrivacyAlgrthm; \
128 encry_algo = (u8)psecuritypriv->XGrpPrivacy; \
130 encry_algo = (u8)psta->XPrivacy; \
134 #define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)\
156 #define GET_TKIP_PN(iv, txpn) \
158 txpn._byte_.TSC0 = iv[2];\
159 txpn._byte_.TSC1 = iv[0];\
160 txpn._byte_.TSC2 = iv[4];\
161 txpn._byte_.TSC3 = iv[5];\
162 txpn._byte_.TSC4 = iv[6];\
163 txpn._byte_.TSC5 = iv[7];\
166 #define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
167 #define ROR32(A, n) ROL32((A), 32 - (n))
170 u32 K0, K1; /* Key */
171 u32 L, R; /* Current state */
172 u32 M; /* Message accumulator (single word) */
173 u32 nBytesInM; /* # bytes in M */
184 void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
185 void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes);
186 void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst);
187 u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe);
188 u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe);
189 void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe);
190 u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe);
191 u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe);
192 void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe);
193 void r8712_use_tkipkey_handler(void *FunctionContext);
195 #endif /*__RTL871X_SECURITY_H_ */