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: <[email protected]>
  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;
 }
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to