Skip to content

Commit c644bce

Browse files
hharrisonlinvjw
authored andcommitted
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>
1 parent 7c70537 commit c644bce

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

‎net/mac80211/tkip.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,27 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
153153
{
154154
struct ieee80211_key *key = (struct ieee80211_key *)
155155
container_of(keyconf, struct ieee80211_key, conf);
156-
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
157-
u8 *data = (u8 *) hdr;
158-
u16 fc = le16_to_cpu(hdr->frame_control);
159-
int hdr_len = ieee80211_get_hdrlen(fc);
160-
u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY];
161-
u8 *ta = hdr->addr2;
156+
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
157+
u8 *data;
158+
const u8 *tk;
159+
struct tkip_ctx *ctx;
162160
u16 iv16;
163161
u32 iv32;
164162

165-
iv16 = data[hdr_len + 2] | (data[hdr_len] << 8);
166-
iv32 = get_unaligned_le32(data + hdr_len + 4);
163+
data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
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;
167169

168170
#ifdef CONFIG_TKIP_DEBUG
169171
printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n",
170172
iv16, iv32);
171173

172-
if (iv32 != key->u.tkip.tx.iv32) {
174+
if (iv32 != ctx->iv32) {
173175
printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n",
174-
iv32, key->u.tkip.tx.iv32);
176+
iv32, ctx->iv32);
175177
printk(KERN_DEBUG "Wrap around of iv16 in the middle of a "
176178
"fragmented packet\n");
177179
}
@@ -180,15 +182,15 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
180182
/* Update the p1k only when the iv16 in the packet wraps around, this
181183
* might occur after the wrap around of iv16 in the key in case of
182184
* fragmented packets. */
183-
if (iv16 == 0 || !key->u.tkip.tx.initialized)
184-
tkip_mixing_phase1(tk, &key->u.tkip.tx, ta, iv32);
185+
if (iv16 == 0 || !ctx->initialized)
186+
tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32);
185187

186188
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);
188190
return;
189191
}
190192

191-
tkip_mixing_phase2(tk, &key->u.tkip.tx, iv16, outkey);
193+
tkip_mixing_phase2(tk, ctx, iv16, outkey);
192194
}
193195
EXPORT_SYMBOL(ieee80211_get_tkip_key);
194196

0 commit comments

Comments
 (0)