* [PATCH] lib80211: Introduce TKIP_HDR_LEN define for code clarity
@ 2010-02-02 11:11 Andriy Tkachuk
2010-02-02 14:31 ` John W. Linville
0 siblings, 1 reply; 3+ messages in thread
From: Andriy Tkachuk @ 2010-02-02 11:11 UTC (permalink / raw)
To: linux-wireless; +Cc: Jouni Malinen, John W. Linville
Introduce TKIP_HDR_LEN define for code clarity (in the same way as
CCMP_HDR_LEN).
Also odd len variable (not used) dropped from lib80211_tkip_hdr().
Signed-off-by: Andriy V. Tkachuk <andrit@ukr.net>
---
net/wireless/lib80211_crypt_tkip.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/wireless/lib80211_crypt_tkip.c
b/net/wireless/lib80211_crypt_tkip.c
index c362873..c4fb4fb 100644
--- a/net/wireless/lib80211_crypt_tkip.c
+++ b/net/wireless/lib80211_crypt_tkip.c
@@ -36,6 +36,8 @@ MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("lib80211 crypt: TKIP");
MODULE_LICENSE("GPL");
+#define TKIP_HDR_LEN 8
+
struct lib80211_tkip_data {
#define TKIP_KEY_LEN 32
u8 key[TKIP_KEY_LEN];
@@ -314,13 +316,12 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
u8 * rc4key, int keylen, void *priv)
{
struct lib80211_tkip_data *tkey = priv;
- int len;
u8 *pos;
struct ieee80211_hdr *hdr;
hdr = (struct ieee80211_hdr *)skb->data;
- if (skb_headroom(skb) < 8 || skb->len < hdr_len)
+ if (skb_headroom(skb) < TKIP_HDR_LEN || skb->len < hdr_len)
return -1;
if (rc4key == NULL || keylen < 16)
@@ -333,9 +334,8 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
}
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
- len = skb->len - hdr_len;
- pos = skb_push(skb, 8);
- memmove(pos, pos + 8, hdr_len);
+ pos = skb_push(skb, TKIP_HDR_LEN);
+ memmove(pos, pos + TKIP_HDR_LEN, hdr_len);
pos += hdr_len;
*pos++ = *rc4key;
@@ -353,7 +353,7 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
tkey->tx_iv32++;
}
- return 8;
+ return TKIP_HDR_LEN;
}
static int lib80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void
*priv)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib80211: Introduce TKIP_HDR_LEN define for code clarity
2010-02-02 11:11 Andriy Tkachuk
@ 2010-02-02 14:31 ` John W. Linville
0 siblings, 0 replies; 3+ messages in thread
From: John W. Linville @ 2010-02-02 14:31 UTC (permalink / raw)
To: Andriy Tkachuk; +Cc: linux-wireless, Jouni Malinen
On Tue, Feb 02, 2010 at 01:11:10PM +0200, Andriy Tkachuk wrote:
> Introduce TKIP_HDR_LEN define for code clarity (in the same way as
> CCMP_HDR_LEN).
>
> Also odd len variable (not used) dropped from lib80211_tkip_hdr().
>
> Signed-off-by: Andriy V. Tkachuk <andrit@ukr.net>
>
> ---
> net/wireless/lib80211_crypt_tkip.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net/wireless/lib80211_crypt_tkip.c
> b/net/wireless/lib80211_crypt_tkip.c
> index c362873..c4fb4fb 100644
> --- a/net/wireless/lib80211_crypt_tkip.c
> +++ b/net/wireless/lib80211_crypt_tkip.c
> @@ -36,6 +36,8 @@ MODULE_AUTHOR("Jouni Malinen");
> MODULE_DESCRIPTION("lib80211 crypt: TKIP");
> MODULE_LICENSE("GPL");
>
> +#define TKIP_HDR_LEN 8
> +
> struct lib80211_tkip_data {
> #define TKIP_KEY_LEN 32
> u8 key[TKIP_KEY_LEN];
> @@ -314,13 +316,12 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
> int hdr_len,
After a quick look, this and the other patch look fine. But, the
patches are whitespace-damaged. I can fix these, but in the future
please be sure to use a mailer that does not break lines. I recommend
mutt and/or 'git send-email'.
Thanks,
John
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] lib80211: Introduce TKIP_HDR_LEN define for code clarity
@ 2010-02-02 14:33 Andriy Tkachuk
0 siblings, 0 replies; 3+ messages in thread
From: Andriy Tkachuk @ 2010-02-02 14:33 UTC (permalink / raw)
To: linux-wireless; +Cc: Jouni Malinen, John W. Linville
Introduce TKIP_HDR_LEN define for code clarity (in the same way as
CCMP_HDR_LEN).
Also odd len variable (not used) dropped from lib80211_tkip_hdr().
Signed-off-by: Andriy V. Tkachuk <andrit@ukr.net>
---
Found few more candidates for TKIP_HDR_LEN usage comparing to prev. patch.
diff --git a/net/wireless/lib80211_crypt_tkip.c
b/net/wireless/lib80211_crypt_tkip.c
index c362873..8cbdb32 100644
--- a/net/wireless/lib80211_crypt_tkip.c
+++ b/net/wireless/lib80211_crypt_tkip.c
@@ -36,6 +36,8 @@ MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("lib80211 crypt: TKIP");
MODULE_LICENSE("GPL");
+#define TKIP_HDR_LEN 8
+
struct lib80211_tkip_data {
#define TKIP_KEY_LEN 32
u8 key[TKIP_KEY_LEN];
@@ -314,13 +316,12 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
u8 * rc4key, int keylen, void *priv)
{
struct lib80211_tkip_data *tkey = priv;
- int len;
u8 *pos;
struct ieee80211_hdr *hdr;
hdr = (struct ieee80211_hdr *)skb->data;
- if (skb_headroom(skb) < 8 || skb->len < hdr_len)
+ if (skb_headroom(skb) < TKIP_HDR_LEN || skb->len < hdr_len)
return -1;
if (rc4key == NULL || keylen < 16)
@@ -333,9 +334,8 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
}
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
- len = skb->len - hdr_len;
- pos = skb_push(skb, 8);
- memmove(pos, pos + 8, hdr_len);
+ pos = skb_push(skb, TKIP_HDR_LEN);
+ memmove(pos, pos + TKIP_HDR_LEN, hdr_len);
pos += hdr_len;
*pos++ = *rc4key;
@@ -353,7 +353,7 @@ static int lib80211_tkip_hdr(struct sk_buff *skb,
int hdr_len,
tkey->tx_iv32++;
}
- return 8;
+ return TKIP_HDR_LEN;
}
static int lib80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void
*priv)
@@ -434,7 +433,7 @@ static int lib80211_tkip_decrypt(struct sk_buff
*skb, int hdr_len, void *priv)
return -1;
}
- if (skb->len < hdr_len + 8 + 4)
+ if (skb->len < hdr_len + TKIP_HDR_LEN + 4)
return -1;
pos = skb->data + hdr_len;
@@ -462,7 +461,7 @@ static int lib80211_tkip_decrypt(struct sk_buff
*skb, int hdr_len, void *priv)
}
iv16 = (pos[0] << 8) | pos[2];
iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
- pos += 8;
+ pos += TKIP_HDR_LEN;
if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) {
#ifdef CONFIG_LIB80211_DEBUG
@@ -523,8 +522,8 @@ static int lib80211_tkip_decrypt(struct sk_buff
*skb, int hdr_len, void *priv)
tkey->rx_iv16_new = iv16;
/* Remove IV and ICV */
- memmove(skb->data + 8, skb->data, hdr_len);
- skb_pull(skb, 8);
+ memmove(skb->data + TKIP_HDR_LEN, skb->data, hdr_len);
+ skb_pull(skb, TKIP_HDR_LEN);
skb_trim(skb, skb->len - 4);
return keyidx;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-02 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 14:33 [PATCH] lib80211: Introduce TKIP_HDR_LEN define for code clarity Andriy Tkachuk
-- strict thread matches above, loose matches on Subject: below --
2010-02-02 11:11 Andriy Tkachuk
2010-02-02 14:31 ` John W. Linville
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).