aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-08-12 19:50:57 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:02:32 -0400
commitcbe892f6772145f160b89ef5fd4759a8dc7bf6c6 (patch)
treec2a8226b720b1b3f6a3701fc21f98fb149e3642b
parent96ed5846c4eeb29934b789e6d83e35a8d498778f (diff)
Staging: rtl8192e: remove unneeded ieee80211 files
These files are not even built or used, so just remove them. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/rtl8192e/ieee80211/EndianFree.h199
-rw-r--r--drivers/staging/rtl8192e/ieee80211/aes.c469
-rw-r--r--drivers/staging/rtl8192e/ieee80211/api.c246
-rw-r--r--drivers/staging/rtl8192e/ieee80211/arc4.c103
-rw-r--r--drivers/staging/rtl8192e/ieee80211/autoload.c40
-rw-r--r--drivers/staging/rtl8192e/ieee80211/cipher.c299
-rw-r--r--drivers/staging/rtl8192e/ieee80211/compress.c64
-rw-r--r--drivers/staging/rtl8192e/ieee80211/crypto_compat.h90
-rw-r--r--drivers/staging/rtl8192e/ieee80211/digest.c108
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c3
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c4
-rw-r--r--drivers/staging/rtl8192e/ieee80211/internal.h115
-rw-r--r--drivers/staging/rtl8192e/ieee80211/kmap_types.h20
-rw-r--r--drivers/staging/rtl8192e/ieee80211/michael_mic.c194
-rw-r--r--drivers/staging/rtl8192e/ieee80211/proc.c116
-rw-r--r--drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h1
-rw-r--r--drivers/staging/rtl8192e/ieee80211/scatterwalk.c126
-rw-r--r--drivers/staging/rtl8192e/ieee80211/scatterwalk.h51
18 files changed, 0 insertions, 2248 deletions
diff --git a/drivers/staging/rtl8192e/ieee80211/EndianFree.h b/drivers/staging/rtl8192e/ieee80211/EndianFree.h
deleted file mode 100644
index 0c417a6234a9..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/EndianFree.h
+++ /dev/null
@@ -1,199 +0,0 @@
1#ifndef __INC_ENDIANFREE_H
2#define __INC_ENDIANFREE_H
3
4/*
5 * Call endian free function when
6 * 1. Read/write packet content.
7 * 2. Before write integer to IO.
8 * 3. After read integer from IO.
9 */
10#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
11#ifndef bool
12typedef enum{false = 0, true} bool;
13#endif
14#endif
15
16#define __MACHINE_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
17#define __MACHINE_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net, ppc */
18
19#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN
20
21#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
22// Convert data
23#define EF1Byte(_val) ((u8)(_val))
24#define EF2Byte(_val) ((u16)(_val))
25#define EF4Byte(_val) ((u32)(_val))
26
27#else
28// Convert data
29#define EF1Byte(_val) ((u8)(_val))
30#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8))
31#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\
32 ((((u32)(_val))&0x0000ff00)<<8)|\
33 ((((u32)(_val))&0x00ff0000)>>8)|\
34 ((((u32)(_val))&0xff000000)>>24))
35#endif
36
37// Read data from memory
38#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
39#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
40#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
41
42// Write data to memory
43#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
44#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
45#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
46// Convert Host system specific byte ording (litten or big endia) to Network byte ording (big endian).
47// 2006.05.07, by rcnjko.
48#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
49#define H2N1BYTE(_val) ((u8)(_val))
50#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
51 ((((u16)(_val))&0xff00)>>8))
52#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
53 ((((u32)(_val))&0x0000ff00)<<8) |\
54 ((((u32)(_val))&0x00ff0000)>>8) |\
55 ((((u32)(_val))&0xff000000)>>24))
56#else
57#define H2N1BYTE(_val) ((u8)(_val))
58#define H2N2BYTE(_val) ((u16)(_val))
59#define H2N4BYTE(_val) ((u32)(_val))
60#endif
61
62// Convert from Network byte ording (big endian) to Host system specific byte ording (litten or big endia).
63// 2006.05.07, by rcnjko.
64#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
65#define N2H1BYTE(_val) ((u8)(_val))
66#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
67 ((((u16)(_val))&0xff00)>>8))
68#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
69 ((((u32)(_val))&0x0000ff00)<<8) |\
70 ((((u32)(_val))&0x00ff0000)>>8) |\
71 ((((u32)(_val))&0xff000000)>>24))
72#else
73#define N2H1BYTE(_val) ((u8)(_val))
74#define N2H2BYTE(_val) ((u16)(_val))
75#define N2H4BYTE(_val) ((u32)(_val))
76#endif
77
78//
79// Example:
80// BIT_LEN_MASK_32(0) => 0x00000000
81// BIT_LEN_MASK_32(1) => 0x00000001
82// BIT_LEN_MASK_32(2) => 0x00000003
83// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
84//
85#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen)))
86//
87// Example:
88// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
89// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
90//
91#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
92
93//
94// Description:
95// Return 4-byte value in host byte ordering from
96// 4-byte pointer in litten-endian system.
97//
98#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart))))
99
100//
101// Description:
102// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
103// 4-byte value in host byte ordering.
104//
105#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
106 ( \
107 ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
108 & \
109 BIT_LEN_MASK_32(__BitLen) \
110 )
111
112//
113// Description:
114// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
115// and return the result in 4-byte value in host byte ordering.
116//
117#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
118 ( \
119 LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
120 & \
121 ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
122 )
123
124//
125// Description:
126// Set subfield of little-endian 4-byte value to specified value.
127//
128#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
129 *((u32 *)(__pStart)) = \
130 EF4Byte( \
131 LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
132 | \
133 ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
134 );
135
136
137#define BIT_LEN_MASK_16(__BitLen) \
138 (0xFFFF >> (16 - (__BitLen)))
139
140#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
141 (BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
142
143#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
144 (EF2Byte(*((u16 *)(__pStart))))
145
146#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
147 ( \
148 ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
149 & \
150 BIT_LEN_MASK_16(__BitLen) \
151 )
152
153#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
154 ( \
155 LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
156 & \
157 ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
158 )
159
160#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
161 *((u16 *)(__pStart)) = \
162 EF2Byte( \
163 LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
164 | \
165 ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
166 );
167
168#define BIT_LEN_MASK_8(__BitLen) \
169 (0xFF >> (8 - (__BitLen)))
170
171#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
172 (BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
173
174#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
175 (EF1Byte(*((u8 *)(__pStart))))
176
177#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
178 ( \
179 ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
180 & \
181 BIT_LEN_MASK_8(__BitLen) \
182 )
183
184#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
185 ( \
186 LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
187 & \
188 ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
189 )
190
191#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
192 *((u8 *)(__pStart)) = \
193 EF1Byte( \
194 LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
195 | \
196 ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
197 );
198
199#endif // #ifndef __INC_ENDIANFREE_H
diff --git a/drivers/staging/rtl8192e/ieee80211/aes.c b/drivers/staging/rtl8192e/ieee80211/aes.c
deleted file mode 100644
index 0c176e29a797..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/aes.c
+++ /dev/null
@@ -1,469 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * AES Cipher Algorithm.
5 *
6 * Based on Brian Gladman's code.
7 *
8 * Linux developers:
9 * Alexander Kjeldaas <astor@fast.no>
10 * Herbert Valerio Riedel <hvr@hvrlab.org>
11 * Kyle McMartin <kyle@debian.org>
12 * Adam J. Richter <adam@yggdrasil.com> (conversion to 2.5 API).
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * ---------------------------------------------------------------------------
20 * Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
21 * All rights reserved.
22 *
23 * LICENSE TERMS
24 *
25 * The free distribution and use of this software in both source and binary
26 * form is allowed (with or without changes) provided that:
27 *
28 * 1. distributions of this source code include the above copyright
29 * notice, this list of conditions and the following disclaimer;
30 *
31 * 2. distributions in binary form include the above copyright
32 * notice, this list of conditions and the following disclaimer
33 * in the documentation and/or other associated materials;
34 *
35 * 3. the copyright holder's name is not used to endorse products
36 * built using this software without specific written permission.
37 *
38 * ALTERNATIVELY, provided that this notice is retained in full, this product
39 * may be distributed under the terms of the GNU General Public License (GPL),
40 * in which case the provisions of the GPL apply INSTEAD OF those given above.
41 *
42 * DISCLAIMER
43 *
44 * This software is provided 'as is' with no explicit or implied warranties
45 * in respect of its properties, including, but not limited to, correctness
46 * and/or fitness for purpose.
47 * ---------------------------------------------------------------------------
48 */
49
50/* Some changes from the Gladman version:
51 s/RIJNDAEL(e_key)/E_KEY/g
52 s/RIJNDAEL(d_key)/D_KEY/g
53*/
54
55#include <linux/module.h>
56#include <linux/init.h>
57#include <linux/types.h>
58#include <linux/errno.h>
59//#include <linux/crypto.h>
60#include "rtl_crypto.h"
61#include <asm/byteorder.h>
62
63#define AES_MIN_KEY_SIZE 16
64#define AES_MAX_KEY_SIZE 32
65
66#define AES_BLOCK_SIZE 16
67
68static inline
69u32 generic_rotr32 (const u32 x, const unsigned bits)
70{
71 const unsigned n = bits % 32;
72 return (x >> n) | (x << (32 - n));
73}
74
75static inline
76u32 generic_rotl32 (const u32 x, const unsigned bits)
77{
78 const unsigned n = bits % 32;
79 return (x << n) | (x >> (32 - n));
80}
81
82#define rotl generic_rotl32
83#define rotr generic_rotr32
84
85/*
86 * #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
87 */
88inline static u8
89byte(const u32 x, const unsigned n)
90{
91 return x >> (n << 3);
92}
93
94#define u32_in(x) le32_to_cpu(*(const u32 *)(x))
95#define u32_out(to, from) (*(u32 *)(to) = cpu_to_le32(from))
96
97struct aes_ctx {
98 int key_length;
99 u32 E[60];
100 u32 D[60];
101};
102
103#define E_KEY ctx->E
104#define D_KEY ctx->D
105
106static u8 pow_tab[256] __initdata;
107static u8 log_tab[256] __initdata;
108static u8 sbx_tab[256] __initdata;
109static u8 isb_tab[256] __initdata;
110static u32 rco_tab[10];
111static u32 ft_tab[4][256];
112static u32 it_tab[4][256];
113
114static u32 fl_tab[4][256];
115static u32 il_tab[4][256];
116
117static inline u8 __init
118f_mult (u8 a, u8 b)
119{
120 u8 aa = log_tab[a], cc = aa + log_tab[b];
121
122 return pow_tab[cc + (cc < aa ? 1 : 0)];
123}
124
125#define ff_mult(a,b) (a && b ? f_mult(a, b) : 0)
126
127#define f_rn(bo, bi, n, k) \
128 bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
129 ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
130 ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
131 ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
132
133#define i_rn(bo, bi, n, k) \
134 bo[n] = it_tab[0][byte(bi[n],0)] ^ \
135 it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
136 it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
137 it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
138
139#define ls_box(x) \
140 ( fl_tab[0][byte(x, 0)] ^ \
141 fl_tab[1][byte(x, 1)] ^ \
142 fl_tab[2][byte(x, 2)] ^ \
143 fl_tab[3][byte(x, 3)] )
144
145#define f_rl(bo, bi, n, k) \
146 bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
147 fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
148 fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
149 fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
150
151#define i_rl(bo, bi, n, k) \
152 bo[n] = il_tab[0][byte(bi[n],0)] ^ \
153 il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
154 il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
155 il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
156
157static void __init
158gen_tabs (void)
159{
160 u32 i, t;
161 u8 p, q;
162
163 /* log and power tables for GF(2**8) finite field with
164 0x011b as modular polynomial - the simplest primitive
165 root is 0x03, used here to generate the tables */
166
167 for (i = 0, p = 1; i < 256; ++i) {
168 pow_tab[i] = (u8) p;
169 log_tab[p] = (u8) i;
170
171 p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0);
172 }
173
174 log_tab[1] = 0;
175
176 for (i = 0, p = 1; i < 10; ++i) {
177 rco_tab[i] = p;
178
179 p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
180 }
181
182 for (i = 0; i < 256; ++i) {
183 p = (i ? pow_tab[255 - log_tab[i]] : 0);
184 q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
185 p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
186 sbx_tab[i] = p;
187 isb_tab[p] = (u8) i;
188 }
189
190 for (i = 0; i < 256; ++i) {
191 p = sbx_tab[i];
192
193 t = p;
194 fl_tab[0][i] = t;
195 fl_tab[1][i] = rotl (t, 8);
196 fl_tab[2][i] = rotl (t, 16);
197 fl_tab[3][i] = rotl (t, 24);
198
199 t = ((u32) ff_mult (2, p)) |
200 ((u32) p << 8) |
201 ((u32) p << 16) | ((u32) ff_mult (3, p) << 24);
202
203 ft_tab[0][i] = t;
204 ft_tab[1][i] = rotl (t, 8);
205 ft_tab[2][i] = rotl (t, 16);
206 ft_tab[3][i] = rotl (t, 24);
207
208 p = isb_tab[i];
209
210 t = p;
211 il_tab[0][i] = t;
212 il_tab[1][i] = rotl (t, 8);
213 il_tab[2][i] = rotl (t, 16);
214 il_tab[3][i] = rotl (t, 24);
215
216 t = ((u32) ff_mult (14, p)) |
217 ((u32) ff_mult (9, p) << 8) |
218 ((u32) ff_mult (13, p) << 16) |
219 ((u32) ff_mult (11, p) << 24);
220
221 it_tab[0][i] = t;
222 it_tab[1][i] = rotl (t, 8);
223 it_tab[2][i] = rotl (t, 16);
224 it_tab[3][i] = rotl (t, 24);
225 }
226}
227
228#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
229
230#define imix_col(y,x) \
231 u = star_x(x); \
232 v = star_x(u); \
233 w = star_x(v); \
234 t = w ^ (x); \
235 (y) = u ^ v ^ w; \
236 (y) ^= rotr(u ^ t, 8) ^ \
237 rotr(v ^ t, 16) ^ \
238 rotr(t,24)
239
240/* initialise the key schedule from the user supplied key */
241
242#define loop4(i) \
243{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
244 t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \
245 t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \
246 t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \
247 t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \
248}
249
250#define loop6(i) \
251{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
252 t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \
253 t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \
254 t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \
255 t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \
256 t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \
257 t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \
258}
259
260#define loop8(i) \
261{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \
262 t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \
263 t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \
264 t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \
265 t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \
266 t = E_KEY[8 * i + 4] ^ ls_box(t); \
267 E_KEY[8 * i + 12] = t; \
268 t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \
269 t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \
270 t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
271}
272
273static int
274aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
275{
276 struct aes_ctx *ctx = ctx_arg;
277 u32 i, t, u, v, w;
278
279 if (key_len != 16 && key_len != 24 && key_len != 32) {
280 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
281 return -EINVAL;
282 }
283
284 ctx->key_length = key_len;
285
286 E_KEY[0] = u32_in (in_key);
287 E_KEY[1] = u32_in (in_key + 4);
288 E_KEY[2] = u32_in (in_key + 8);
289 E_KEY[3] = u32_in (in_key + 12);
290
291 switch (key_len) {
292 case 16:
293 t = E_KEY[3];
294 for (i = 0; i < 10; ++i)
295 loop4 (i);
296 break;
297
298 case 24:
299 E_KEY[4] = u32_in (in_key + 16);
300 t = E_KEY[5] = u32_in (in_key + 20);
301 for (i = 0; i < 8; ++i)
302 loop6 (i);
303 break;
304
305 case 32:
306 E_KEY[4] = u32_in (in_key + 16);
307 E_KEY[5] = u32_in (in_key + 20);
308 E_KEY[6] = u32_in (in_key + 24);
309 t = E_KEY[7] = u32_in (in_key + 28);
310 for (i = 0; i < 7; ++i)
311 loop8 (i);
312 break;
313 }
314
315 D_KEY[0] = E_KEY[0];
316 D_KEY[1] = E_KEY[1];
317 D_KEY[2] = E_KEY[2];
318 D_KEY[3] = E_KEY[3];
319
320 for (i = 4; i < key_len + 24; ++i) {
321 imix_col (D_KEY[i], E_KEY[i]);
322 }
323
324 return 0;
325}
326
327/* encrypt a block of text */
328
329#define f_nround(bo, bi, k) \
330 f_rn(bo, bi, 0, k); \
331 f_rn(bo, bi, 1, k); \
332 f_rn(bo, bi, 2, k); \
333 f_rn(bo, bi, 3, k); \
334 k += 4
335
336#define f_lround(bo, bi, k) \
337 f_rl(bo, bi, 0, k); \
338 f_rl(bo, bi, 1, k); \
339 f_rl(bo, bi, 2, k); \
340 f_rl(bo, bi, 3, k)
341
342static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in)
343{
344 const struct aes_ctx *ctx = ctx_arg;
345 u32 b0[4], b1[4];
346 const u32 *kp = E_KEY + 4;
347
348 b0[0] = u32_in (in) ^ E_KEY[0];
349 b0[1] = u32_in (in + 4) ^ E_KEY[1];
350 b0[2] = u32_in (in + 8) ^ E_KEY[2];
351 b0[3] = u32_in (in + 12) ^ E_KEY[3];
352
353 if (ctx->key_length > 24) {
354 f_nround (b1, b0, kp);
355 f_nround (b0, b1, kp);
356 }
357
358 if (ctx->key_length > 16) {
359 f_nround (b1, b0, kp);
360 f_nround (b0, b1, kp);
361 }
362
363 f_nround (b1, b0, kp);
364 f_nround (b0, b1, kp);
365 f_nround (b1, b0, kp);
366 f_nround (b0, b1, kp);
367 f_nround (b1, b0, kp);
368 f_nround (b0, b1, kp);
369 f_nround (b1, b0, kp);
370 f_nround (b0, b1, kp);
371 f_nround (b1, b0, kp);
372 f_lround (b0, b1, kp);
373
374 u32_out (out, b0[0]);
375 u32_out (out + 4, b0[1]);
376 u32_out (out + 8, b0[2]);
377 u32_out (out + 12, b0[3]);
378}
379
380/* decrypt a block of text */
381
382#define i_nround(bo, bi, k) \
383 i_rn(bo, bi, 0, k); \
384 i_rn(bo, bi, 1, k); \
385 i_rn(bo, bi, 2, k); \
386 i_rn(bo, bi, 3, k); \
387 k -= 4
388
389#define i_lround(bo, bi, k) \
390 i_rl(bo, bi, 0, k); \
391 i_rl(bo, bi, 1, k); \
392 i_rl(bo, bi, 2, k); \
393 i_rl(bo, bi, 3, k)
394
395static void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in)
396{
397 const struct aes_ctx *ctx = ctx_arg;
398 u32 b0[4], b1[4];
399 const int key_len = ctx->key_length;
400 const u32 *kp = D_KEY + key_len + 20;
401
402 b0[0] = u32_in (in) ^ E_KEY[key_len + 24];
403 b0[1] = u32_in (in + 4) ^ E_KEY[key_len + 25];
404 b0[2] = u32_in (in + 8) ^ E_KEY[key_len + 26];
405 b0[3] = u32_in (in + 12) ^ E_KEY[key_len + 27];
406
407 if (key_len > 24) {
408 i_nround (b1, b0, kp);
409 i_nround (b0, b1, kp);
410 }
411
412 if (key_len > 16) {
413 i_nround (b1, b0, kp);
414 i_nround (b0, b1, kp);
415 }
416
417 i_nround (b1, b0, kp);
418 i_nround (b0, b1, kp);
419 i_nround (b1, b0, kp);
420 i_nround (b0, b1, kp);
421 i_nround (b1, b0, kp);
422 i_nround (b0, b1, kp);
423 i_nround (b1, b0, kp);
424 i_nround (b0, b1, kp);
425 i_nround (b1, b0, kp);
426 i_lround (b0, b1, kp);
427
428 u32_out (out, b0[0]);
429 u32_out (out + 4, b0[1]);
430 u32_out (out + 8, b0[2]);
431 u32_out (out + 12, b0[3]);
432}
433
434
435static struct crypto_alg aes_alg = {
436 .cra_name = "aes",
437 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
438 .cra_blocksize = AES_BLOCK_SIZE,
439 .cra_ctxsize = sizeof(struct aes_ctx),
440 .cra_module = THIS_MODULE,
441 .cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
442 .cra_u = {
443 .cipher = {
444 .cia_min_keysize = AES_MIN_KEY_SIZE,
445 .cia_max_keysize = AES_MAX_KEY_SIZE,
446 .cia_setkey = aes_set_key,
447 .cia_encrypt = aes_encrypt,
448 .cia_decrypt = aes_decrypt
449 }
450 }
451};
452
453static int __init aes_init(void)
454{
455 gen_tabs();
456 return crypto_register_alg(&aes_alg);
457}
458
459static void __exit aes_fini(void)
460{
461 crypto_unregister_alg(&aes_alg);
462}
463
464module_init(aes_init);
465module_exit(aes_fini);
466
467MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
468MODULE_LICENSE("Dual BSD/GPL");
469
diff --git a/drivers/staging/rtl8192e/ieee80211/api.c b/drivers/staging/rtl8192e/ieee80211/api.c
deleted file mode 100644
index c627d029528b..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/api.c
+++ /dev/null
@@ -1,246 +0,0 @@
1/*
2 * Scatterlist Cryptographic API.
3 *
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2002 David S. Miller (davem@redhat.com)
6 *
7 * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
8 * and Nettle, by Niels Mé°ˆler.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 */
16#include "kmap_types.h"
17
18#include <linux/init.h>
19#include <linux/module.h>
20//#include <linux/crypto.h>
21#include "rtl_crypto.h"
22#include <linux/errno.h>
23#include <linux/rwsem.h>
24#include <linux/slab.h>
25#include "internal.h"
26
27LIST_HEAD(crypto_alg_list);
28DECLARE_RWSEM(crypto_alg_sem);
29
30static inline int crypto_alg_get(struct crypto_alg *alg)
31{
32 return try_inc_mod_count(alg->cra_module);
33}
34
35static inline void crypto_alg_put(struct crypto_alg *alg)
36{
37 if (alg->cra_module)
38 __MOD_DEC_USE_COUNT(alg->cra_module);
39}
40
41struct crypto_alg *crypto_alg_lookup(const char *name)
42{
43 struct crypto_alg *q, *alg = NULL;
44
45 if (!name)
46 return NULL;
47
48 down_read(&crypto_alg_sem);
49
50 list_for_each_entry(q, &crypto_alg_list, cra_list) {
51 if (!(strcmp(q->cra_name, name))) {
52 if (crypto_alg_get(q))
53 alg = q;
54 break;
55 }
56 }
57
58 up_read(&crypto_alg_sem);
59 return alg;
60}
61
62static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
63{
64 tfm->crt_flags = 0;
65
66 switch (crypto_tfm_alg_type(tfm)) {
67 case CRYPTO_ALG_TYPE_CIPHER:
68 return crypto_init_cipher_flags(tfm, flags);
69
70 case CRYPTO_ALG_TYPE_DIGEST:
71 return crypto_init_digest_flags(tfm, flags);
72
73 case CRYPTO_ALG_TYPE_COMPRESS:
74 return crypto_init_compress_flags(tfm, flags);
75
76 default:
77 break;
78 }
79
80 BUG();
81 return -EINVAL;
82}
83
84static int crypto_init_ops(struct crypto_tfm *tfm)
85{
86 switch (crypto_tfm_alg_type(tfm)) {
87 case CRYPTO_ALG_TYPE_CIPHER:
88 return crypto_init_cipher_ops(tfm);
89
90 case CRYPTO_ALG_TYPE_DIGEST:
91 return crypto_init_digest_ops(tfm);
92
93 case CRYPTO_ALG_TYPE_COMPRESS:
94 return crypto_init_compress_ops(tfm);
95
96 default:
97 break;
98 }
99
100 BUG();
101 return -EINVAL;
102}
103
104static void crypto_exit_ops(struct crypto_tfm *tfm)
105{
106 switch (crypto_tfm_alg_type(tfm)) {
107 case CRYPTO_ALG_TYPE_CIPHER:
108 crypto_exit_cipher_ops(tfm);
109 break;
110
111 case CRYPTO_ALG_TYPE_DIGEST:
112 crypto_exit_digest_ops(tfm);
113 break;
114
115 case CRYPTO_ALG_TYPE_COMPRESS:
116 crypto_exit_compress_ops(tfm);
117 break;
118
119 default:
120 BUG();
121
122 }
123}
124
125struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
126{
127 struct crypto_tfm *tfm = NULL;
128 struct crypto_alg *alg;
129
130 alg = crypto_alg_mod_lookup(name);
131 if (alg == NULL)
132 goto out;
133
134 tfm = kmalloc(sizeof(*tfm) + alg->cra_ctxsize, GFP_KERNEL);
135 if (tfm == NULL)
136 goto out_put;
137
138 memset(tfm, 0, sizeof(*tfm) + alg->cra_ctxsize);
139
140 tfm->__crt_alg = alg;
141
142 if (crypto_init_flags(tfm, flags))
143 goto out_free_tfm;
144
145 if (crypto_init_ops(tfm)) {
146 crypto_exit_ops(tfm);
147 goto out_free_tfm;
148 }
149
150 goto out;
151
152out_free_tfm:
153 kfree(tfm);
154 tfm = NULL;
155out_put:
156 crypto_alg_put(alg);
157out:
158 return tfm;
159}
160
161void crypto_free_tfm(struct crypto_tfm *tfm)
162{
163 struct crypto_alg *alg = tfm->__crt_alg;
164 int size = sizeof(*tfm) + alg->cra_ctxsize;
165
166 crypto_exit_ops(tfm);
167 crypto_alg_put(alg);
168 memset(tfm, 0, size);
169 kfree(tfm);
170}
171
172int crypto_register_alg(struct crypto_alg *alg)
173{
174 int ret = 0;
175 struct crypto_alg *q;
176
177 down_write(&crypto_alg_sem);
178
179 list_for_each_entry(q, &crypto_alg_list, cra_list) {
180 if (!(strcmp(q->cra_name, alg->cra_name))) {
181 ret = -EEXIST;
182 goto out;
183 }
184 }
185
186 list_add_tail(&alg->cra_list, &crypto_alg_list);
187out:
188 up_write(&crypto_alg_sem);
189 return ret;
190}
191
192int crypto_unregister_alg(struct crypto_alg *alg)
193{
194 int ret = -ENOENT;
195 struct crypto_alg *q;
196
197 BUG_ON(!alg->cra_module);
198
199 down_write(&crypto_alg_sem);
200 list_for_each_entry(q, &crypto_alg_list, cra_list) {
201 if (alg == q) {
202 list_del(&alg->cra_list);
203 ret = 0;
204 goto out;
205 }
206 }
207out:
208 up_write(&crypto_alg_sem);
209 return ret;
210}
211
212int crypto_alg_available(const char *name, u32 flags)
213{
214 int ret = 0;
215 struct crypto_alg *alg = crypto_alg_mod_lookup(name);
216
217 if (alg) {
218 crypto_alg_put(alg);
219 ret = 1;
220 }
221
222 return ret;
223}
224
225static int __init init_crypto(void)
226{
227 printk(KERN_INFO "Initializing Cryptographic API\n");
228 crypto_init_proc();
229 return 0;
230}
231
232__initcall(init_crypto);
233
234/*
235EXPORT_SYMBOL_GPL(crypto_register_alg);
236EXPORT_SYMBOL_GPL(crypto_unregister_alg);
237EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
238EXPORT_SYMBOL_GPL(crypto_free_tfm);
239EXPORT_SYMBOL_GPL(crypto_alg_available);
240*/
241
242EXPORT_SYMBOL_NOVERS(crypto_register_alg);
243EXPORT_SYMBOL_NOVERS(crypto_unregister_alg);
244EXPORT_SYMBOL_NOVERS(crypto_alloc_tfm);
245EXPORT_SYMBOL_NOVERS(crypto_free_tfm);
246EXPORT_SYMBOL_NOVERS(crypto_alg_available);
diff --git a/drivers/staging/rtl8192e/ieee80211/arc4.c b/drivers/staging/rtl8192e/ieee80211/arc4.c
deleted file mode 100644
index e408472af305..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/arc4.c
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * Cryptographic API
3 *
4 * ARC4 Cipher Algorithm
5 *
6 * Jon Oberheide <jon@oberheide.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14#include <linux/module.h>
15#include <linux/init.h>
16#include "rtl_crypto.h"
17
18#define ARC4_MIN_KEY_SIZE 1
19#define ARC4_MAX_KEY_SIZE 256
20#define ARC4_BLOCK_SIZE 1
21
22struct arc4_ctx {
23 u8 S[256];
24 u8 x, y;
25};
26
27static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
28{
29 struct arc4_ctx *ctx = ctx_arg;
30 int i, j = 0, k = 0;
31
32 ctx->x = 1;
33 ctx->y = 0;
34
35 for(i = 0; i < 256; i++)
36 ctx->S[i] = i;
37
38 for(i = 0; i < 256; i++)
39 {
40 u8 a = ctx->S[i];
41 j = (j + in_key[k] + a) & 0xff;
42 ctx->S[i] = ctx->S[j];
43 ctx->S[j] = a;
44 if((unsigned int)++k >= key_len)
45 k = 0;
46 }
47
48 return 0;
49}
50
51static void arc4_crypt(void *ctx_arg, u8 *out, const u8 *in)
52{
53 struct arc4_ctx *ctx = ctx_arg;
54
55 u8 *const S = ctx->S;
56 u8 x = ctx->x;
57 u8 y = ctx->y;
58 u8 a, b;
59
60 a = S[x];
61 y = (y + a) & 0xff;
62 b = S[y];
63 S[x] = b;
64 S[y] = a;
65 x = (x + 1) & 0xff;
66 *out++ = *in ^ S[(a + b) & 0xff];
67
68 ctx->x = x;
69 ctx->y = y;
70}
71
72static struct crypto_alg arc4_alg = {
73 .cra_name = "arc4",
74 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
75 .cra_blocksize = ARC4_BLOCK_SIZE,
76 .cra_ctxsize = sizeof(struct arc4_ctx),
77 .cra_module = THIS_MODULE,
78 .cra_list = LIST_HEAD_INIT(arc4_alg.cra_list),
79 .cra_u = { .cipher = {
80 .cia_min_keysize = ARC4_MIN_KEY_SIZE,
81 .cia_max_keysize = ARC4_MAX_KEY_SIZE,
82 .cia_setkey = arc4_set_key,
83 .cia_encrypt = arc4_crypt,
84 .cia_decrypt = arc4_crypt } }
85};
86
87static int __init arc4_init(void)
88{
89 return crypto_register_alg(&arc4_alg);
90}
91
92
93static void __exit arc4_exit(void)
94{
95 crypto_unregister_alg(&arc4_alg);
96}
97
98module_init(arc4_init);
99module_exit(arc4_exit);
100
101MODULE_LICENSE("GPL");
102MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
103MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
diff --git a/drivers/staging/rtl8192e/ieee80211/autoload.c b/drivers/staging/rtl8192e/ieee80211/autoload.c
deleted file mode 100644
index c97756f3b2ea..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/autoload.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Algorithm autoloader.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14#include "kmap_types.h"
15
16#include <linux/kernel.h>
17//#include <linux/crypto.h>
18#include "rtl_crypto.h"
19#include <linux/string.h>
20#include <linux/kmod.h>
21#include "internal.h"
22
23/*
24 * A far more intelligent version of this is planned. For now, just
25 * try an exact match on the name of the algorithm.
26 */
27void crypto_alg_autoload(const char *name)
28{
29 request_module(name);
30}
31
32struct crypto_alg *crypto_alg_mod_lookup(const char *name)
33{
34 struct crypto_alg *alg = crypto_alg_lookup(name);
35 if (alg == NULL) {
36 crypto_alg_autoload(name);
37 alg = crypto_alg_lookup(name);
38 }
39 return alg;
40}
diff --git a/drivers/staging/rtl8192e/ieee80211/cipher.c b/drivers/staging/rtl8192e/ieee80211/cipher.c
deleted file mode 100644
index 1968acfe32b1..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/cipher.c
+++ /dev/null
@@ -1,299 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Cipher operations.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14#include <linux/kernel.h>
15//#include <linux/crypto.h>
16#include "rtl_crypto.h"
17#include <linux/errno.h>
18#include <linux/mm.h>
19#include <linux/slab.h>
20#include <asm/scatterlist.h>
21#include "internal.h"
22#include "scatterwalk.h"
23
24typedef void (cryptfn_t)(void *, u8 *, const u8 *);
25typedef void (procfn_t)(struct crypto_tfm *, u8 *,
26 u8*, cryptfn_t, int enc, void *, int);
27
28static inline void xor_64(u8 *a, const u8 *b)
29{
30 ((u32 *)a)[0] ^= ((u32 *)b)[0];
31 ((u32 *)a)[1] ^= ((u32 *)b)[1];
32}
33
34static inline void xor_128(u8 *a, const u8 *b)
35{
36 ((u32 *)a)[0] ^= ((u32 *)b)[0];
37 ((u32 *)a)[1] ^= ((u32 *)b)[1];
38 ((u32 *)a)[2] ^= ((u32 *)b)[2];
39 ((u32 *)a)[3] ^= ((u32 *)b)[3];
40}
41
42
43/*
44 * Generic encrypt/decrypt wrapper for ciphers, handles operations across
45 * multiple page boundaries by using temporary blocks. In user context,
46 * the kernel is given a chance to schedule us once per block.
47 */
48static int crypt(struct crypto_tfm *tfm,
49 struct scatterlist *dst,
50 struct scatterlist *src,
51 unsigned int nbytes, cryptfn_t crfn,
52 procfn_t prfn, int enc, void *info)
53{
54 struct scatter_walk walk_in, walk_out;
55 const unsigned int bsize = crypto_tfm_alg_blocksize(tfm);
56 u8 tmp_src[bsize];
57 u8 tmp_dst[bsize];
58
59 if (!nbytes)
60 return 0;
61
62 if (nbytes % bsize) {
63 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
64 return -EINVAL;
65 }
66
67 scatterwalk_start(&walk_in, src);
68 scatterwalk_start(&walk_out, dst);
69
70 for(;;) {
71 u8 *src_p, *dst_p;
72 int in_place;
73
74 scatterwalk_map(&walk_in, 0);
75 scatterwalk_map(&walk_out, 1);
76 src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src);
77 dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst);
78 in_place = scatterwalk_samebuf(&walk_in, &walk_out,
79 src_p, dst_p);
80
81 nbytes -= bsize;
82
83 scatterwalk_copychunks(src_p, &walk_in, bsize, 0);
84
85 prfn(tfm, dst_p, src_p, crfn, enc, info, in_place);
86
87 scatterwalk_done(&walk_in, 0, nbytes);
88
89 scatterwalk_copychunks(dst_p, &walk_out, bsize, 1);
90 scatterwalk_done(&walk_out, 1, nbytes);
91
92 if (!nbytes)
93 return 0;
94
95 crypto_yield(tfm);
96 }
97}
98
99static void cbc_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
100 cryptfn_t fn, int enc, void *info, int in_place)
101{
102 u8 *iv = info;
103
104 /* Null encryption */
105 if (!iv)
106 return;
107
108 if (enc) {
109 tfm->crt_u.cipher.cit_xor_block(iv, src);
110 fn(crypto_tfm_ctx(tfm), dst, iv);
111 memcpy(iv, dst, crypto_tfm_alg_blocksize(tfm));
112 } else {
113 u8 stack[in_place ? crypto_tfm_alg_blocksize(tfm) : 0];
114 u8 *buf = in_place ? stack : dst;
115
116 fn(crypto_tfm_ctx(tfm), buf, src);
117 tfm->crt_u.cipher.cit_xor_block(buf, iv);
118 memcpy(iv, src, crypto_tfm_alg_blocksize(tfm));
119 if (buf != dst)
120 memcpy(dst, buf, crypto_tfm_alg_blocksize(tfm));
121 }
122}
123
124static void ecb_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
125 cryptfn_t fn, int enc, void *info, int in_place)
126{
127 fn(crypto_tfm_ctx(tfm), dst, src);
128}
129
130static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
131{
132 struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher;
133
134 if (keylen < cia->cia_min_keysize || keylen > cia->cia_max_keysize) {
135 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
136 return -EINVAL;
137 } else
138 return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen,
139 &tfm->crt_flags);
140}
141
142static int ecb_encrypt(struct crypto_tfm *tfm,
143 struct scatterlist *dst,
144 struct scatterlist *src, unsigned int nbytes)
145{
146 return crypt(tfm, dst, src, nbytes,
147 tfm->__crt_alg->cra_cipher.cia_encrypt,
148 ecb_process, 1, NULL);
149}
150
151static int ecb_decrypt(struct crypto_tfm *tfm,
152 struct scatterlist *dst,
153 struct scatterlist *src,
154 unsigned int nbytes)
155{
156 return crypt(tfm, dst, src, nbytes,
157 tfm->__crt_alg->cra_cipher.cia_decrypt,
158 ecb_process, 1, NULL);
159}
160
161static int cbc_encrypt(struct crypto_tfm *tfm,
162 struct scatterlist *dst,
163 struct scatterlist *src,
164 unsigned int nbytes)
165{
166 return crypt(tfm, dst, src, nbytes,
167 tfm->__crt_alg->cra_cipher.cia_encrypt,
168 cbc_process, 1, tfm->crt_cipher.cit_iv);
169}
170
171static int cbc_encrypt_iv(struct crypto_tfm *tfm,
172 struct scatterlist *dst,
173 struct scatterlist *src,
174 unsigned int nbytes, u8 *iv)
175{
176 return crypt(tfm, dst, src, nbytes,
177 tfm->__crt_alg->cra_cipher.cia_encrypt,
178 cbc_process, 1, iv);
179}
180
181static int cbc_decrypt(struct crypto_tfm *tfm,
182 struct scatterlist *dst,
183 struct scatterlist *src,
184 unsigned int nbytes)
185{
186 return crypt(tfm, dst, src, nbytes,
187 tfm->__crt_alg->cra_cipher.cia_decrypt,
188 cbc_process, 0, tfm->crt_cipher.cit_iv);
189}
190
191static int cbc_decrypt_iv(struct crypto_tfm *tfm,
192 struct scatterlist *dst,
193 struct scatterlist *src,
194 unsigned int nbytes, u8 *iv)
195{
196 return crypt(tfm, dst, src, nbytes,
197 tfm->__crt_alg->cra_cipher.cia_decrypt,
198 cbc_process, 0, iv);
199}
200
201static int nocrypt(struct crypto_tfm *tfm,
202 struct scatterlist *dst,
203 struct scatterlist *src,
204 unsigned int nbytes)
205{
206 return -ENOSYS;
207}
208
209static int nocrypt_iv(struct crypto_tfm *tfm,
210 struct scatterlist *dst,
211 struct scatterlist *src,
212 unsigned int nbytes, u8 *iv)
213{
214 return -ENOSYS;
215}
216
217int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
218{
219 u32 mode = flags & CRYPTO_TFM_MODE_MASK;
220
221 tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB;
222 if (flags & CRYPTO_TFM_REQ_WEAK_KEY)
223 tfm->crt_flags = CRYPTO_TFM_REQ_WEAK_KEY;
224
225 return 0;
226}
227
228int crypto_init_cipher_ops(struct crypto_tfm *tfm)
229{
230 int ret = 0;
231 struct cipher_tfm *ops = &tfm->crt_cipher;
232
233 ops->cit_setkey = setkey;
234
235 switch (tfm->crt_cipher.cit_mode) {
236 case CRYPTO_TFM_MODE_ECB:
237 ops->cit_encrypt = ecb_encrypt;
238 ops->cit_decrypt = ecb_decrypt;
239 break;
240
241 case CRYPTO_TFM_MODE_CBC:
242 ops->cit_encrypt = cbc_encrypt;
243 ops->cit_decrypt = cbc_decrypt;
244 ops->cit_encrypt_iv = cbc_encrypt_iv;
245 ops->cit_decrypt_iv = cbc_decrypt_iv;
246 break;
247
248 case CRYPTO_TFM_MODE_CFB:
249 ops->cit_encrypt = nocrypt;
250 ops->cit_decrypt = nocrypt;
251 ops->cit_encrypt_iv = nocrypt_iv;
252 ops->cit_decrypt_iv = nocrypt_iv;
253 break;
254
255 case CRYPTO_TFM_MODE_CTR:
256 ops->cit_encrypt = nocrypt;
257 ops->cit_decrypt = nocrypt;
258 ops->cit_encrypt_iv = nocrypt_iv;
259 ops->cit_decrypt_iv = nocrypt_iv;
260 break;
261
262 default:
263 BUG();
264 }
265
266 if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) {
267
268 switch (crypto_tfm_alg_blocksize(tfm)) {
269 case 8:
270 ops->cit_xor_block = xor_64;
271 break;
272
273 case 16:
274 ops->cit_xor_block = xor_128;
275 break;
276
277 default:
278 printk(KERN_WARNING "%s: block size %u not supported\n",
279 crypto_tfm_alg_name(tfm),
280 crypto_tfm_alg_blocksize(tfm));
281 ret = -EINVAL;
282 goto out;
283 }
284
285 ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
286 ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL);
287 if (ops->cit_iv == NULL)
288 ret = -ENOMEM;
289 }
290
291out:
292 return ret;
293}
294
295void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
296{
297 if (tfm->crt_cipher.cit_iv)
298 kfree(tfm->crt_cipher.cit_iv);
299}
diff --git a/drivers/staging/rtl8192e/ieee80211/compress.c b/drivers/staging/rtl8192e/ieee80211/compress.c
deleted file mode 100644
index c2df80e2ed9d..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/compress.c
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Compression operations.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14#include <linux/types.h>
15//#include <linux/crypto.h>
16#include "rtl_crypto.h"
17#include <linux/errno.h>
18#include <asm/scatterlist.h>
19#include <linux/string.h>
20#include "internal.h"
21
22static int crypto_compress(struct crypto_tfm *tfm,
23 const u8 *src, unsigned int slen,
24 u8 *dst, unsigned int *dlen)
25{
26 return tfm->__crt_alg->cra_compress.coa_compress(crypto_tfm_ctx(tfm),
27 src, slen, dst,
28 dlen);
29}
30
31static int crypto_decompress(struct crypto_tfm *tfm,
32 const u8 *src, unsigned int slen,
33 u8 *dst, unsigned int *dlen)
34{
35 return tfm->__crt_alg->cra_compress.coa_decompress(crypto_tfm_ctx(tfm),
36 src, slen, dst,
37 dlen);
38}
39
40int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
41{
42 return flags ? -EINVAL : 0;
43}
44
45int crypto_init_compress_ops(struct crypto_tfm *tfm)
46{
47 int ret = 0;
48 struct compress_tfm *ops = &tfm->crt_compress;
49
50 ret = tfm->__crt_alg->cra_compress.coa_init(crypto_tfm_ctx(tfm));
51 if (ret)
52 goto out;
53
54 ops->cot_compress = crypto_compress;
55 ops->cot_decompress = crypto_decompress;
56
57out:
58 return ret;
59}
60
61void crypto_exit_compress_ops(struct crypto_tfm *tfm)
62{
63 tfm->__crt_alg->cra_compress.coa_exit(crypto_tfm_ctx(tfm));
64}
diff --git a/drivers/staging/rtl8192e/ieee80211/crypto_compat.h b/drivers/staging/rtl8192e/ieee80211/crypto_compat.h
deleted file mode 100644
index 587e8bb2db6a..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/crypto_compat.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Header file to maintain compatibility among different kernel versions.
3 *
4 * Copyright (c) 2004-2006 <lawrence_wang@realsil.com.cn>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. See README and COPYING for
9 * more details.
10 */
11
12#include <linux/crypto.h>
13
14static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
15 struct scatterlist *dst,
16 struct scatterlist *src,
17 unsigned int nbytes)
18{
19 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
20 return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
21}
22
23
24static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
25 struct scatterlist *dst,
26 struct scatterlist *src,
27 unsigned int nbytes)
28{
29 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
30 return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
31}
32
33#if 0
34/*
35 * crypto_free_tfm - Free crypto transform
36 * @tfm: Transform to free
37 *
38 * crypto_free_tfm() frees up the transform and any associated resources,
39 * then drops the refcount on the associated algorithm.
40 */
41void crypto_free_tfm(struct crypto_tfm *tfm)
42{
43 struct crypto_alg *alg;
44 int size;
45
46 if (unlikely(!tfm))
47 return;
48
49 alg = tfm->__crt_alg;
50 size = sizeof(*tfm) + alg->cra_ctxsize;
51
52 if (alg->cra_exit)
53 alg->cra_exit(tfm);
54 crypto_exit_ops(tfm);
55 crypto_mod_put(alg);
56 memset(tfm, 0, size);
57 kfree(tfm);
58}
59
60#endif
61#if 1
62 struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
63{
64 struct crypto_tfm *tfm = NULL;
65 int err;
66 printk("call crypto_alloc_tfm!!!\n");
67 do {
68 struct crypto_alg *alg;
69
70 alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
71 err = PTR_ERR(alg);
72 if (IS_ERR(alg))
73 continue;
74
75 tfm = __crypto_alloc_tfm(alg, flags);
76 err = 0;
77 if (IS_ERR(tfm)) {
78 crypto_mod_put(alg);
79 err = PTR_ERR(tfm);
80 tfm = NULL;
81 }
82 } while (err == -EAGAIN && !signal_pending(current));
83
84 return tfm;
85}
86#endif
87//EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
88//EXPORT_SYMBOL_GPL(crypto_free_tfm);
89
90
diff --git a/drivers/staging/rtl8192e/ieee80211/digest.c b/drivers/staging/rtl8192e/ieee80211/digest.c
deleted file mode 100644
index 1a95f2d37837..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/digest.c
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Digest operations.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14//#include <linux/crypto.h>
15#include "rtl_crypto.h"
16#include <linux/mm.h>
17#include <linux/errno.h>
18#include <linux/highmem.h>
19#include <asm/scatterlist.h>
20#include "internal.h"
21
22static void init(struct crypto_tfm *tfm)
23{
24 tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm));
25}
26
27static void update(struct crypto_tfm *tfm,
28 struct scatterlist *sg, unsigned int nsg)
29{
30 unsigned int i;
31
32 for (i = 0; i < nsg; i++) {
33
34 struct page *pg = sg[i].page;
35 unsigned int offset = sg[i].offset;
36 unsigned int l = sg[i].length;
37
38 do {
39 unsigned int bytes_from_page = min(l, ((unsigned int)
40 (PAGE_SIZE)) -
41 offset);
42 char *p = crypto_kmap(pg, 0) + offset;
43
44 tfm->__crt_alg->cra_digest.dia_update
45 (crypto_tfm_ctx(tfm), p,
46 bytes_from_page);
47 crypto_kunmap(p, 0);
48 crypto_yield(tfm);
49 offset = 0;
50 pg++;
51 l -= bytes_from_page;
52 } while (l > 0);
53 }
54}
55
56static void final(struct crypto_tfm *tfm, u8 *out)
57{
58 tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
59}
60
61static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
62{
63 u32 flags;
64 if (tfm->__crt_alg->cra_digest.dia_setkey == NULL)
65 return -ENOSYS;
66 return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm),
67 key, keylen, &flags);
68}
69
70static void digest(struct crypto_tfm *tfm,
71 struct scatterlist *sg, unsigned int nsg, u8 *out)
72{
73 unsigned int i;
74
75 tfm->crt_digest.dit_init(tfm);
76
77 for (i = 0; i < nsg; i++) {
78 char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;
79 tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm),
80 p, sg[i].length);
81 crypto_kunmap(p, 0);
82 crypto_yield(tfm);
83 }
84 crypto_digest_final(tfm, out);
85}
86
87int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
88{
89 return flags ? -EINVAL : 0;
90}
91
92int crypto_init_digest_ops(struct crypto_tfm *tfm)
93{
94 struct digest_tfm *ops = &tfm->crt_digest;
95
96 ops->dit_init = init;
97 ops->dit_update = update;
98 ops->dit_final = final;
99 ops->dit_digest = digest;
100 ops->dit_setkey = setkey;
101
102 return crypto_alloc_hmac_block(tfm);
103}
104
105void crypto_exit_digest_ops(struct crypto_tfm *tfm)
106{
107 crypto_free_hmac_block(tfm);
108}
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c
index a9eddeb66b27..7a1797e6cbec 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_tkip.c
@@ -22,9 +22,6 @@
22#include <asm/string.h> 22#include <asm/string.h>
23 23
24#include "ieee80211.h" 24#include "ieee80211.h"
25#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
26//#include "crypto_compat.h"
27#endif
28 25
29 26
30#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) 27#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c
index 634143551357..5678313e30a5 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_crypt_wep.c
@@ -20,10 +20,6 @@
20 20
21#include "ieee80211.h" 21#include "ieee80211.h"
22 22
23#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
24//#include "crypto_compat.h"
25#endif
26
27 23
28#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) 24#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
29#include "rtl_crypto.h" 25#include "rtl_crypto.h"
diff --git a/drivers/staging/rtl8192e/ieee80211/internal.h b/drivers/staging/rtl8192e/ieee80211/internal.h
deleted file mode 100644
index ddc22350d006..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/internal.h
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12#ifndef _CRYPTO_INTERNAL_H
13#define _CRYPTO_INTERNAL_H
14
15
16//#include <linux/crypto.h>
17#include "rtl_crypto.h"
18#include <linux/mm.h>
19#include <linux/highmem.h>
20#include <linux/init.h>
21#include <asm/hardirq.h>
22#include <asm/softirq.h>
23#include <asm/kmap_types.h>
24
25#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
26#define list_for_each_entry(pos, head, member) \
27 for (pos = list_entry((head)->next, typeof(*pos), member), \
28 prefetch(pos->member.next); \
29 &pos->member != (head); \
30 pos = list_entry(pos->member.next, typeof(*pos), member), \
31 prefetch(pos->member.next))
32
33static inline void cond_resched(void)
34{
35 if (need_resched()) {
36 set_current_state(TASK_RUNNING);
37 schedule();
38 }
39}
40#endif
41
42extern enum km_type crypto_km_types[];
43
44static inline enum km_type crypto_kmap_type(int out)
45{
46 return crypto_km_types[(in_softirq() ? 2 : 0) + out];
47}
48
49static inline void *crypto_kmap(struct page *page, int out)
50{
51 return kmap_atomic(page, crypto_kmap_type(out));
52}
53
54static inline void crypto_kunmap(void *vaddr, int out)
55{
56 kunmap_atomic(vaddr, crypto_kmap_type(out));
57}
58
59static inline void crypto_yield(struct crypto_tfm *tfm)
60{
61 if (!in_softirq())
62 cond_resched();
63}
64
65static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
66{
67 return (void *)&tfm[1];
68}
69
70struct crypto_alg *crypto_alg_lookup(const char *name);
71
72#ifdef CONFIG_KMOD
73void crypto_alg_autoload(const char *name);
74struct crypto_alg *crypto_alg_mod_lookup(const char *name);
75#else
76static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
77{
78 return crypto_alg_lookup(name);
79}
80#endif
81
82#ifdef CONFIG_CRYPTO_HMAC
83int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
84void crypto_free_hmac_block(struct crypto_tfm *tfm);
85#else
86static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
87{
88 return 0;
89}
90
91static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
92{ }
93#endif
94
95#ifdef CONFIG_PROC_FS
96void __init crypto_init_proc(void);
97#else
98static inline void crypto_init_proc(void)
99{ }
100#endif
101
102int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
103int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
104int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
105
106int crypto_init_digest_ops(struct crypto_tfm *tfm);
107int crypto_init_cipher_ops(struct crypto_tfm *tfm);
108int crypto_init_compress_ops(struct crypto_tfm *tfm);
109
110void crypto_exit_digest_ops(struct crypto_tfm *tfm);
111void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
112void crypto_exit_compress_ops(struct crypto_tfm *tfm);
113
114#endif /* _CRYPTO_INTERNAL_H */
115
diff --git a/drivers/staging/rtl8192e/ieee80211/kmap_types.h b/drivers/staging/rtl8192e/ieee80211/kmap_types.h
deleted file mode 100644
index de67bb01b5f5..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/kmap_types.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef __KMAP_TYPES_H
2
3#define __KMAP_TYPES_H
4
5
6enum km_type {
7 KM_BOUNCE_READ,
8 KM_SKB_SUNRPC_DATA,
9 KM_SKB_DATA_SOFTIRQ,
10 KM_USER0,
11 KM_USER1,
12 KM_BH_IRQ,
13 KM_SOFTIRQ0,
14 KM_SOFTIRQ1,
15 KM_TYPE_NR
16};
17
18#define _ASM_KMAP_TYPES_H
19
20#endif
diff --git a/drivers/staging/rtl8192e/ieee80211/michael_mic.c b/drivers/staging/rtl8192e/ieee80211/michael_mic.c
deleted file mode 100644
index df256e487c20..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/michael_mic.c
+++ /dev/null
@@ -1,194 +0,0 @@
1/*
2 * Cryptographic API
3 *
4 * Michael MIC (IEEE 802.11i/TKIP) keyed digest
5 *
6 * Copyright (c) 2004 Jouni Malinen <jkmaline@cc.hut.fi>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/string.h>
16//#include <linux/crypto.h>
17#include "rtl_crypto.h"
18
19
20struct michael_mic_ctx {
21 u8 pending[4];
22 size_t pending_len;
23
24 u32 l, r;
25};
26
27
28static inline u32 rotl(u32 val, int bits)
29{
30 return (val << bits) | (val >> (32 - bits));
31}
32
33
34static inline u32 rotr(u32 val, int bits)
35{
36 return (val >> bits) | (val << (32 - bits));
37}
38
39
40static inline u32 xswap(u32 val)
41{
42 return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
43}
44
45
46#define michael_block(l, r) \
47do { \
48 r ^= rotl(l, 17); \
49 l += r; \
50 r ^= xswap(l); \
51 l += r; \
52 r ^= rotl(l, 3); \
53 l += r; \
54 r ^= rotr(l, 2); \
55 l += r; \
56} while (0)
57
58
59static inline u32 get_le32(const u8 *p)
60{
61 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
62}
63
64
65static inline void put_le32(u8 *p, u32 v)
66{
67 p[0] = v;
68 p[1] = v >> 8;
69 p[2] = v >> 16;
70 p[3] = v >> 24;
71}
72
73
74static void michael_init(void *ctx)
75{
76 struct michael_mic_ctx *mctx = ctx;
77 mctx->pending_len = 0;
78}
79
80
81static void michael_update(void *ctx, const u8 *data, unsigned int len)
82{
83 struct michael_mic_ctx *mctx = ctx;
84
85 if (mctx->pending_len) {
86 int flen = 4 - mctx->pending_len;
87 if (flen > len)
88 flen = len;
89 memcpy(&mctx->pending[mctx->pending_len], data, flen);
90 mctx->pending_len += flen;
91 data += flen;
92 len -= flen;
93
94 if (mctx->pending_len < 4)
95 return;
96
97 mctx->l ^= get_le32(mctx->pending);
98 michael_block(mctx->l, mctx->r);
99 mctx->pending_len = 0;
100 }
101
102 while (len >= 4) {
103 mctx->l ^= get_le32(data);
104 michael_block(mctx->l, mctx->r);
105 data += 4;
106 len -= 4;
107 }
108
109 if (len > 0) {
110 mctx->pending_len = len;
111 memcpy(mctx->pending, data, len);
112 }
113}
114
115
116static void michael_final(void *ctx, u8 *out)
117{
118 struct michael_mic_ctx *mctx = ctx;
119 u8 *data = mctx->pending;
120
121 /* Last block and padding (0x5a, 4..7 x 0) */
122 switch (mctx->pending_len) {
123 case 0:
124 mctx->l ^= 0x5a;
125 break;
126 case 1:
127 mctx->l ^= data[0] | 0x5a00;
128 break;
129 case 2:
130 mctx->l ^= data[0] | (data[1] << 8) | 0x5a0000;
131 break;
132 case 3:
133 mctx->l ^= data[0] | (data[1] << 8) | (data[2] << 16) |
134 0x5a000000;
135 break;
136 }
137 michael_block(mctx->l, mctx->r);
138 /* l ^= 0; */
139 michael_block(mctx->l, mctx->r);
140
141 put_le32(out, mctx->l);
142 put_le32(out + 4, mctx->r);
143}
144
145
146static int michael_setkey(void *ctx, const u8 *key, unsigned int keylen,
147 u32 *flags)
148{
149 struct michael_mic_ctx *mctx = ctx;
150 if (keylen != 8) {
151 if (flags)
152 *flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
153 return -EINVAL;
154 }
155 mctx->l = get_le32(key);
156 mctx->r = get_le32(key + 4);
157 return 0;
158}
159
160
161static struct crypto_alg michael_mic_alg = {
162 .cra_name = "michael_mic",
163 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
164 .cra_blocksize = 8,
165 .cra_ctxsize = sizeof(struct michael_mic_ctx),
166 .cra_module = THIS_MODULE,
167 .cra_list = LIST_HEAD_INIT(michael_mic_alg.cra_list),
168 .cra_u = { .digest = {
169 .dia_digestsize = 8,
170 .dia_init = michael_init,
171 .dia_update = michael_update,
172 .dia_final = michael_final,
173 .dia_setkey = michael_setkey } }
174};
175
176
177static int __init michael_mic_init(void)
178{
179 return crypto_register_alg(&michael_mic_alg);
180}
181
182
183static void __exit michael_mic_exit(void)
184{
185 crypto_unregister_alg(&michael_mic_alg);
186}
187
188
189module_init(michael_mic_init);
190module_exit(michael_mic_exit);
191
192MODULE_LICENSE("GPL v2");
193MODULE_DESCRIPTION("Michael MIC");
194MODULE_AUTHOR("Jouni Malinen <jkmaline@cc.hut.fi>");
diff --git a/drivers/staging/rtl8192e/ieee80211/proc.c b/drivers/staging/rtl8192e/ieee80211/proc.c
deleted file mode 100644
index 4f3f9ed7751a..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/proc.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2 * Scatterlist Cryptographic API.
3 *
4 * Procfs information.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14#include <linux/init.h>
15//#include <linux/crypto.h>
16#include "rtl_crypto.h"
17#include <linux/rwsem.h>
18#include <linux/proc_fs.h>
19#include <linux/seq_file.h>
20#include "internal.h"
21
22extern struct list_head crypto_alg_list;
23extern struct rw_semaphore crypto_alg_sem;
24
25static void *c_start(struct seq_file *m, loff_t *pos)
26{
27 struct list_head *v;
28 loff_t n = *pos;
29
30 down_read(&crypto_alg_sem);
31 list_for_each(v, &crypto_alg_list)
32 if (!n--)
33 return list_entry(v, struct crypto_alg, cra_list);
34 return NULL;
35}
36
37static void *c_next(struct seq_file *m, void *p, loff_t *pos)
38{
39 struct list_head *v = p;
40
41 (*pos)++;
42 v = v->next;
43 return (v == &crypto_alg_list) ?
44 NULL : list_entry(v, struct crypto_alg, cra_list);
45}
46
47static void c_stop(struct seq_file *m, void *p)
48{
49 up_read(&crypto_alg_sem);
50}
51
52static int c_show(struct seq_file *m, void *p)
53{
54 struct crypto_alg *alg = (struct crypto_alg *)p;
55
56 seq_printf(m, "name : %s\n", alg->cra_name);
57 seq_printf(m, "module : %s\n",
58 (alg->cra_module ?
59 alg->cra_module->name :
60 "kernel"));
61
62 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
63 case CRYPTO_ALG_TYPE_CIPHER:
64 seq_printf(m, "type : cipher\n");
65 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
66 seq_printf(m, "min keysize : %u\n",
67 alg->cra_cipher.cia_min_keysize);
68 seq_printf(m, "max keysize : %u\n",
69 alg->cra_cipher.cia_max_keysize);
70 break;
71
72 case CRYPTO_ALG_TYPE_DIGEST:
73 seq_printf(m, "type : digest\n");
74 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
75 seq_printf(m, "digestsize : %u\n",
76 alg->cra_digest.dia_digestsize);
77 break;
78 case CRYPTO_ALG_TYPE_COMPRESS:
79 seq_printf(m, "type : compression\n");
80 break;
81 default:
82 seq_printf(m, "type : unknown\n");
83 break;
84 }
85
86 seq_putc(m, '\n');
87 return 0;
88}
89
90static struct seq_operations crypto_seq_ops = {
91 .start = c_start,
92 .next = c_next,
93 .stop = c_stop,
94 .show = c_show
95};
96
97static int crypto_info_open(struct inode *inode, struct file *file)
98{
99 return seq_open(file, &crypto_seq_ops);
100}
101
102static struct file_operations proc_crypto_ops = {
103 .open = crypto_info_open,
104 .read = seq_read,
105 .llseek = seq_lseek,
106 .release = seq_release
107};
108
109void __init crypto_init_proc(void)
110{
111 struct proc_dir_entry *proc;
112
113 proc = create_proc_entry("crypto", 0, NULL);
114 if (proc)
115 proc->proc_fops = &proc_crypto_ops;
116}
diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h
index f7b882b99d14..a50ee0e1c059 100644
--- a/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/ieee80211/rtl819x_Qos.h
@@ -1,7 +1,6 @@
1#ifndef __INC_QOS_TYPE_H 1#ifndef __INC_QOS_TYPE_H
2#define __INC_QOS_TYPE_H 2#define __INC_QOS_TYPE_H
3 3
4//#include "EndianFree.h"
5#define BIT0 0x00000001 4#define BIT0 0x00000001
6#define BIT1 0x00000002 5#define BIT1 0x00000002
7#define BIT2 0x00000004 6#define BIT2 0x00000004
diff --git a/drivers/staging/rtl8192e/ieee80211/scatterwalk.c b/drivers/staging/rtl8192e/ieee80211/scatterwalk.c
deleted file mode 100644
index 49f401fbce88..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/scatterwalk.c
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Cipher operations.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 * 2002 Adam J. Richter <adam@yggdrasil.com>
8 * 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 */
16#include "kmap_types.h"
17
18#include <linux/kernel.h>
19#include <linux/mm.h>
20#include <linux/pagemap.h>
21#include <linux/highmem.h>
22#include <asm/scatterlist.h>
23#include "internal.h"
24#include "scatterwalk.h"
25
26enum km_type crypto_km_types[] = {
27 KM_USER0,
28 KM_USER1,
29 KM_SOFTIRQ0,
30 KM_SOFTIRQ1,
31};
32
33void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch)
34{
35 if (nbytes <= walk->len_this_page &&
36 (((unsigned long)walk->data) & (PAGE_CACHE_SIZE - 1)) + nbytes <=
37 PAGE_CACHE_SIZE)
38 return walk->data;
39 else
40 return scratch;
41}
42
43static void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out)
44{
45 if (out)
46 memcpy(sgdata, buf, nbytes);
47 else
48 memcpy(buf, sgdata, nbytes);
49}
50
51void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg)
52{
53 unsigned int rest_of_page;
54
55 walk->sg = sg;
56
57 walk->page = sg->page;
58 walk->len_this_segment = sg->length;
59
60 rest_of_page = PAGE_CACHE_SIZE - (sg->offset & (PAGE_CACHE_SIZE - 1));
61 walk->len_this_page = min(sg->length, rest_of_page);
62 walk->offset = sg->offset;
63}
64
65void scatterwalk_map(struct scatter_walk *walk, int out)
66{
67 walk->data = crypto_kmap(walk->page, out) + walk->offset;
68}
69
70static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
71 unsigned int more)
72{
73 /* walk->data may be pointing the first byte of the next page;
74 however, we know we transfered at least one byte. So,
75 walk->data - 1 will be a virtual address in the mapped page. */
76
77 if (out)
78 flush_dcache_page(walk->page);
79
80 if (more) {
81 walk->len_this_segment -= walk->len_this_page;
82
83 if (walk->len_this_segment) {
84 walk->page++;
85 walk->len_this_page = min(walk->len_this_segment,
86 (unsigned)PAGE_CACHE_SIZE);
87 walk->offset = 0;
88 }
89 else
90 scatterwalk_start(walk, sg_next(walk->sg));
91 }
92}
93
94void scatterwalk_done(struct scatter_walk *walk, int out, int more)
95{
96 crypto_kunmap(walk->data, out);
97 if (walk->len_this_page == 0 || !more)
98 scatterwalk_pagedone(walk, out, more);
99}
100
101/*
102 * Do not call this unless the total length of all of the fragments
103 * has been verified as multiple of the block size.
104 */
105int scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
106 size_t nbytes, int out)
107{
108 if (buf != walk->data) {
109 while (nbytes > walk->len_this_page) {
110 memcpy_dir(buf, walk->data, walk->len_this_page, out);
111 buf += walk->len_this_page;
112 nbytes -= walk->len_this_page;
113
114 crypto_kunmap(walk->data, out);
115 scatterwalk_pagedone(walk, out, 1);
116 scatterwalk_map(walk, out);
117 }
118
119 memcpy_dir(buf, walk->data, nbytes, out);
120 }
121
122 walk->offset += nbytes;
123 walk->len_this_page -= nbytes;
124 walk->len_this_segment -= nbytes;
125 return 0;
126}
diff --git a/drivers/staging/rtl8192e/ieee80211/scatterwalk.h b/drivers/staging/rtl8192e/ieee80211/scatterwalk.h
deleted file mode 100644
index b16446519017..000000000000
--- a/drivers/staging/rtl8192e/ieee80211/scatterwalk.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com>
6 * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14
15#ifndef _CRYPTO_SCATTERWALK_H
16#define _CRYPTO_SCATTERWALK_H
17#include <linux/mm.h>
18#include <asm/scatterlist.h>
19
20struct scatter_walk {
21 struct scatterlist *sg;
22 struct page *page;
23 void *data;
24 unsigned int len_this_page;
25 unsigned int len_this_segment;
26 unsigned int offset;
27};
28
29/* Define sg_next is an inline routine now in case we want to change
30 scatterlist to a linked list later. */
31static inline struct scatterlist *sg_next(struct scatterlist *sg)
32{
33 return sg + 1;
34}
35
36static inline int scatterwalk_samebuf(struct scatter_walk *walk_in,
37 struct scatter_walk *walk_out,
38 void *src_p, void *dst_p)
39{
40 return walk_in->page == walk_out->page &&
41 walk_in->offset == walk_out->offset &&
42 walk_in->data == src_p && walk_out->data == dst_p;
43}
44
45void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch);
46void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
47int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out);
48void scatterwalk_map(struct scatter_walk *walk, int out);
49void scatterwalk_done(struct scatter_walk *walk, int out, int more);
50
51#endif /* _CRYPTO_SCATTERWALK_H */