aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8712/rtl871x_security.h
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2010-08-20 11:15:30 -0400
committerLarry Finger <Larry.Finger@lwfinger.net>2010-08-20 11:15:30 -0400
commit2865d42c78a9121caad52cb02d1fbb7f5cdbc4ef (patch)
tree430b79f753b0e1cec6379b9a4208a716c914ac65 /drivers/staging/rtl8712/rtl871x_security.h
parent763008c4357b73c8d18396dfd8d79dc58fa3f99d (diff)
staging: r8712u: Add the new driver to the mainline kernel
This code is for a completely new version of the Realtek 8192 USB devices such as the D-Link DWA-130. The Realtek code, which was originally for Linux, Windows XP and Windows CE, has been stripped of all code not needed for Linux. In addition, only one additional configuration variable, which enables AP mode, remains. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Florian Schilhabel <florian.c.schilhabel@googlemail.com> Tested-by: Frederic Leroy <fredo@starox.org>
Diffstat (limited to 'drivers/staging/rtl8712/rtl871x_security.h')
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.h196
1 files changed, 196 insertions, 0 deletions
diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h
new file mode 100644
index 00000000000..782b70a352f
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_security.h
@@ -0,0 +1,196 @@
1#ifndef __RTL871X_SECURITY_H_
2#define __RTL871X_SECURITY_H_
3
4#include "osdep_service.h"
5#include "drv_types.h"
6
7#define _NO_PRIVACY_ 0x0
8#define _WEP40_ 0x1
9#define _TKIP_ 0x2
10#define _TKIP_WTMIC_ 0x3
11#define _AES_ 0x4
12#define _WEP104_ 0x5
13
14#define _WPA_IE_ID_ 0xdd
15#define _WPA2_IE_ID_ 0x30
16
17#ifndef Ndis802_11AuthModeWPA2
18#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
19#endif
20
21#ifndef Ndis802_11AuthModeWPA2PSK
22#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
23#endif
24union pn48 {
25 u64 val;
26#if defined(__BIG_ENDIAN)
27struct {
28 u8 TSC7;
29 u8 TSC6;
30 u8 TSC5;
31 u8 TSC4;
32 u8 TSC3;
33 u8 TSC2;
34 u8 TSC1;
35 u8 TSC0;
36} _byte_;
37#else
38struct {
39 u8 TSC0;
40 u8 TSC1;
41 u8 TSC2;
42 u8 TSC3;
43 u8 TSC4;
44 u8 TSC5;
45 u8 TSC6;
46 u8 TSC7;
47} _byte_;
48#endif
49};
50
51union Keytype {
52 u8 skey[16];
53 u32 lkey[4];
54};
55
56struct RT_PMKID_LIST {
57 u8 bUsed;
58 u8 Bssid[6];
59 u8 PMKID[16];
60 u8 SsidBuf[33];
61 u8 *ssid_octet;
62 u16 ssid_length;
63};
64
65struct 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
69 * auth. algorithm. */
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 */
73 u32 DefKeylen[4];
74 u32 XGrpPrivacy; /* This specify the privacy algthm.
75 * used for Grp key */
76 u32 XGrpKeyid; /* key id used for Grp Key */
77 union Keytype XGrpKey[2]; /* 802.1x Group Key, for
78 * inx0 and inx1 */
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];
86 int wps_ie_len;
87 u8 binstallGrpkey;
88 u8 busetkipkey;
89 struct timer_list tkip_timer;
90 u8 bcheck_grpkey;
91 u8 bgrpkey_handshake;
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;
101 u8 assoc_info[600];
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];
115 u8 PMKIDIndex;
116};
117
118#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \
119do { \
120 switch (psecuritypriv->AuthAlgrthm) { \
121 case 0: \
122 case 1: \
123 case 3: \
124 encry_algo = (u8)psecuritypriv->PrivacyAlgrthm; \
125 break; \
126 case 2: \
127 if (bmcst) \
128 encry_algo = (u8)psecuritypriv->XGrpPrivacy; \
129 else \
130 encry_algo = (u8)psta->XPrivacy; \
131 break; \
132 } \
133} while (0)
134#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)\
135do {\
136 switch (encrypt) { \
137 case _WEP40_: \
138 case _WEP104_: \
139 iv_len = 4; \
140 icv_len = 4; \
141 break; \
142 case _TKIP_: \
143 iv_len = 8; \
144 icv_len = 4; \
145 break; \
146 case _AES_: \
147 iv_len = 8; \
148 icv_len = 8; \
149 break; \
150 default: \
151 iv_len = 0; \
152 icv_len = 0; \
153 break; \
154 } \
155} while (0)
156#define GET_TKIP_PN(iv, txpn) \
157do {\
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];\
164} while (0)
165
166#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
167#define ROR32(A, n) ROL32((A), 32 - (n))
168
169struct mic_data {
170 u32 K0, K1; /* Key */
171 u32 L, R; /* Current state */
172 u32 M; /* Message accumulator (single word) */
173 u32 nBytesInM; /* # bytes in M */
174};
175
176void seccalctkipmic(
177 u8 *key,
178 u8 *header,
179 u8 *data,
180 u32 data_len,
181 u8 *Miccode,
182 u8 priority);
183
184void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
185void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes);
186void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst);
187u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe);
188u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe);
189void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe);
190u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe);
191u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe);
192void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe);
193void r8712_use_tkipkey_handler(void *FunctionContext);
194
195#endif /*__RTL871X_SECURITY_H_ */
196