All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jouni Malinen <j@w1.fi>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Subject: [RFC PATCH 2/7] 802.11w: CCMP for management frames
Date: Tue, 17 Jun 2008 18:40:10 +0300	[thread overview]
Message-ID: <20080617155844.056034562@localhost> (raw)
In-Reply-To: 20080617154008.883383150@localhost

Extend CCMP to support encryption and decryption of unicast management
frames.

Signed-off-by: Jouni Malinen <j@w1.fi>


Index: wireless-testing/net/mac80211/wpa.c
===================================================================
--- wireless-testing.orig/net/mac80211/wpa.c
+++ wireless-testing/net/mac80211/wpa.c
@@ -299,7 +299,7 @@ static void ccmp_special_blocks(struct s
 				int encrypted)
 {
 	u16 fc;
-	int a4_included, qos_included;
+	int a4_included, qos_included, mgmt;
 	u8 qos_tid, *fc_pos, *data, *sa, *da;
 	int len_a;
 	size_t data_len;
@@ -309,6 +309,7 @@ static void ccmp_special_blocks(struct s
 	fc = fc_pos[0] ^ (fc_pos[1] << 8);
 	a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 		(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
+	mgmt = (fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT;
 
 	ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len);
 	data_len -= CCMP_HDR_LEN + (encrypted ? CCMP_MIC_LEN : 0);
@@ -320,8 +321,10 @@ static void ccmp_special_blocks(struct s
 	/* First block, b_0 */
 
 	b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */
-	/* Nonce: QoS Priority | A2 | PN */
-	b_0[1] = qos_tid;
+	/* Nonce: Nonce Flags | A2 | PN
+	 * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7)
+	 */
+	b_0[1] = qos_tid | (mgmt << 4);
 	memcpy(&b_0[2], hdr->addr2, 6);
 	memcpy(&b_0[8], pn, CCMP_PN_LEN);
 	/* l(m) */
@@ -338,8 +341,11 @@ static void ccmp_special_blocks(struct s
 
 	aad[0] = 0; /* (len_a >> 8) & 0xff; */
 	aad[1] = len_a & 0xff;
-	/* Mask FC: zero subtype b4 b5 b6 */
-	aad[2] = fc_pos[0] & ~(BIT(4) | BIT(5) | BIT(6));
+	aad[2] = fc_pos[0]; /* FC type/subtype */
+	if (!mgmt) {
+		/* Mask FC: zero subtype b4 b5 b6 */
+		aad[2] &= BIT(4) | BIT(5) | BIT(6);
+	}
 	/* Retry, PwrMgt, MoreData; set Protected */
 	aad[3] = (fc_pos[1] & ~(BIT(3) | BIT(4) | BIT(5))) | BIT(6);
 	memcpy(&aad[4], &hdr->addr1, 18);
Index: wireless-testing/net/mac80211/tx.c
===================================================================
--- wireless-testing.orig/net/mac80211/tx.c
+++ wireless-testing/net/mac80211/tx.c
@@ -446,6 +446,26 @@ ieee80211_tx_h_ps_buf(struct ieee80211_t
 		return ieee80211_tx_h_multicast_ps_buf(tx);
 }
 
+static int ieee80211_use_mfp(u16 fc, struct sta_info *sta, struct sk_buff *skb)
+{
+	u16 stype;
+
+	if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
+		return 0;
+
+	if (sta == NULL || !test_sta_flags(sta, WLAN_STA_MFP))
+		return 0;
+
+	stype = fc & IEEE80211_FCTL_STYPE;
+	if (stype != IEEE80211_STYPE_DEAUTH &&
+	    stype != IEEE80211_STYPE_DISASSOC &&
+	    stype != IEEE80211_STYPE_ACTION)
+		return 0;
+
+	return 1;
+}
+
+
 static ieee80211_tx_result
 ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
 {
@@ -482,10 +502,14 @@ ieee80211_tx_h_select_key(struct ieee802
 			    stype == IEEE80211_STYPE_AUTH)
 				break;
 		case ALG_TKIP:
-		case ALG_CCMP:
 			if (!WLAN_FC_DATA_PRESENT(fc))
 				tx->key = NULL;
 			break;
+		case ALG_CCMP:
+			if (!WLAN_FC_DATA_PRESENT(fc) &&
+			    !ieee80211_use_mfp(fc, tx->sta, tx->skb))
+				tx->key = NULL;
+			break;
 		}
 	}
 

--

-- 
Jouni Malinen                                            PGP id EFC895FA

  parent reply	other threads:[~2008-06-17 15:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-17 15:40 [RFC PATCH 0/7] IEEE 802.11w / management frame protection Jouni Malinen
2008-06-17 15:40 ` [RFC PATCH 1/7] 802.11w: STA flag for MFP Jouni Malinen
2008-06-17 15:40 ` Jouni Malinen [this message]
2008-06-17 15:40 ` [RFC PATCH 3/7] 802.11w: Add BIP (AES-128-CMAC) Jouni Malinen
2008-06-17 16:55   ` Johannes Berg
2008-06-17 17:22     ` Harvey Harrison
2008-06-17 18:06     ` Jouni Malinen
2008-06-17 18:08       ` Michael Buesch
2008-06-17 18:19       ` Johannes Berg
2008-06-17 18:50         ` Jouni Malinen
2008-06-17 18:56           ` Johannes Berg
2008-06-17 15:40 ` [RFC PATCH 4/7] 802.11w: Use " Jouni Malinen
2008-06-17 17:05   ` Johannes Berg
2008-06-17 18:10     ` Jouni Malinen
2008-06-17 18:27       ` Johannes Berg
2008-06-18 10:17   ` Johannes Berg
2008-06-17 15:40 ` [RFC PATCH 5/7] 802.11w: WEXT parameter for setting mgmt cipher Jouni Malinen
2008-06-17 15:40 ` [RFC PATCH 6/7] 802.11w: WEXT configuration for IGTK Jouni Malinen
2008-06-17 15:40 ` [RFC PATCH 7/7] 802.11w: Configuration of MFP disabled/optional/required Jouni Malinen
2008-06-17 17:09   ` Johannes Berg
2008-06-17 18:18     ` Jouni Malinen
2008-06-17 18:34       ` Johannes Berg
2008-06-17 16:44 ` [RFC PATCH 0/7] IEEE 802.11w / management frame protection Johannes Berg
2008-06-17 17:47   ` Jouni Malinen
2008-06-17 17:52     ` Michael Buesch
2008-06-17 18:00       ` Johannes Berg
2008-06-17 18:23       ` Jouni Malinen
2008-06-17 18:27         ` Michael Buesch
2008-06-17 18:31           ` Johannes Berg
2008-06-17 18:41             ` Michael Buesch
2008-06-17 19:02 ` Jouni Malinen
2008-07-09 17:40 ` Johannes Berg
2008-07-09 18:08   ` Johannes Berg
2008-07-14 22:01     ` Jouni Malinen
2008-08-28 16:04     ` VLAN testing (and mac80211_hwsim test cases in general) Jouni Malinen
2008-08-29  7:33       ` Johannes Berg
2008-08-29  8:37         ` Jouni Malinen
2008-08-29 11:34           ` Jose Ignacio Naranjo Hernández

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080617155844.056034562@localhost \
    --to=j@w1.fi \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.