diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-06-11 17:22:02 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-14 12:18:14 -0400 |
commit | c644bce95f287e763a0b49e5d03f0fe6256f6d2e (patch) | |
tree | 714e2209e13f30c1b81b0f1ea2ad6022dc033718 /net | |
parent | 7c70537f97fe35f46762247a4bda72c16d585736 (diff) |
mac80211: tkip.c use a local struct tkip_ctx in ieee80211_get_tkip_key
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/tkip.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c index 8a7dac742b71..e710243d82e2 100644 --- a/net/mac80211/tkip.c +++ b/net/mac80211/tkip.c | |||
@@ -153,25 +153,27 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, | |||
153 | { | 153 | { |
154 | struct ieee80211_key *key = (struct ieee80211_key *) | 154 | struct ieee80211_key *key = (struct ieee80211_key *) |
155 | container_of(keyconf, struct ieee80211_key, conf); | 155 | container_of(keyconf, struct ieee80211_key, conf); |
156 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 156 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
157 | u8 *data = (u8 *) hdr; | 157 | u8 *data; |
158 | u16 fc = le16_to_cpu(hdr->frame_control); | 158 | const u8 *tk; |
159 | int hdr_len = ieee80211_get_hdrlen(fc); | 159 | struct tkip_ctx *ctx; |
160 | u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; | ||
161 | u8 *ta = hdr->addr2; | ||
162 | u16 iv16; | 160 | u16 iv16; |
163 | u32 iv32; | 161 | u32 iv32; |
164 | 162 | ||
165 | iv16 = data[hdr_len + 2] | (data[hdr_len] << 8); | 163 | data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); |
166 | iv32 = get_unaligned_le32(data + hdr_len + 4); | 164 | iv16 = data[2] | (data[0] << 8); |
165 | iv32 = get_unaligned_le32(&data[4]); | ||
166 | |||
167 | tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; | ||
168 | ctx = &key->u.tkip.tx; | ||
167 | 169 | ||
168 | #ifdef CONFIG_TKIP_DEBUG | 170 | #ifdef CONFIG_TKIP_DEBUG |
169 | printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n", | 171 | printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n", |
170 | iv16, iv32); | 172 | iv16, iv32); |
171 | 173 | ||
172 | if (iv32 != key->u.tkip.tx.iv32) { | 174 | if (iv32 != ctx->iv32) { |
173 | printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n", | 175 | printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n", |
174 | iv32, key->u.tkip.tx.iv32); | 176 | iv32, ctx->iv32); |
175 | printk(KERN_DEBUG "Wrap around of iv16 in the middle of a " | 177 | printk(KERN_DEBUG "Wrap around of iv16 in the middle of a " |
176 | "fragmented packet\n"); | 178 | "fragmented packet\n"); |
177 | } | 179 | } |
@@ -180,15 +182,15 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, | |||
180 | /* Update the p1k only when the iv16 in the packet wraps around, this | 182 | /* Update the p1k only when the iv16 in the packet wraps around, this |
181 | * might occur after the wrap around of iv16 in the key in case of | 183 | * might occur after the wrap around of iv16 in the key in case of |
182 | * fragmented packets. */ | 184 | * fragmented packets. */ |
183 | if (iv16 == 0 || !key->u.tkip.tx.initialized) | 185 | if (iv16 == 0 || !ctx->initialized) |
184 | tkip_mixing_phase1(tk, &key->u.tkip.tx, ta, iv32); | 186 | tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32); |
185 | 187 | ||
186 | if (type == IEEE80211_TKIP_P1_KEY) { | 188 | if (type == IEEE80211_TKIP_P1_KEY) { |
187 | memcpy(outkey, key->u.tkip.tx.p1k, sizeof(u16) * 5); | 189 | memcpy(outkey, ctx->p1k, sizeof(u16) * 5); |
188 | return; | 190 | return; |
189 | } | 191 | } |
190 | 192 | ||
191 | tkip_mixing_phase2(tk, &key->u.tkip.tx, iv16, outkey); | 193 | tkip_mixing_phase2(tk, ctx, iv16, outkey); |
192 | } | 194 | } |
193 | EXPORT_SYMBOL(ieee80211_get_tkip_key); | 195 | EXPORT_SYMBOL(ieee80211_get_tkip_key); |
194 | 196 | ||