Staging: add Realtek 8192 PCI wireless driver
[safe/jmp/linux-2.6] / drivers / staging / rtl8192e / ieee80211 / crypto_compat.h
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
14 static 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
24 static 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  */
41 void 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