Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Oct 2015 00:03:08 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r288525 - head/sys/net80211
Message-ID:  <201510030003.t93038q9074837@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sat Oct  3 00:03:07 2015
New Revision: 288525
URL: https://svnweb.freebsd.org/changeset/base/288525

Log:
  net80211: get rid of tx_phase1_done flag (ieee80211_crypto_tkip.c).
  
  Submitted by:	<s3erios@gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D3596

Modified:
  head/sys/net80211/ieee80211_crypto_tkip.c

Modified: head/sys/net80211/ieee80211_crypto_tkip.c
==============================================================================
--- head/sys/net80211/ieee80211_crypto_tkip.c	Fri Oct  2 22:05:51 2015	(r288524)
+++ head/sys/net80211/ieee80211_crypto_tkip.c	Sat Oct  3 00:03:07 2015	(r288525)
@@ -84,7 +84,6 @@ struct tkip_ctx {
 	struct ieee80211vap *tc_vap;	/* for diagnostics+statistics */
 
 	u16	tx_ttak[5];
-	int	tx_phase1_done;
 	u8	tx_rc4key[16];		/* XXX for test module; make locals? */
 
 	u16	rx_ttak[5];
@@ -143,7 +142,6 @@ tkip_setkey(struct ieee80211_key *k)
 			__func__, k->wk_keylen, 128/NBBY);
 		return 0;
 	}
-	k->wk_keytsc = 1;		/* TSC starts at 1 */
 	ctx->rx_phase1_done = 0;
 	return 1;
 }
@@ -188,6 +186,7 @@ tkip_encap(struct ieee80211_key *k, stru
 
 	keyid = ieee80211_crypto_get_keyid(vap, k) << 6;
 
+	k->wk_keytsc++;
 	ivp[0] = k->wk_keytsc >> 8;		/* TSC1 */
 	ivp[1] = (ivp[0] | 0x20) & 0x7f;	/* WEP seed */
 	ivp[2] = k->wk_keytsc >> 0;		/* TSC0 */
@@ -200,12 +199,9 @@ tkip_encap(struct ieee80211_key *k, stru
 	/*
 	 * Finally, do software encrypt if needed.
 	 */
-	if (k->wk_flags & IEEE80211_KEY_SWENCRYPT) {
-		if (!tkip_encrypt(ctx, k, m, hdrlen))
-			return 0;
-		/* NB: tkip_encrypt handles wk_keytsc */
-	} else
-		k->wk_keytsc++;
+	if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
+	    !tkip_encrypt(ctx, k, m, hdrlen))
+		return 0;
 
 	return 1;
 }
@@ -934,10 +930,9 @@ tkip_encrypt(struct tkip_ctx *ctx, struc
 	ctx->tc_vap->iv_stats.is_crypto_tkip++;
 
 	wh = mtod(m, struct ieee80211_frame *);
-	if (!ctx->tx_phase1_done) {
+	if ((u16)(key->wk_keytsc) == 0 || key->wk_keytsc == 1) {
 		tkip_mixing_phase1(ctx->tx_ttak, key->wk_key, wh->i_addr2,
 				   (u32)(key->wk_keytsc >> 16));
-		ctx->tx_phase1_done = 1;
 	}
 	tkip_mixing_phase2(ctx->tx_rc4key, key->wk_key, ctx->tx_ttak,
 		(u16) key->wk_keytsc);
@@ -948,9 +943,6 @@ tkip_encrypt(struct tkip_ctx *ctx, struc
 		icv);
 	(void) m_append(m, IEEE80211_WEP_CRCLEN, icv);	/* XXX check return */
 
-	key->wk_keytsc++;
-	if ((u16)(key->wk_keytsc) == 0)
-		ctx->tx_phase1_done = 0;
 	return 1;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510030003.t93038q9074837>