summaryrefslogtreecommitdiff
path: root/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c')
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c73
1 files changed, 7 insertions, 66 deletions
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index 08add385790f..39fcabc12bef 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -24,18 +24,8 @@
#include "ieee80211.h"
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#include "rtl_crypto.h"
-#else
#include <linux/crypto.h>
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- #include <asm/scatterlist.h>
-#else
- #include <linux/scatterlist.h>
-#endif
-
-//#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Host AP crypt: CCMP");
@@ -77,21 +67,7 @@ struct ieee80211_ccmp_data {
void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
const u8 pt[16], u8 ct[16])
{
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))||(IN_OPENSUSE_SLED))
crypto_cipher_encrypt_one((void *)tfm, ct, pt);
- #else
- struct scatterlist src, dst;
-
- src.page = virt_to_page(pt);
- src.offset = offset_in_page(pt);
- src.length = AES_BLOCK_LEN;
-
- dst.page = virt_to_page(ct);
- dst.offset = offset_in_page(ct);
- dst.length = AES_BLOCK_LEN;
-
- crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
- #endif
}
static void * ieee80211_ccmp_init(int key_idx)
@@ -104,33 +80,20 @@ static void * ieee80211_ccmp_init(int key_idx)
memset(priv, 0, sizeof(*priv));
priv->key_idx = key_idx;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_OPENSUSE_SLED))
- priv->tfm = crypto_alloc_tfm("aes", 0);
- if (priv->tfm == NULL) {
- printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
- "crypto API aes\n");
- goto fail;
- }
- #else
- priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
+ priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
"crypto API aes\n");
priv->tfm = NULL;
goto fail;
}
- #endif
+
return priv;
fail:
if (priv) {
if (priv->tfm)
- //#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_OPENSUSE_SLED))
- crypto_free_tfm(priv->tfm);
- #else
crypto_free_cipher((void *)priv->tfm);
- #endif
kfree(priv);
}
@@ -141,13 +104,9 @@ fail:
static void ieee80211_ccmp_deinit(void *priv)
{
struct ieee80211_ccmp_data *_priv = priv;
+
if (_priv && _priv->tfm)
- //#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_OPENSUSE_SLED))
- crypto_free_tfm(_priv->tfm);
- #else
crypto_free_cipher((void *)_priv->tfm);
- #endif
kfree(priv);
}
@@ -159,7 +118,6 @@ static inline void xor_block(u8 *b, u8 *a, size_t len)
b[i] ^= a[i];
}
-#ifndef JOHN_CCMP
static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr *hdr,
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
@@ -237,7 +195,6 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
b0[14] = b0[15] = 0;
ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
}
-#endif
static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
@@ -245,14 +202,13 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
int data_len, i;
u8 *pos;
struct ieee80211_hdr *hdr;
-#ifndef JOHN_CCMP
int blocks, last, len;
u8 *mic;
u8 *b0 = key->tx_b0;
u8 *b = key->tx_b;
u8 *e = key->tx_e;
u8 *s0 = key->tx_s0;
-#endif
+
if (skb_headroom(skb) < CCMP_HDR_LEN ||
skb_tailroom(skb) < CCMP_MIC_LEN ||
skb->len < hdr_len)
@@ -282,7 +238,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[0];
hdr = (struct ieee80211_hdr *) skb->data;
-#ifndef JOHN_CCMP
//mic is moved to here by john
mic = skb_put(skb, CCMP_MIC_LEN);
@@ -306,7 +261,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
for (i = 0; i < CCMP_MIC_LEN; i++)
mic[i] = b[i] ^ s0[i];
-#endif
+
return 0;
}
@@ -317,14 +272,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 keyidx, *pos;
struct ieee80211_hdr *hdr;
u8 pn[6];
-#ifndef JOHN_CCMP
size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
u8 *b0 = key->rx_b0;
u8 *b = key->rx_b;
u8 *a = key->rx_a;
int i, blocks, last, len;
-#endif
+
if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
key->dot11RSNAStatsCCMPFormatErrors++;
return -1;
@@ -376,7 +330,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -4;
}
-#ifndef JOHN_CCMP
ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
xor_block(mic, b, CCMP_MIC_LEN);
@@ -407,7 +360,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
memcpy(key->rx_pn, pn, CCMP_PN_LEN);
-#endif
/* Remove hdr and MIC */
memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
skb_pull(skb, CCMP_HDR_LEN);
@@ -520,14 +472,3 @@ void ieee80211_crypto_ccmp_exit(void)
{
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
}
-
-#if 0
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-EXPORT_SYMBOL(ieee80211_ccmp_null);
-#else
-EXPORT_SYMBOL_NOVERS(ieee80211_ccmp_null);
-#endif
-#endif
-
-//module_init(ieee80211_crypto_ccmp_init);
-//module_exit(ieee80211_crypto_ccmp_exit);