Remove Host AP and Prism2 references from IEEE 802.11 crypto code. Clean
up coding style and some comments. Replace couple of kmalloc+memset with
kzalloc.
Signed-off-by: Jouni Malinen <[EMAIL PROTECTED]>
Index: wireless-2.6/include/net/ieee80211_crypt.h
===================================================================
--- wireless-2.6.orig/include/net/ieee80211_crypt.h
+++ wireless-2.6/include/net/ieee80211_crypt.h
@@ -1,10 +1,7 @@
/*
- * Original code based on Host AP (software wireless LAN access point) driver
- * for Intersil Prism2/2.5/3.
+ * This file defines the interface to the ieee80211 crypto module.
*
- * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- * <[EMAIL PROTECTED]>
- * Copyright (c) 2002-2003, Jouni Malinen <[EMAIL PROTECTED]>
+ * Copyright (c) 2002-2006, Jouni Malinen <[EMAIL PROTECTED]>
*
* Adaption to a generic IEEE 802.11 stack by James Ketrenos
* <[EMAIL PROTECTED]>
@@ -17,9 +14,6 @@
* more details.
*/
-/*
- * This file defines the interface to the ieee80211 crypto module.
- */
#ifndef IEEE80211_CRYPT_H
#define IEEE80211_CRYPT_H
@@ -42,13 +36,13 @@ struct ieee80211_crypto_ops {
/* init new crypto context (e.g., allocate private data space,
* select IV, etc.); returns NULL on failure or pointer to allocated
* private data on success */
- void *(*init) (int keyidx);
+ void *(*init)(int keyidx);
/* deinitialize crypto context and free allocated private data */
- void (*deinit) (void *priv);
+ void (*deinit)(void *priv);
- int (*build_iv) (struct sk_buff * skb, int hdr_len,
- u8 *key, int keylen, void *priv);
+ int (*build_iv)(struct sk_buff *skb, int hdr_len,
+ u8 *key, int keylen, void *priv);
/* encrypt/decrypt return < 0 on error or >= 0 on success. The return
* value from decrypt_mpdu is passed as the keyidx value for
@@ -56,25 +50,25 @@ struct ieee80211_crypto_ops {
* encryption; if not, error will be returned; these functions are
* called for all MPDUs (i.e., fragments).
*/
- int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
- int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
+ int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
/* These functions are called for full MSDUs, i.e. full frames.
* These can be NULL if full MSDU operations are not needed. */
- int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
- int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
- void *priv);
+ int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
+ void *priv);
- int (*set_key) (void *key, int len, u8 * seq, void *priv);
- int (*get_key) (void *key, int len, u8 * seq, void *priv);
+ int (*set_key)(void *key, int len, u8 *seq, void *priv);
+ int (*get_key)(void *key, int len, u8 *seq, void *priv);
/* procfs handler for printing out key information and possible
* statistics */
- char *(*print_stats) (char *p, void *priv);
+ char * (*print_stats)(char *p, void *priv);
/* Crypto specific flag get/set for configuration settings */
- unsigned long (*get_flags) (void *priv);
- unsigned long (*set_flags) (unsigned long flags, void *priv);
+ unsigned long (*get_flags)(void *priv);
+ unsigned long (*set_flags)(unsigned long flags, void *priv);
/* maximum number of bytes added by encryption; encrypt buf is
* allocated with extra_prefix_len bytes, copy of in_buf, and
@@ -88,7 +82,7 @@ struct ieee80211_crypto_ops {
};
struct ieee80211_crypt_data {
- struct list_head list; /* delayed deletion list */
+ struct list_head list; /* delayed deletion list */
struct ieee80211_crypto_ops *ops;
void *priv;
atomic_t refcnt;
@@ -98,11 +92,11 @@ struct ieee80211_device;
int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
-struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
void ieee80211_crypt_deinit_handler(unsigned long);
void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
struct ieee80211_crypt_data **crypt);
void ieee80211_crypt_quiescing(struct ieee80211_device *ieee);
-#endif
+#endif /* IEEE80211_CRYPT_H */
Index: wireless-2.6/net/ieee80211/Kconfig
===================================================================
--- wireless-2.6.orig/net/ieee80211/Kconfig
+++ wireless-2.6/net/ieee80211/Kconfig
@@ -28,14 +28,15 @@ config IEEE80211_DEBUG
subsystem, you most likely want to say N here.
config IEEE80211_CRYPT_WEP
- tristate "IEEE 802.11 WEP encryption (802.1x)"
+ tristate "IEEE 802.11 WEP encryption"
depends on IEEE80211
select CRYPTO
select CRYPTO_ARC4
select CRC32
---help---
Include software based cipher suites in support of IEEE
- 802.11's WEP. This is needed for WEP as well as 802.1x.
+ 802.11's WEP. This is needed for both static WEP and
+ IEEE 802.1X with dynamic WEP keys.
This can be compiled as a modules and it will be called
"ieee80211_crypt_wep".
@@ -47,8 +48,7 @@ config IEEE80211_CRYPT_CCMP
select CRYPTO_AES
---help---
Include software based cipher suites in support of IEEE 802.11i
- (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with CCMP enabled
- networks.
+ (aka TGi, WPA, WPA2, etc.) for use with CCMP enabled networks.
This can be compiled as a modules and it will be called
"ieee80211_crypt_ccmp".
@@ -60,8 +60,7 @@ config IEEE80211_CRYPT_TKIP
select CRYPTO_MICHAEL_MIC
---help---
Include software based cipher suites in support of IEEE 802.11i
- (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with TKIP enabled
- networks.
+ (aka TGi, WPA, WPA2, etc.) for use with TKIP enabled networks.
This can be compiled as a modules and it will be called
"ieee80211_crypt_tkip".
Index: wireless-2.6/net/ieee80211/ieee80211_crypt.c
===================================================================
--- wireless-2.6.orig/net/ieee80211/ieee80211_crypt.c
+++ wireless-2.6/net/ieee80211/ieee80211_crypt.c
@@ -1,5 +1,5 @@
/*
- * Host AP crypto routines
+ * IEEE 802.11 crypto routines
*
* Copyright (c) 2002-2003, Jouni Malinen <[EMAIL PROTECTED]>
* Portions Copyright (C) 2004, Intel Corporation <[EMAIL PROTECTED]>
@@ -19,7 +19,7 @@
#include <net/ieee80211.h>
MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("HostAP crypto");
+MODULE_DESCRIPTION("IEEE 802.11 crypto");
MODULE_LICENSE("GPL");
struct ieee80211_crypto_alg {
@@ -63,7 +63,7 @@ void ieee80211_crypt_quiescing(struct ie
void ieee80211_crypt_deinit_handler(unsigned long data)
{
- struct ieee80211_device *ieee = (struct ieee80211_device *)data;
+ struct ieee80211_device *ieee = (struct ieee80211_device *) data;
unsigned long flags;
ieee80211_crypt_deinit_entries(ieee, 0);
@@ -110,11 +110,10 @@ int ieee80211_register_crypto_ops(struct
unsigned long flags;
struct ieee80211_crypto_alg *alg;
- alg = kmalloc(sizeof(*alg), GFP_KERNEL);
+ alg = kzalloc(sizeof(*alg), GFP_KERNEL);
if (alg == NULL)
return -ENOMEM;
- memset(alg, 0, sizeof(*alg));
alg->ops = ops;
spin_lock_irqsave(&ieee80211_crypto_lock, flags);
@@ -140,7 +139,7 @@ int ieee80211_unregister_crypto_ops(stru
spin_unlock_irqrestore(&ieee80211_crypto_lock, flags);
return -EINVAL;
- found:
+found:
printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
"'%s'\n", ops->name);
list_del(&alg->list);
@@ -149,7 +148,7 @@ int ieee80211_unregister_crypto_ops(stru
return 0;
}
-struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name)
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
{
struct ieee80211_crypto_alg *alg;
unsigned long flags;
@@ -162,14 +161,14 @@ struct ieee80211_crypto_ops *ieee80211_g
spin_unlock_irqrestore(&ieee80211_crypto_lock, flags);
return NULL;
- found:
+found:
spin_unlock_irqrestore(&ieee80211_crypto_lock, flags);
return alg->ops;
}
-static void *ieee80211_crypt_null_init(int keyidx)
+static void * ieee80211_crypt_null_init(int keyidx)
{
- return (void *)1;
+ return (void *) 1;
}
static void ieee80211_crypt_null_deinit(void *priv)
Index: wireless-2.6/net/ieee80211/ieee80211_crypt_ccmp.c
===================================================================
--- wireless-2.6.orig/net/ieee80211/ieee80211_crypt_ccmp.c
+++ wireless-2.6/net/ieee80211/ieee80211_crypt_ccmp.c
@@ -1,5 +1,5 @@
/*
- * Host AP crypt: host-based CCMP encryption implementation for Host AP driver
+ * IEEE 802.11 crypt: Host-based CCMP encryption implementation
*
* Copyright (c) 2003-2004, Jouni Malinen <[EMAIL PROTECTED]>
*
@@ -27,7 +27,7 @@
#include <asm/scatterlist.h>
MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: CCMP");
+MODULE_DESCRIPTION("IEEE 802.11 crypt: CCMP");
MODULE_LICENSE("GPL");
#define AES_BLOCK_LEN 16
@@ -53,7 +53,7 @@ struct ieee80211_ccmp_data {
/* scratch buffers for virt_to_page() (crypto API) */
u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
- tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
+ tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
};
@@ -73,14 +73,13 @@ static void ieee80211_ccmp_aes_encrypt(s
crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
}
-static void *ieee80211_ccmp_init(int key_idx)
+static void * ieee80211_ccmp_init(int key_idx)
{
struct ieee80211_ccmp_data *priv;
- priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
if (priv == NULL)
goto fail;
- memset(priv, 0, sizeof(*priv));
priv->key_idx = key_idx;
priv->tfm = crypto_alloc_tfm("aes", 0);
@@ -92,7 +91,7 @@ static void *ieee80211_ccmp_init(int key
return priv;
- fail:
+fail:
if (priv) {
if (priv->tfm)
crypto_free_tfm(priv->tfm);
@@ -110,7 +109,7 @@ static void ieee80211_ccmp_deinit(void *
kfree(priv);
}
-static inline void xor_block(u8 * b, u8 * a, size_t len)
+static inline void xor_block(u8 *b, u8 *a, size_t len)
{
int i;
for (i = 0; i < len; i++)
@@ -119,7 +118,7 @@ static inline void xor_block(u8 * b, u8
static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr_4addr *hdr,
- u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0)
+ u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0)
{
u8 *pos, qc = 0;
size_t aad_len;
@@ -136,7 +135,7 @@ static void ccmp_init_blocks(struct cryp
if (a4_included)
aad_len += 6;
if (qc_included) {
- pos = (u8 *) & hdr->addr4;
+ pos = (u8 *) &hdr->addr4;
if (a4_included)
pos += 6;
qc = *pos & 0x0f;
@@ -163,14 +162,14 @@ static void ccmp_init_blocks(struct cryp
* QC (if present)
*/
pos = (u8 *) hdr;
- aad[0] = 0; /* aad_len >> 8 */
+ aad[0] = 0; /* aad_len >> 8 */
aad[1] = aad_len & 0xff;
aad[2] = pos[0] & 0x8f;
aad[3] = pos[1] & 0xc7;
memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
- pos = (u8 *) & hdr->seq_ctl;
+ pos = (u8 *) &hdr->seq_ctl;
aad[22] = pos[0] & 0x0f;
- aad[23] = 0; /* all bits masked */
+ aad[23] = 0; /* all bits masked */
memset(aad + 24, 0, 8);
if (a4_included)
memcpy(aad + 24, hdr->addr4, ETH_ALEN);
@@ -218,7 +217,7 @@ static int ieee80211_ccmp_hdr(struct sk_
*pos++ = key->tx_pn[5];
*pos++ = key->tx_pn[4];
*pos++ = 0;
- *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */ ;
+ *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
*pos++ = key->tx_pn[3];
*pos++ = key->tx_pn[2];
*pos++ = key->tx_pn[1];
@@ -248,7 +247,7 @@ static int ieee80211_ccmp_encrypt(struct
pos = skb->data + hdr_len + CCMP_HDR_LEN;
mic = skb_put(skb, CCMP_MIC_LEN);
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
@@ -291,13 +290,14 @@ static int ieee80211_ccmp_decrypt(struct
return -1;
}
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
if (net_ratelimit()) {
printk(KERN_DEBUG "CCMP: received packet without ExtIV"
- " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ " flag from " MAC_FMT "\n",
+ MAC_ARG(hdr->addr2));
}
key->dot11RSNAStatsCCMPFormatErrors++;
return -2;
@@ -375,7 +375,7 @@ static int ieee80211_ccmp_decrypt(struct
return keyidx;
}
-static int ieee80211_ccmp_set_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
{
struct ieee80211_ccmp_data *data = priv;
int keyidx;
@@ -405,7 +405,7 @@ static int ieee80211_ccmp_set_key(void *
return 0;
}
-static int ieee80211_ccmp_get_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
{
struct ieee80211_ccmp_data *data = priv;
@@ -428,7 +428,7 @@ static int ieee80211_ccmp_get_key(void *
return CCMP_TK_LEN;
}
-static char *ieee80211_ccmp_print_stats(char *p, void *priv)
+static char * ieee80211_ccmp_print_stats(char *p, void *priv)
{
struct ieee80211_ccmp_data *ccmp = priv;
p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
Index: wireless-2.6/net/ieee80211/ieee80211_crypt_tkip.c
===================================================================
--- wireless-2.6.orig/net/ieee80211/ieee80211_crypt_tkip.c
+++ wireless-2.6/net/ieee80211/ieee80211_crypt_tkip.c
@@ -1,5 +1,5 @@
/*
- * Host AP crypt: host-based TKIP encryption implementation for Host AP driver
+ * IEEE 802.11 crypt: Host-based TKIP encryption implementation
*
* Copyright (c) 2003-2004, Jouni Malinen <[EMAIL PROTECTED]>
*
@@ -27,7 +27,7 @@
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: TKIP");
+MODULE_DESCRIPTION("IEEE 802.11 crypt: TKIP");
MODULE_LICENSE("GPL");
struct ieee80211_tkip_data {
@@ -76,14 +76,13 @@ static unsigned long ieee80211_tkip_get_
return _priv->flags;
}
-static void *ieee80211_tkip_init(int key_idx)
+static void * ieee80211_tkip_init(int key_idx)
{
struct ieee80211_tkip_data *priv;
priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
if (priv == NULL)
goto fail;
-
priv->key_idx = key_idx;
priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
@@ -102,7 +101,7 @@ static void *ieee80211_tkip_init(int key
return priv;
- fail:
+fail:
if (priv) {
if (priv->tfm_michael)
crypto_free_tfm(priv->tfm_michael);
@@ -154,7 +153,7 @@ static inline u16 Mk16(u8 hi, u8 lo)
return lo | (((u16) hi) << 8);
}
-static inline u16 Mk16_le(u16 * v)
+static inline u16 Mk16_le(u16 *v)
{
return le16_to_cpu(*v);
}
@@ -202,8 +201,7 @@ static inline u16 _S_(u16 v)
#define PHASE1_LOOP_COUNT 8
-static void tkip_mixing_phase1(u16 * TTAK, const u8 * TK, const u8 * TA,
- u32 IV32)
+static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
{
int i, j;
@@ -224,12 +222,12 @@ static void tkip_mixing_phase1(u16 * TTA
}
}
-static void tkip_mixing_phase2(u8 * WEPSeed, const u8 * TK, const u16 * TTAK,
+static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
u16 IV16)
{
/* Make temporary area overlap WEP seed so that the final copy can be
* avoided on little endian hosts. */
- u16 *PPK = (u16 *) & WEPSeed[4];
+ u16 *PPK = (u16 *) &WEPSeed[4];
/* Step 1 - make copy of TTAK and bring in TSC */
PPK[0] = TTAK[0];
@@ -240,15 +238,15 @@ static void tkip_mixing_phase2(u8 * WEPS
PPK[5] = TTAK[4] + IV16;
/* Step 2 - 96-bit bijective mixing using S-box */
- PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) & TK[0]));
- PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) & TK[2]));
- PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) & TK[4]));
- PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) & TK[6]));
- PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) & TK[8]));
- PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) & TK[10]));
+ PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
+ PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
+ PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
+ PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
+ PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
+ PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
- PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) & TK[12]));
- PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) & TK[14]));
+ PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
+ PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
PPK[2] += RotR1(PPK[1]);
PPK[3] += RotR1(PPK[2]);
PPK[4] += RotR1(PPK[3]);
@@ -259,7 +257,7 @@ static void tkip_mixing_phase2(u8 * WEPS
WEPSeed[0] = Hi8(IV16);
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
WEPSeed[2] = Lo8(IV16);
- WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) & TK[0])) >> 1);
+ WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
#ifdef __BIG_ENDIAN
{
@@ -271,14 +269,14 @@ static void tkip_mixing_phase2(u8 * WEPS
}
static int ieee80211_tkip_hdr(struct sk_buff *skb, int hdr_len,
- u8 * rc4key, int keylen, void *priv)
+ u8 *rc4key, int keylen, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
int len;
u8 *pos;
struct ieee80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
if (skb_headroom(skb) < 8 || skb->len < hdr_len)
return -1;
@@ -301,7 +299,7 @@ static int ieee80211_tkip_hdr(struct sk_
*pos++ = *rc4key;
*pos++ = *(rc4key + 1);
*pos++ = *(rc4key + 2);
- *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ;
+ *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
*pos++ = tkey->tx_iv32 & 0xff;
*pos++ = (tkey->tx_iv32 >> 8) & 0xff;
*pos++ = (tkey->tx_iv32 >> 16) & 0xff;
@@ -327,7 +325,7 @@ static int ieee80211_tkip_encrypt(struct
if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
if (net_ratelimit()) {
struct ieee80211_hdr_4addr *hdr =
- (struct ieee80211_hdr_4addr *)skb->data;
+ (struct ieee80211_hdr_4addr *) skb->data;
printk(KERN_DEBUG ": TKIP countermeasures: dropped "
"TX packet to " MAC_FMT "\n",
MAC_ARG(hdr->addr1));
@@ -374,7 +372,7 @@ static int ieee80211_tkip_decrypt(struct
struct scatterlist sg;
int plen;
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
if (net_ratelimit()) {
@@ -393,7 +391,8 @@ static int ieee80211_tkip_decrypt(struct
if (!(keyidx & (1 << 5))) {
if (net_ratelimit()) {
printk(KERN_DEBUG "TKIP: received packet without ExtIV"
- " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ " flag from " MAC_FMT "\n",
+ MAC_ARG(hdr->addr2));
}
return -2;
}
@@ -473,8 +472,8 @@ static int ieee80211_tkip_decrypt(struct
return keyidx;
}
-static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,
- u8 * data, size_t data_len, u8 * mic)
+static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
+ u8 *data, size_t data_len, u8 *mic)
{
struct scatterlist sg[2];
@@ -498,33 +497,33 @@ static int michael_mic(struct ieee80211_
return 0;
}
-static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
+static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
{
struct ieee80211_hdr_4addr *hdr11;
- hdr11 = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr11 = (struct ieee80211_hdr_4addr *) skb->data;
switch (le16_to_cpu(hdr11->frame_ctl) &
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
case IEEE80211_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
break;
case IEEE80211_FCTL_FROMDS:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+ memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
break;
case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+ memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
break;
case 0:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
break;
}
- hdr[12] = 0; /* priority */
- hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
+ hdr[12] = 0; /* priority */
+ hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
}
static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len,
@@ -567,7 +566,7 @@ static void ieee80211_michael_mic_failur
memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
- wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
+ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
}
static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
@@ -585,7 +584,7 @@ static int ieee80211_michael_mic_verify(
return -1;
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
struct ieee80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
printk(KERN_DEBUG "%s: Michael MIC verification failed for "
"MSDU from " MAC_FMT " keyidx=%d\n",
skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
@@ -606,7 +605,7 @@ static int ieee80211_michael_mic_verify(
return 0;
}
-static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
int keyidx;
@@ -621,10 +620,10 @@ static int ieee80211_tkip_set_key(void *
if (len == TKIP_KEY_LEN) {
memcpy(tkey->key, key, TKIP_KEY_LEN);
tkey->key_set = 1;
- tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
+ tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
if (seq) {
tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) |
- (seq[3] << 8) | seq[2];
+ (seq[3] << 8) | seq[2];
tkey->rx_iv16 = (seq[1] << 8) | seq[0];
}
} else if (len == 0)
@@ -635,7 +634,7 @@ static int ieee80211_tkip_set_key(void *
return 0;
}
-static int ieee80211_tkip_get_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
@@ -664,7 +663,7 @@ static int ieee80211_tkip_get_key(void *
return TKIP_KEY_LEN;
}
-static char *ieee80211_tkip_print_stats(char *p, void *priv)
+static char * ieee80211_tkip_print_stats(char *p, void *priv)
{
struct ieee80211_tkip_data *tkip = priv;
p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
@@ -702,9 +701,9 @@ static struct ieee80211_crypto_ops ieee8
.set_key = ieee80211_tkip_set_key,
.get_key = ieee80211_tkip_get_key,
.print_stats = ieee80211_tkip_print_stats,
- .extra_mpdu_prefix_len = 4 + 4, /* IV + ExtIV */
- .extra_mpdu_postfix_len = 4, /* ICV */
- .extra_msdu_postfix_len = 8, /* MIC */
+ .extra_mpdu_prefix_len = 4 + 4 /* IV + ExtIV */,
+ .extra_mpdu_postfix_len = 4 /* ICV */,
+ .extra_msdu_postfix_len = 8 /* MIC */,
.get_flags = ieee80211_tkip_get_flags,
.set_flags = ieee80211_tkip_set_flags,
.owner = THIS_MODULE,
Index: wireless-2.6/net/ieee80211/ieee80211_crypt_wep.c
===================================================================
--- wireless-2.6.orig/net/ieee80211/ieee80211_crypt_wep.c
+++ wireless-2.6/net/ieee80211/ieee80211_crypt_wep.c
@@ -1,5 +1,5 @@
/*
- * Host AP crypt: host-based WEP encryption implementation for Host AP driver
+ * IEEE 802.11 crypt: Host-based WEP encryption implementation
*
* Copyright (c) 2002-2004, Jouni Malinen <[EMAIL PROTECTED]>
*
@@ -24,10 +24,10 @@
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: WEP");
+MODULE_DESCRIPTION("IEEE 802.11 crypt: WEP");
MODULE_LICENSE("GPL");
-struct prism2_wep_data {
+struct ieee80211_wep_data {
u32 iv;
#define WEP_KEY_LEN 13
u8 key[WEP_KEY_LEN + 1];
@@ -36,14 +36,13 @@ struct prism2_wep_data {
struct crypto_tfm *tfm;
};
-static void *prism2_wep_init(int keyidx)
+static void * ieee80211_wep_init(int keyidx)
{
- struct prism2_wep_data *priv;
+ struct ieee80211_wep_data *priv;
- priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
if (priv == NULL)
goto fail;
- memset(priv, 0, sizeof(*priv));
priv->key_idx = keyidx;
priv->tfm = crypto_alloc_tfm("arc4", 0);
@@ -58,7 +57,7 @@ static void *prism2_wep_init(int keyidx)
return priv;
- fail:
+fail:
if (priv) {
if (priv->tfm)
crypto_free_tfm(priv->tfm);
@@ -67,19 +66,19 @@ static void *prism2_wep_init(int keyidx)
return NULL;
}
-static void prism2_wep_deinit(void *priv)
+static void ieee80211_wep_deinit(void *priv)
{
- struct prism2_wep_data *_priv = priv;
+ struct ieee80211_wep_data *_priv = priv;
if (_priv && _priv->tfm)
crypto_free_tfm(_priv->tfm);
kfree(priv);
}
/* Add WEP IV/key info to a frame that has at least 4 bytes of headroom */
-static int prism2_wep_build_iv(struct sk_buff *skb, int hdr_len,
- u8 *key, int keylen, void *priv)
+static int ieee80211_wep_build_iv(struct sk_buff *skb, int hdr_len,
+ u8 *key, int keylen, void *priv)
{
- struct prism2_wep_data *wep = priv;
+ struct ieee80211_wep_data *wep = priv;
u32 klen, len;
u8 *pos;
@@ -119,20 +118,20 @@ static int prism2_wep_build_iv(struct sk
*
* WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
*/
-static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+static int ieee80211_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
- struct prism2_wep_data *wep = priv;
+ struct ieee80211_wep_data *wep = priv;
u32 crc, klen, len;
u8 *pos, *icv;
struct scatterlist sg;
u8 key[WEP_KEY_LEN + 3];
- /* other checks are in prism2_wep_build_iv */
+ /* other checks are in ieee80211_wep_build_iv */
if (skb_tailroom(skb) < 4)
return -1;
/* add the IV to the frame */
- if (prism2_wep_build_iv(skb, hdr_len, NULL, 0, priv))
+ if (ieee80211_wep_build_iv(skb, hdr_len, NULL, 0, priv))
return -1;
/* Copy the IV into the first 3 bytes of the key */
@@ -145,7 +144,10 @@ static int prism2_wep_encrypt(struct sk_
pos = skb->data + hdr_len + 4;
klen = 3 + wep->key_len;
- /* Append little-endian CRC32 over only the data and encrypt it to
produce ICV */
+ /*
+ * Append little-endian CRC32 over only the data and encrypt it to
+ * produce ICV.
+ */
crc = ~crc32_le(~0, pos, len);
icv = skb_put(skb, 4);
icv[0] = crc;
@@ -169,9 +171,9 @@ static int prism2_wep_encrypt(struct sk_
* Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
* failure. If frame is OK, IV and ICV will be removed.
*/
-static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+static int ieee80211_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
- struct prism2_wep_data *wep = priv;
+ struct ieee80211_wep_data *wep = priv;
u32 crc, klen, plen;
u8 key[WEP_KEY_LEN + 3];
u8 keyidx, *pos, icv[4];
@@ -220,9 +222,9 @@ static int prism2_wep_decrypt(struct sk_
return 0;
}
-static int prism2_wep_set_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_wep_set_key(void *key, int len, u8 *seq, void *priv)
{
- struct prism2_wep_data *wep = priv;
+ struct ieee80211_wep_data *wep = priv;
if (len < 0 || len > WEP_KEY_LEN)
return -1;
@@ -233,9 +235,9 @@ static int prism2_wep_set_key(void *key,
return 0;
}
-static int prism2_wep_get_key(void *key, int len, u8 * seq, void *priv)
+static int ieee80211_wep_get_key(void *key, int len, u8 *seq, void *priv)
{
- struct prism2_wep_data *wep = priv;
+ struct ieee80211_wep_data *wep = priv;
if (len < wep->key_len)
return -1;
@@ -245,27 +247,28 @@ static int prism2_wep_get_key(void *key,
return wep->key_len;
}
-static char *prism2_wep_print_stats(char *p, void *priv)
+static char * ieee80211_wep_print_stats(char *p, void *priv)
{
- struct prism2_wep_data *wep = priv;
- p += sprintf(p, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len);
+ struct ieee80211_wep_data *wep = priv;
+ p += sprintf(p, "key[%d] alg=WEP len=%d\n",
+ wep->key_idx, wep->key_len);
return p;
}
static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
.name = "WEP",
- .init = prism2_wep_init,
- .deinit = prism2_wep_deinit,
- .build_iv = prism2_wep_build_iv,
- .encrypt_mpdu = prism2_wep_encrypt,
- .decrypt_mpdu = prism2_wep_decrypt,
+ .init = ieee80211_wep_init,
+ .deinit = ieee80211_wep_deinit,
+ .build_iv = ieee80211_wep_build_iv,
+ .encrypt_mpdu = ieee80211_wep_encrypt,
+ .decrypt_mpdu = ieee80211_wep_decrypt,
.encrypt_msdu = NULL,
.decrypt_msdu = NULL,
- .set_key = prism2_wep_set_key,
- .get_key = prism2_wep_get_key,
- .print_stats = prism2_wep_print_stats,
- .extra_mpdu_prefix_len = 4, /* IV */
- .extra_mpdu_postfix_len = 4, /* ICV */
+ .set_key = ieee80211_wep_set_key,
+ .get_key = ieee80211_wep_get_key,
+ .print_stats = ieee80211_wep_print_stats,
+ .extra_mpdu_prefix_len = 4 /* IV */,
+ .extra_mpdu_postfix_len = 4 /* ICV */,
.owner = THIS_MODULE,
};
--
Jouni Malinen PGP id EFC895FA
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html