diff options
author | Mike McCormack <mikem@ring3k.org> | 2011-07-11 08:56:20 +0900 |
---|---|---|
committer | Larry Finger <Larry.Finger@lwfinger.net> | 2011-08-23 20:02:27 -0500 |
commit | cb76215448947ddcc133c4b1c2ff2d4a77e851e0 (patch) | |
tree | fd624f3b0be586b9a1e182b0e5fa68f40db34132 /drivers/staging/rtl8192e/rtllib_crypt_tkip.c | |
parent | 1ec3e2f255c597c4bff693d0b045a49b12c5bb90 (diff) |
rtl8192e: Remove extra ifdefs
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Mike McCormack <mikem@ring3k.org>
Diffstat (limited to 'drivers/staging/rtl8192e/rtllib_crypt_tkip.c')
-rw-r--r-- | drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 189 |
1 files changed, 2 insertions, 187 deletions
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index ad9a62f4c393..366c94325a70 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -22,16 +22,8 @@ #include "rtllib.h" -#if defined(BUILT_IN_CRYPTO) || (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 <linux/scatterlist.h> #include <linux/crc32.h> @@ -58,17 +50,10 @@ struct rtllib_tkip_data { u32 dot11RSNAStatsTKIPLocalMICFailures; int key_idx; -#if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct crypto_blkcipher *rx_tfm_arc4; struct crypto_hash *rx_tfm_michael; struct crypto_blkcipher *tx_tfm_arc4; struct crypto_hash *tx_tfm_michael; -#else - struct crypto_tfm *tx_tfm_arc4; - struct crypto_tfm *tx_tfm_michael; - struct crypto_tfm *rx_tfm_arc4; - struct crypto_tfm *rx_tfm_michael; -#endif /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; }; @@ -82,35 +67,6 @@ static void * rtllib_tkip_init(int key_idx) goto fail; memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); - if (priv->tx_tfm_arc4 == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API arc4\n"); - goto fail; - } - - priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); - if (priv->tx_tfm_michael == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API michael_mic\n"); - goto fail; - } - - priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0); - if (priv->rx_tfm_arc4 == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API arc4\n"); - goto fail; - } - - priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0); - if (priv->rx_tfm_michael == NULL) { - printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate " - "crypto API michael_mic\n"); - goto fail; - } -#else priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_arc4)) { @@ -146,22 +102,10 @@ static void * rtllib_tkip_init(int key_idx) priv->rx_tfm_michael = NULL; goto fail; } -#endif return priv; fail: if (priv) { -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (priv->tx_tfm_michael) - crypto_free_tfm(priv->tx_tfm_michael); - if (priv->tx_tfm_arc4) - crypto_free_tfm(priv->tx_tfm_arc4); - if (priv->rx_tfm_michael) - crypto_free_tfm(priv->rx_tfm_michael); - if (priv->rx_tfm_arc4) - crypto_free_tfm(priv->rx_tfm_arc4); - -#else if (priv->tx_tfm_michael) crypto_free_hash(priv->tx_tfm_michael); if (priv->tx_tfm_arc4) @@ -170,7 +114,6 @@ fail: crypto_free_hash(priv->rx_tfm_michael); if (priv->rx_tfm_arc4) crypto_free_blkcipher(priv->rx_tfm_arc4); -#endif kfree(priv); } @@ -181,16 +124,7 @@ fail: static void rtllib_tkip_deinit(void *priv) { struct rtllib_tkip_data *_priv = priv; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (_priv->tx_tfm_michael) - crypto_free_tfm(_priv->tx_tfm_michael); - if (_priv->tx_tfm_arc4) - crypto_free_tfm(_priv->tx_tfm_arc4); - if (_priv->rx_tfm_michael) - crypto_free_tfm(_priv->rx_tfm_michael); - if (_priv->rx_tfm_arc4) - crypto_free_tfm(_priv->rx_tfm_arc4); -#else + if (_priv) { if (_priv->tx_tfm_michael) crypto_free_hash(_priv->tx_tfm_michael); @@ -201,7 +135,6 @@ static void rtllib_tkip_deinit(void *priv) if (_priv->rx_tfm_arc4) crypto_free_blkcipher(_priv->rx_tfm_arc4); } -#endif kfree(priv); } @@ -371,11 +304,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 *pos; struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; - #endif u8 rc4key[16], *icv; u32 crc; struct scatterlist sg; @@ -426,23 +356,11 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) icv[2] = crc >> 16; icv[3] = crc >> 24; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = len + 4; -#else sg_init_one(&sg, pos, len+4); -#endif -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); - crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4); -#else crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); -#endif - } tkey->tx_iv16++; @@ -452,11 +370,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tcb_desc->bHwSec) - #if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - return 0; - #else return ret; - #endif else return 0; @@ -471,9 +385,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u16 iv16; struct rtllib_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - #if ( !defined(BUILT_IN_CRYPTO) && ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED)) ) struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; - #endif u8 rc4key[16]; u8 icv[4]; u32 crc; @@ -533,18 +445,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) plen = skb->len - hdr_len - 12; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - sg.page = virt_to_page(pos); - sg.offset = offset_in_page(pos); - sg.length = plen + 4; -#else sg_init_one(&sg, pos, plen+4); -#endif -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); - crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4); -#else crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { @@ -554,13 +456,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } return -7; } -#endif - #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) crc = ~crc32_le(~0, pos, plen); - #else - crc = ~ether_crc_le(plen, pos); - #endif icv[0] = crc; icv[1] = crc >> 8; icv[2] = crc >> 16; @@ -607,51 +504,6 @@ if ( ((u16*)skb->data)[0] & 0x4000){ } -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) -static int michael_mic(struct crypto_tfm * tfm_michael, u8 *key, u8 *hdr, - u8 *data, size_t data_len, u8 *mic) -{ - struct scatterlist sg[2]; -#if ( !defined(BUILT_IN_CRYPTO) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) ) - struct hash_desc desc; - int ret = 0; -#endif - - if (tfm_michael == NULL){ - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - sg[0].page = virt_to_page(hdr); - sg[0].offset = offset_in_page(hdr); - sg[0].length = 16; - - sg[1].page = virt_to_page(data); - sg[1].offset = offset_in_page(data); - sg[1].length = data_len; -#else - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); -#endif - -#if ( defined(BUILT_IN_CRYPTO) || LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) ) - crypto_digest_init(tfm_michael); - crypto_digest_setkey(tfm_michael, key, 8); - crypto_digest_update(tfm_michael, sg, 2); - crypto_digest_final(tfm_michael, mic); - return 0; -#else -if (crypto_hash_setkey(tkey->tfm_michael, key, 8)) - return -1; - - desc.tfm = tkey->tfm_michael; - desc.flags = 0; - ret = crypto_hash_digest(&desc, sg, data_len + 16, mic); - return ret; -#endif -} -#else static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, u8 * data, size_t data_len, u8 * mic) { @@ -662,19 +514,9 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); return -1; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - sg[0].page = virt_to_page(hdr); - sg[0].offset = offset_in_page(hdr); - sg[0].length = 16; - - sg[1].page = virt_to_page(data); - sg[1].offset = offset_in_page(data); - sg[1].length = data_len; -#else sg_init_table(sg, 2); sg_set_buf(&sg[0], hdr, 16); sg_set_buf(&sg[1], data, data_len); -#endif if (crypto_hash_setkey(tfm_michael, key, 8)) return -1; @@ -683,9 +525,6 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, desc.flags = 0; return crypto_hash_digest(&desc, sg, data_len + 16, mic); } -#endif - - static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) { @@ -739,13 +578,8 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } pos = skb_put(skb, 8); -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) -#else - if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) -#endif return -1; return 0; @@ -814,13 +648,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; } -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) -#else if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) -#endif return -1; if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { @@ -856,32 +685,18 @@ static int rtllib_tkip_set_key(void *key, int len, u8 *seq, void *priv) { struct rtllib_tkip_data *tkey = priv; int keyidx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - struct crypto_tfm *tfm = tkey->tx_tfm_michael; - struct crypto_tfm *tfm2 = tkey->tx_tfm_arc4; - struct crypto_tfm *tfm3 = tkey->rx_tfm_michael; - struct crypto_tfm *tfm4 = tkey->rx_tfm_arc4; -#else struct crypto_hash *tfm = tkey->tx_tfm_michael; struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; struct crypto_hash *tfm3 = tkey->rx_tfm_michael; struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; -#endif keyidx = tkey->key_idx; memset(tkey, 0, sizeof(*tkey)); tkey->key_idx = keyidx; -#if ( defined(BUILT_IN_CRYPTO) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED)) ) - tkey->tx_tfm_michael = tfm; - tkey->tx_tfm_arc4 = tfm2; - tkey->rx_tfm_michael = tfm3; - tkey->rx_tfm_arc4 = tfm4; -#else tkey->tx_tfm_michael = tfm; tkey->tx_tfm_arc4 = tfm2; tkey->rx_tfm_michael = tfm3; tkey->rx_tfm_arc4 = tfm4; -#endif if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); |