aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tkip.c
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-05-14 19:26:19 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-21 21:47:49 -0400
commit82a57447fa66bf138cd55206f33eea21ee257335 (patch)
tree62eb39abd843d0a184def33dc9aa2da8e82e6d36 /net/mac80211/tkip.c
parentb0f76b335f8b1c324b4b2be06369d391b26a7cc9 (diff)
mac80211: tkip.c use struct tkip_ctx in phase 1 key mixing
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Cc: "John W. Linville" <linville@tuxdriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/tkip.c')
-rw-r--r--net/mac80211/tkip.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index d74c91e23a7f..e9ee247e13f7 100644
--- a/net/mac80211/tkip.c
+++ b/net/mac80211/tkip.c
@@ -71,10 +71,12 @@ static u16 tkipS(u16 val)
71 * TSC = TKIP sequence counter (48 bits, only 32 msb bits used) 71 * TSC = TKIP sequence counter (48 bits, only 32 msb bits used)
72 * P1K: 80 bits 72 * P1K: 80 bits
73 */ 73 */
74static void tkip_mixing_phase1(const u8 *ta, const u8 *tk, u32 tsc_IV32, 74static void tkip_mixing_phase1(struct ieee80211_key *key, const u8 *ta,
75 u16 *p1k) 75 struct tkip_ctx *ctx, u32 tsc_IV32)
76{ 76{
77 int i, j; 77 int i, j;
78 const u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY];
79 u16 *p1k = ctx->p1k;
78 80
79 p1k[0] = tsc_IV32 & 0xFFFF; 81 p1k[0] = tsc_IV32 & 0xFFFF;
80 p1k[1] = tsc_IV32 >> 16; 82 p1k[1] = tsc_IV32 >> 16;
@@ -90,6 +92,7 @@ static void tkip_mixing_phase1(const u8 *ta, const u8 *tk, u32 tsc_IV32,
90 p1k[3] += tkipS(p1k[2] ^ get_unaligned_le16(tk + 12 + j)); 92 p1k[3] += tkipS(p1k[2] ^ get_unaligned_le16(tk + 12 + j));
91 p1k[4] += tkipS(p1k[3] ^ get_unaligned_le16(tk + 0 + j)) + i; 93 p1k[4] += tkipS(p1k[3] ^ get_unaligned_le16(tk + 0 + j)) + i;
92 } 94 }
95 ctx->initialized = 1;
93} 96}
94 97
95static void tkip_mixing_phase2(const u16 *p1k, const u8 *tk, u16 tsc_IV16, 98static void tkip_mixing_phase2(const u16 *p1k, const u8 *tk, u16 tsc_IV16,
@@ -146,12 +149,8 @@ static void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta,
146 u8 *rc4key) 149 u8 *rc4key)
147{ 150{
148 /* Calculate per-packet key */ 151 /* Calculate per-packet key */
149 if (key->u.tkip.tx.iv16 == 0 || !key->u.tkip.tx.initialized) { 152 if (key->u.tkip.tx.iv16 == 0 || !key->u.tkip.tx.initialized)
150 /* IV16 wrapped around - perform TKIP phase 1 */ 153 tkip_mixing_phase1(key, ta, &key->u.tkip.tx, key->u.tkip.tx.iv32);
151 tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
152 key->u.tkip.tx.iv32, key->u.tkip.tx.p1k);
153 key->u.tkip.tx.initialized = 1;
154 }
155 154
156 tkip_mixing_phase2(key->u.tkip.tx.p1k, 155 tkip_mixing_phase2(key->u.tkip.tx.p1k,
157 &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY], 156 &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
@@ -190,12 +189,8 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
190 /* Update the p1k only when the iv16 in the packet wraps around, this 189 /* Update the p1k only when the iv16 in the packet wraps around, this
191 * might occur after the wrap around of iv16 in the key in case of 190 * might occur after the wrap around of iv16 in the key in case of
192 * fragmented packets. */ 191 * fragmented packets. */
193 if (iv16 == 0 || !key->u.tkip.tx.initialized) { 192 if (iv16 == 0 || !key->u.tkip.tx.initialized)
194 /* IV16 wrapped around - perform TKIP phase 1 */ 193 tkip_mixing_phase1(key, ta, &key->u.tkip.tx, iv32);
195 tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
196 iv32, key->u.tkip.tx.p1k);
197 key->u.tkip.tx.initialized = 1;
198 }
199 194
200 if (type == IEEE80211_TKIP_P1_KEY) { 195 if (type == IEEE80211_TKIP_P1_KEY) {
201 memcpy(outkey, key->u.tkip.tx.p1k, sizeof(u16) * 5); 196 memcpy(outkey, key->u.tkip.tx.p1k, sizeof(u16) * 5);
@@ -286,10 +281,8 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
286 281
287 if (!key->u.tkip.rx[queue].initialized || 282 if (!key->u.tkip.rx[queue].initialized ||
288 key->u.tkip.rx[queue].iv32 != iv32) { 283 key->u.tkip.rx[queue].iv32 != iv32) {
289 key->u.tkip.rx[queue].initialized = 1;
290 /* IV16 wrapped around - perform TKIP phase 1 */ 284 /* IV16 wrapped around - perform TKIP phase 1 */
291 tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY], 285 tkip_mixing_phase1(key, ta, &key->u.tkip.rx[queue], iv32);
292 iv32, key->u.tkip.rx[queue].p1k);
293#ifdef CONFIG_TKIP_DEBUG 286#ifdef CONFIG_TKIP_DEBUG
294 { 287 {
295 int i; 288 int i;