ieee80211_pae_input.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. /* $OpenBSD: ieee80211_pae_input.c,v 1.25 2015/07/15 22:16:42 deraadt Exp $ */
  2. /*-
  3. * Copyright (c) 2007,2008 Damien Bergamini <damien.bergamini@free.fr>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /*
  18. * This code implements the 4-Way Handshake and Group Key Handshake protocols
  19. * (both Supplicant and Authenticator Key Receive state machines) defined in
  20. * IEEE Std 802.11-2007 section 8.5.
  21. */
  22. #include <sys/param.h>
  23. #include <sys/systm.h>
  24. #include <sys/mbuf.h>
  25. #include <sys/kernel.h>
  26. #include <sys/socket.h>
  27. #include <sys/sockio.h>
  28. #include <sys/errno.h>
  29. #include <net/if.h>
  30. #include <net/if_dl.h>
  31. #include <net/if_media.h>
  32. #include <netinet/in.h>
  33. #include <netinet/if_ether.h>
  34. #include <net80211/ieee80211_var.h>
  35. #include <net80211/ieee80211_priv.h>
  36. void ieee80211_recv_4way_msg1(struct ieee80211com *,
  37. struct ieee80211_eapol_key *, struct ieee80211_node *);
  38. #ifndef IEEE80211_STA_ONLY
  39. void ieee80211_recv_4way_msg2(struct ieee80211com *,
  40. struct ieee80211_eapol_key *, struct ieee80211_node *,
  41. const u_int8_t *);
  42. #endif
  43. void ieee80211_recv_4way_msg3(struct ieee80211com *,
  44. struct ieee80211_eapol_key *, struct ieee80211_node *);
  45. #ifndef IEEE80211_STA_ONLY
  46. void ieee80211_recv_4way_msg4(struct ieee80211com *,
  47. struct ieee80211_eapol_key *, struct ieee80211_node *);
  48. void ieee80211_recv_4way_msg2or4(struct ieee80211com *,
  49. struct ieee80211_eapol_key *, struct ieee80211_node *);
  50. #endif
  51. void ieee80211_recv_rsn_group_msg1(struct ieee80211com *,
  52. struct ieee80211_eapol_key *, struct ieee80211_node *);
  53. void ieee80211_recv_wpa_group_msg1(struct ieee80211com *,
  54. struct ieee80211_eapol_key *, struct ieee80211_node *);
  55. #ifndef IEEE80211_STA_ONLY
  56. void ieee80211_recv_group_msg2(struct ieee80211com *,
  57. struct ieee80211_eapol_key *, struct ieee80211_node *);
  58. void ieee80211_recv_eapol_key_req(struct ieee80211com *,
  59. struct ieee80211_eapol_key *, struct ieee80211_node *);
  60. #endif
  61. /*
  62. * Process an incoming EAPOL frame. Notice that we are only interested in
  63. * EAPOL-Key frames with an IEEE 802.11 or WPA descriptor type.
  64. */
  65. void
  66. ieee80211_eapol_key_input(struct ieee80211com *ic, struct mbuf *m,
  67. struct ieee80211_node *ni)
  68. {
  69. struct ifnet *ifp = &ic->ic_if;
  70. struct ether_header *eh;
  71. struct ieee80211_eapol_key *key;
  72. u_int16_t info, desc;
  73. int totlen;
  74. ifp->if_ibytes += m->m_pkthdr.len;
  75. eh = mtod(m, struct ether_header *);
  76. if (IEEE80211_IS_MULTICAST(eh->ether_dhost)) {
  77. ifp->if_imcasts++;
  78. goto done;
  79. }
  80. m_adj(m, sizeof(*eh));
  81. if (m->m_pkthdr.len < sizeof(*key))
  82. goto done;
  83. if (m->m_len < sizeof(*key) &&
  84. (m = m_pullup(m, sizeof(*key))) == NULL) {
  85. ic->ic_stats.is_rx_nombuf++;
  86. goto done;
  87. }
  88. key = mtod(m, struct ieee80211_eapol_key *);
  89. if (key->type != EAPOL_KEY)
  90. goto done;
  91. ic->ic_stats.is_rx_eapol_key++;
  92. if ((ni->ni_rsnprotos == IEEE80211_PROTO_RSN &&
  93. key->desc != EAPOL_KEY_DESC_IEEE80211) ||
  94. (ni->ni_rsnprotos == IEEE80211_PROTO_WPA &&
  95. key->desc != EAPOL_KEY_DESC_WPA))
  96. goto done;
  97. /* check packet body length */
  98. if (m->m_pkthdr.len < 4 + BE_READ_2(key->len))
  99. goto done;
  100. /* check key data length */
  101. totlen = sizeof(*key) + BE_READ_2(key->paylen);
  102. if (m->m_pkthdr.len < totlen || totlen > MCLBYTES)
  103. goto done;
  104. info = BE_READ_2(key->info);
  105. /* discard EAPOL-Key frames with an unknown descriptor version */
  106. desc = info & EAPOL_KEY_VERSION_MASK;
  107. if (desc < EAPOL_KEY_DESC_V1 || desc > EAPOL_KEY_DESC_V3)
  108. goto done;
  109. if (ieee80211_is_sha256_akm(ni->ni_rsnakms)) {
  110. if (desc != EAPOL_KEY_DESC_V3)
  111. goto done;
  112. } else if (ni->ni_rsncipher == IEEE80211_CIPHER_CCMP ||
  113. ni->ni_rsngroupcipher == IEEE80211_CIPHER_CCMP) {
  114. if (desc != EAPOL_KEY_DESC_V2)
  115. goto done;
  116. }
  117. /* make sure the key data field is contiguous */
  118. if (m->m_len < totlen && (m = m_pullup(m, totlen)) == NULL) {
  119. ic->ic_stats.is_rx_nombuf++;
  120. goto done;
  121. }
  122. key = mtod(m, struct ieee80211_eapol_key *);
  123. /* determine message type (see 8.5.3.7) */
  124. if (info & EAPOL_KEY_REQUEST) {
  125. #ifndef IEEE80211_STA_ONLY
  126. /* EAPOL-Key Request frame */
  127. ieee80211_recv_eapol_key_req(ic, key, ni);
  128. #endif
  129. } else if (info & EAPOL_KEY_PAIRWISE) {
  130. /* 4-Way Handshake */
  131. if (info & EAPOL_KEY_KEYMIC) {
  132. if (info & EAPOL_KEY_KEYACK)
  133. ieee80211_recv_4way_msg3(ic, key, ni);
  134. #ifndef IEEE80211_STA_ONLY
  135. else
  136. ieee80211_recv_4way_msg2or4(ic, key, ni);
  137. #endif
  138. } else if (info & EAPOL_KEY_KEYACK)
  139. ieee80211_recv_4way_msg1(ic, key, ni);
  140. } else {
  141. /* Group Key Handshake */
  142. if (!(info & EAPOL_KEY_KEYMIC))
  143. goto done;
  144. if (info & EAPOL_KEY_KEYACK) {
  145. if (key->desc == EAPOL_KEY_DESC_WPA)
  146. ieee80211_recv_wpa_group_msg1(ic, key, ni);
  147. else
  148. ieee80211_recv_rsn_group_msg1(ic, key, ni);
  149. }
  150. #ifndef IEEE80211_STA_ONLY
  151. else
  152. ieee80211_recv_group_msg2(ic, key, ni);
  153. #endif
  154. }
  155. done:
  156. m_freem(m);
  157. }
  158. /*
  159. * Process Message 1 of the 4-Way Handshake (sent by Authenticator).
  160. */
  161. void
  162. ieee80211_recv_4way_msg1(struct ieee80211com *ic,
  163. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  164. {
  165. struct ieee80211_ptk tptk;
  166. struct ieee80211_pmk *pmk;
  167. const u_int8_t *frm, *efrm;
  168. const u_int8_t *pmkid;
  169. #ifndef IEEE80211_STA_ONLY
  170. if (ic->ic_opmode != IEEE80211_M_STA &&
  171. ic->ic_opmode != IEEE80211_M_IBSS)
  172. return;
  173. #endif
  174. if (ni->ni_replaycnt_ok &&
  175. BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) {
  176. ic->ic_stats.is_rx_eapol_replay++;
  177. return;
  178. }
  179. /* parse key data field (may contain an encapsulated PMKID) */
  180. frm = (const u_int8_t *)&key[1];
  181. efrm = frm + BE_READ_2(key->paylen);
  182. pmkid = NULL;
  183. while (frm + 2 <= efrm) {
  184. if (frm + 2 + frm[1] > efrm)
  185. break;
  186. switch (frm[0]) {
  187. case IEEE80211_ELEMID_VENDOR:
  188. if (frm[1] < 4)
  189. break;
  190. if (memcmp(&frm[2], IEEE80211_OUI, 3) == 0) {
  191. switch (frm[5]) {
  192. case IEEE80211_KDE_PMKID:
  193. pmkid = frm;
  194. break;
  195. }
  196. }
  197. break;
  198. }
  199. frm += 2 + frm[1];
  200. }
  201. /* check that the PMKID KDE is valid (if present) */
  202. if (pmkid != NULL && pmkid[1] != 4 + 16)
  203. return;
  204. if (ieee80211_is_8021x_akm(ni->ni_rsnakms)) {
  205. /* retrieve the PMK for this (AP,PMKID) */
  206. pmk = ieee80211_pmksa_find(ic, ni,
  207. (pmkid != NULL) ? &pmkid[6] : NULL);
  208. if (pmk == NULL) {
  209. DPRINTF(("no PMK available for %s\n",
  210. ether_sprintf(ni->ni_macaddr)));
  211. return;
  212. }
  213. memcpy(ni->ni_pmk, pmk->pmk_key, IEEE80211_PMK_LEN);
  214. } else /* use pre-shared key */
  215. memcpy(ni->ni_pmk, ic->ic_psk, IEEE80211_PMK_LEN);
  216. ni->ni_flags |= IEEE80211_NODE_PMK;
  217. /* save authenticator's nonce (ANonce) */
  218. memcpy(ni->ni_nonce, key->nonce, EAPOL_KEY_NONCE_LEN);
  219. /* generate supplicant's nonce (SNonce) */
  220. arc4random_buf(ic->ic_nonce, EAPOL_KEY_NONCE_LEN);
  221. /* TPTK = CalcPTK(PMK, ANonce, SNonce) */
  222. ieee80211_derive_ptk(ni->ni_rsnakms, ni->ni_pmk, ni->ni_macaddr,
  223. ic->ic_myaddr, ni->ni_nonce, ic->ic_nonce, &tptk);
  224. if (ic->ic_if.if_flags & IFF_DEBUG)
  225. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  226. ic->ic_if.if_xname, 1, 4, "4-way",
  227. ether_sprintf(ni->ni_macaddr));
  228. /* send message 2 to authenticator using TPTK */
  229. (void)ieee80211_send_4way_msg2(ic, ni, key->replaycnt, &tptk);
  230. }
  231. #ifndef IEEE80211_STA_ONLY
  232. /*
  233. * Process Message 2 of the 4-Way Handshake (sent by Supplicant).
  234. */
  235. void
  236. ieee80211_recv_4way_msg2(struct ieee80211com *ic,
  237. struct ieee80211_eapol_key *key, struct ieee80211_node *ni,
  238. const u_int8_t *rsnie)
  239. {
  240. struct ieee80211_ptk tptk;
  241. if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
  242. ic->ic_opmode != IEEE80211_M_IBSS)
  243. return;
  244. /* discard if we're not expecting this message */
  245. if (ni->ni_rsn_state != RSNA_PTKSTART &&
  246. ni->ni_rsn_state != RSNA_PTKCALCNEGOTIATING) {
  247. DPRINTF(("unexpected in state: %d\n", ni->ni_rsn_state));
  248. return;
  249. }
  250. ni->ni_rsn_state = RSNA_PTKCALCNEGOTIATING;
  251. /* NB: replay counter has already been verified by caller */
  252. /* PTK = CalcPTK(ANonce, SNonce) */
  253. ieee80211_derive_ptk(ni->ni_rsnakms, ni->ni_pmk, ic->ic_myaddr,
  254. ni->ni_macaddr, ni->ni_nonce, key->nonce, &tptk);
  255. /* check Key MIC field using KCK */
  256. if (ieee80211_eapol_key_check_mic(key, tptk.kck) != 0) {
  257. DPRINTF(("key MIC failed\n"));
  258. ic->ic_stats.is_rx_eapol_badmic++;
  259. return; /* will timeout.. */
  260. }
  261. timeout_del(&ni->ni_eapol_to);
  262. ni->ni_rsn_state = RSNA_PTKCALCNEGOTIATING_2;
  263. ni->ni_rsn_retries = 0;
  264. /* install TPTK as PTK now that MIC is verified */
  265. memcpy(&ni->ni_ptk, &tptk, sizeof(tptk));
  266. /*
  267. * The RSN IE must match bit-wise with what the STA included in its
  268. * (Re)Association Request.
  269. */
  270. if (ni->ni_rsnie == NULL || rsnie[1] != ni->ni_rsnie[1] ||
  271. memcmp(rsnie, ni->ni_rsnie, 2 + rsnie[1]) != 0) {
  272. IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
  273. IEEE80211_REASON_RSN_DIFFERENT_IE);
  274. ieee80211_node_leave(ic, ni);
  275. return;
  276. }
  277. if (ic->ic_if.if_flags & IFF_DEBUG)
  278. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  279. ic->ic_if.if_xname, 2, 4, "4-way",
  280. ether_sprintf(ni->ni_macaddr));
  281. /* send message 3 to supplicant */
  282. (void)ieee80211_send_4way_msg3(ic, ni);
  283. }
  284. #endif /* IEEE80211_STA_ONLY */
  285. /*
  286. * Process Message 3 of the 4-Way Handshake (sent by Authenticator).
  287. */
  288. void
  289. ieee80211_recv_4way_msg3(struct ieee80211com *ic,
  290. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  291. {
  292. struct ieee80211_ptk tptk;
  293. struct ieee80211_key *k;
  294. const u_int8_t *frm, *efrm;
  295. const u_int8_t *rsnie1, *rsnie2, *gtk, *igtk;
  296. u_int16_t info, reason = 0;
  297. int keylen;
  298. #ifndef IEEE80211_STA_ONLY
  299. if (ic->ic_opmode != IEEE80211_M_STA &&
  300. ic->ic_opmode != IEEE80211_M_IBSS)
  301. return;
  302. #endif
  303. if (ni->ni_replaycnt_ok &&
  304. BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) {
  305. ic->ic_stats.is_rx_eapol_replay++;
  306. return;
  307. }
  308. /* make sure that a PMK has been selected */
  309. if (!(ni->ni_flags & IEEE80211_NODE_PMK)) {
  310. DPRINTF(("no PMK found for %s\n",
  311. ether_sprintf(ni->ni_macaddr)));
  312. return;
  313. }
  314. /* check that ANonce matches that of Message 1 */
  315. if (memcmp(key->nonce, ni->ni_nonce, EAPOL_KEY_NONCE_LEN) != 0) {
  316. DPRINTF(("ANonce does not match msg 1/4\n"));
  317. return;
  318. }
  319. /* TPTK = CalcPTK(PMK, ANonce, SNonce) */
  320. ieee80211_derive_ptk(ni->ni_rsnakms, ni->ni_pmk, ni->ni_macaddr,
  321. ic->ic_myaddr, key->nonce, ic->ic_nonce, &tptk);
  322. info = BE_READ_2(key->info);
  323. /* check Key MIC field using KCK */
  324. if (ieee80211_eapol_key_check_mic(key, tptk.kck) != 0) {
  325. DPRINTF(("key MIC failed\n"));
  326. ic->ic_stats.is_rx_eapol_badmic++;
  327. return;
  328. }
  329. /* install TPTK as PTK now that MIC is verified */
  330. memcpy(&ni->ni_ptk, &tptk, sizeof(tptk));
  331. /* if encrypted, decrypt Key Data field using KEK */
  332. if ((info & EAPOL_KEY_ENCRYPTED) &&
  333. ieee80211_eapol_key_decrypt(key, ni->ni_ptk.kek) != 0) {
  334. DPRINTF(("decryption failed\n"));
  335. return;
  336. }
  337. /* parse key data field */
  338. frm = (const u_int8_t *)&key[1];
  339. efrm = frm + BE_READ_2(key->paylen);
  340. /*
  341. * Some WPA1+WPA2 APs (like hostapd) appear to include both WPA and
  342. * RSN IEs in message 3/4. We only take into account the IE of the
  343. * version of the protocol we negotiated at association time.
  344. */
  345. rsnie1 = rsnie2 = gtk = igtk = NULL;
  346. while (frm + 2 <= efrm) {
  347. if (frm + 2 + frm[1] > efrm)
  348. break;
  349. switch (frm[0]) {
  350. case IEEE80211_ELEMID_RSN:
  351. if (ni->ni_rsnprotos != IEEE80211_PROTO_RSN)
  352. break;
  353. if (rsnie1 == NULL)
  354. rsnie1 = frm;
  355. else if (rsnie2 == NULL)
  356. rsnie2 = frm;
  357. /* ignore others if more than two RSN IEs */
  358. break;
  359. case IEEE80211_ELEMID_VENDOR:
  360. if (frm[1] < 4)
  361. break;
  362. if (memcmp(&frm[2], IEEE80211_OUI, 3) == 0) {
  363. switch (frm[5]) {
  364. case IEEE80211_KDE_GTK:
  365. gtk = frm;
  366. break;
  367. case IEEE80211_KDE_IGTK:
  368. if (ni->ni_flags & IEEE80211_NODE_MFP)
  369. igtk = frm;
  370. break;
  371. }
  372. } else if (memcmp(&frm[2], MICROSOFT_OUI, 3) == 0) {
  373. switch (frm[5]) {
  374. case 1: /* WPA */
  375. if (ni->ni_rsnprotos !=
  376. IEEE80211_PROTO_WPA)
  377. break;
  378. rsnie1 = frm;
  379. break;
  380. }
  381. }
  382. break;
  383. }
  384. frm += 2 + frm[1];
  385. }
  386. /* first WPA/RSN IE is mandatory */
  387. if (rsnie1 == NULL) {
  388. DPRINTF(("missing RSN IE\n"));
  389. return;
  390. }
  391. /* key data must be encrypted if GTK is included */
  392. if (gtk != NULL && !(info & EAPOL_KEY_ENCRYPTED)) {
  393. DPRINTF(("GTK not encrypted\n"));
  394. return;
  395. }
  396. /* GTK KDE must be included if IGTK KDE is present */
  397. if (igtk != NULL && gtk == NULL) {
  398. DPRINTF(("IGTK KDE found but GTK KDE missing\n"));
  399. return;
  400. }
  401. /* check that the Install bit is set if using pairwise keys */
  402. if (ni->ni_rsncipher != IEEE80211_CIPHER_USEGROUP &&
  403. !(info & EAPOL_KEY_INSTALL)) {
  404. DPRINTF(("pairwise cipher but !Install\n"));
  405. return;
  406. }
  407. /*
  408. * Check that first WPA/RSN IE is identical to the one received in
  409. * the beacon or probe response frame.
  410. */
  411. if (ni->ni_rsnie == NULL || rsnie1[1] != ni->ni_rsnie[1] ||
  412. memcmp(rsnie1, ni->ni_rsnie, 2 + rsnie1[1]) != 0) {
  413. reason = IEEE80211_REASON_RSN_DIFFERENT_IE;
  414. goto deauth;
  415. }
  416. /*
  417. * If a second RSN information element is present, use its pairwise
  418. * cipher suite or deauthenticate.
  419. */
  420. if (rsnie2 != NULL) {
  421. struct ieee80211_rsnparams rsn;
  422. if (ieee80211_parse_rsn(ic, rsnie2, &rsn) == 0) {
  423. if (rsn.rsn_akms != ni->ni_rsnakms ||
  424. rsn.rsn_groupcipher != ni->ni_rsngroupcipher ||
  425. rsn.rsn_nciphers != 1 ||
  426. !(rsn.rsn_ciphers & ic->ic_rsnciphers)) {
  427. reason = IEEE80211_REASON_BAD_PAIRWISE_CIPHER;
  428. goto deauth;
  429. }
  430. /* use pairwise cipher suite of second RSN IE */
  431. ni->ni_rsnciphers = rsn.rsn_ciphers;
  432. ni->ni_rsncipher = ni->ni_rsnciphers;
  433. }
  434. }
  435. /* update the last seen value of the key replay counter field */
  436. ni->ni_replaycnt = BE_READ_8(key->replaycnt);
  437. ni->ni_replaycnt_ok = 1;
  438. if (ic->ic_if.if_flags & IFF_DEBUG)
  439. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  440. ic->ic_if.if_xname, 3, 4, "4-way",
  441. ether_sprintf(ni->ni_macaddr));
  442. /* send message 4 to authenticator */
  443. if (ieee80211_send_4way_msg4(ic, ni) != 0)
  444. return; /* ..authenticator will retry */
  445. if (ni->ni_rsncipher != IEEE80211_CIPHER_USEGROUP) {
  446. u_int64_t prsc;
  447. /* check that key length matches that of pairwise cipher */
  448. keylen = ieee80211_cipher_keylen(ni->ni_rsncipher);
  449. if (BE_READ_2(key->keylen) != keylen) {
  450. reason = IEEE80211_REASON_AUTH_LEAVE;
  451. goto deauth;
  452. }
  453. prsc = (gtk == NULL) ? LE_READ_6(key->rsc) : 0;
  454. /* map PTK to 802.11 key */
  455. k = &ni->ni_pairwise_key;
  456. memset(k, 0, sizeof(*k));
  457. k->k_cipher = ni->ni_rsncipher;
  458. k->k_rsc[0] = prsc;
  459. k->k_len = keylen;
  460. memcpy(k->k_key, ni->ni_ptk.tk, k->k_len);
  461. /* install the PTK */
  462. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  463. reason = IEEE80211_REASON_AUTH_LEAVE;
  464. goto deauth;
  465. }
  466. ni->ni_flags &= ~IEEE80211_NODE_TXRXPROT;
  467. ni->ni_flags |= IEEE80211_NODE_RXPROT;
  468. }
  469. if (gtk != NULL) {
  470. u_int8_t kid;
  471. /* check that key length matches that of group cipher */
  472. keylen = ieee80211_cipher_keylen(ni->ni_rsngroupcipher);
  473. if (gtk[1] != 6 + keylen) {
  474. reason = IEEE80211_REASON_AUTH_LEAVE;
  475. goto deauth;
  476. }
  477. /* map GTK to 802.11 key */
  478. kid = gtk[6] & 3;
  479. k = &ic->ic_nw_keys[kid];
  480. memset(k, 0, sizeof(*k));
  481. k->k_id = kid; /* 0-3 */
  482. k->k_cipher = ni->ni_rsngroupcipher;
  483. k->k_flags = IEEE80211_KEY_GROUP;
  484. if (gtk[6] & (1 << 2))
  485. k->k_flags |= IEEE80211_KEY_TX;
  486. k->k_rsc[0] = LE_READ_6(key->rsc);
  487. k->k_len = keylen;
  488. memcpy(k->k_key, &gtk[8], k->k_len);
  489. /* install the GTK */
  490. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  491. reason = IEEE80211_REASON_AUTH_LEAVE;
  492. goto deauth;
  493. }
  494. }
  495. if (igtk != NULL) { /* implies MFP && gtk != NULL */
  496. u_int16_t kid;
  497. /* check that the IGTK KDE is valid */
  498. if (igtk[1] != 4 + 24) {
  499. reason = IEEE80211_REASON_AUTH_LEAVE;
  500. goto deauth;
  501. }
  502. kid = LE_READ_2(&igtk[6]);
  503. if (kid != 4 && kid != 5) {
  504. DPRINTF(("unsupported IGTK id %u\n", kid));
  505. reason = IEEE80211_REASON_AUTH_LEAVE;
  506. goto deauth;
  507. }
  508. /* map IGTK to 802.11 key */
  509. k = &ic->ic_nw_keys[kid];
  510. memset(k, 0, sizeof(*k));
  511. k->k_id = kid; /* either 4 or 5 */
  512. k->k_cipher = ni->ni_rsngroupmgmtcipher;
  513. k->k_flags = IEEE80211_KEY_IGTK;
  514. k->k_mgmt_rsc = LE_READ_6(&igtk[8]); /* IPN */
  515. k->k_len = 16;
  516. memcpy(k->k_key, &igtk[14], k->k_len);
  517. /* install the IGTK */
  518. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  519. reason = IEEE80211_REASON_AUTH_LEAVE;
  520. goto deauth;
  521. }
  522. }
  523. if (info & EAPOL_KEY_INSTALL)
  524. ni->ni_flags |= IEEE80211_NODE_TXRXPROT;
  525. if (info & EAPOL_KEY_SECURE) {
  526. ni->ni_flags |= IEEE80211_NODE_TXRXPROT;
  527. #ifndef IEEE80211_STA_ONLY
  528. if (ic->ic_opmode != IEEE80211_M_IBSS ||
  529. ++ni->ni_key_count == 2)
  530. #endif
  531. {
  532. DPRINTF(("marking port %s valid\n",
  533. ether_sprintf(ni->ni_macaddr)));
  534. ni->ni_port_valid = 1;
  535. ieee80211_set_link_state(ic, LINK_STATE_UP);
  536. }
  537. }
  538. deauth:
  539. if (reason != 0) {
  540. IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
  541. reason);
  542. ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
  543. }
  544. }
  545. #ifndef IEEE80211_STA_ONLY
  546. /*
  547. * Process Message 4 of the 4-Way Handshake (sent by Supplicant).
  548. */
  549. void
  550. ieee80211_recv_4way_msg4(struct ieee80211com *ic,
  551. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  552. {
  553. if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
  554. ic->ic_opmode != IEEE80211_M_IBSS)
  555. return;
  556. /* discard if we're not expecting this message */
  557. if (ni->ni_rsn_state != RSNA_PTKINITNEGOTIATING) {
  558. DPRINTF(("unexpected in state: %d\n", ni->ni_rsn_state));
  559. return;
  560. }
  561. /* NB: replay counter has already been verified by caller */
  562. /* check Key MIC field using KCK */
  563. if (ieee80211_eapol_key_check_mic(key, ni->ni_ptk.kck) != 0) {
  564. DPRINTF(("key MIC failed\n"));
  565. ic->ic_stats.is_rx_eapol_badmic++;
  566. return; /* will timeout.. */
  567. }
  568. timeout_del(&ni->ni_eapol_to);
  569. ni->ni_rsn_state = RSNA_PTKINITDONE;
  570. ni->ni_rsn_retries = 0;
  571. if (ni->ni_rsncipher != IEEE80211_CIPHER_USEGROUP) {
  572. struct ieee80211_key *k;
  573. /* map PTK to 802.11 key */
  574. k = &ni->ni_pairwise_key;
  575. memset(k, 0, sizeof(*k));
  576. k->k_cipher = ni->ni_rsncipher;
  577. k->k_len = ieee80211_cipher_keylen(k->k_cipher);
  578. memcpy(k->k_key, ni->ni_ptk.tk, k->k_len);
  579. /* install the PTK */
  580. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  581. IEEE80211_SEND_MGMT(ic, ni,
  582. IEEE80211_FC0_SUBTYPE_DEAUTH,
  583. IEEE80211_REASON_ASSOC_TOOMANY);
  584. ieee80211_node_leave(ic, ni);
  585. return;
  586. }
  587. ni->ni_flags |= IEEE80211_NODE_TXRXPROT;
  588. }
  589. if (ic->ic_opmode != IEEE80211_M_IBSS || ++ni->ni_key_count == 2) {
  590. DPRINTF(("marking port %s valid\n",
  591. ether_sprintf(ni->ni_macaddr)));
  592. ni->ni_port_valid = 1;
  593. }
  594. if (ic->ic_if.if_flags & IFF_DEBUG)
  595. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  596. ic->ic_if.if_xname, 4, 4, "4-way",
  597. ether_sprintf(ni->ni_macaddr));
  598. /* initiate a group key handshake for WPA */
  599. if (ni->ni_rsnprotos == IEEE80211_PROTO_WPA)
  600. (void)ieee80211_send_group_msg1(ic, ni);
  601. else
  602. ni->ni_rsn_gstate = RSNA_IDLE;
  603. }
  604. /*
  605. * Differentiate Message 2 from Message 4 of the 4-Way Handshake based on
  606. * the presence of an RSN or WPA Information Element.
  607. */
  608. void
  609. ieee80211_recv_4way_msg2or4(struct ieee80211com *ic,
  610. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  611. {
  612. const u_int8_t *frm, *efrm;
  613. const u_int8_t *rsnie;
  614. if (BE_READ_8(key->replaycnt) != ni->ni_replaycnt) {
  615. ic->ic_stats.is_rx_eapol_replay++;
  616. return;
  617. }
  618. /* parse key data field (check if an RSN IE is present) */
  619. frm = (const u_int8_t *)&key[1];
  620. efrm = frm + BE_READ_2(key->paylen);
  621. rsnie = NULL;
  622. while (frm + 2 <= efrm) {
  623. if (frm + 2 + frm[1] > efrm)
  624. break;
  625. switch (frm[0]) {
  626. case IEEE80211_ELEMID_RSN:
  627. rsnie = frm;
  628. break;
  629. case IEEE80211_ELEMID_VENDOR:
  630. if (frm[1] < 4)
  631. break;
  632. if (memcmp(&frm[2], MICROSOFT_OUI, 3) == 0) {
  633. switch (frm[5]) {
  634. case 1: /* WPA */
  635. rsnie = frm;
  636. break;
  637. }
  638. }
  639. }
  640. frm += 2 + frm[1];
  641. }
  642. if (rsnie != NULL)
  643. ieee80211_recv_4way_msg2(ic, key, ni, rsnie);
  644. else
  645. ieee80211_recv_4way_msg4(ic, key, ni);
  646. }
  647. #endif /* IEEE80211_STA_ONLY */
  648. /*
  649. * Process Message 1 of the RSN Group Key Handshake (sent by Authenticator).
  650. */
  651. void
  652. ieee80211_recv_rsn_group_msg1(struct ieee80211com *ic,
  653. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  654. {
  655. struct ieee80211_key *k;
  656. const u_int8_t *frm, *efrm;
  657. const u_int8_t *gtk, *igtk;
  658. u_int16_t info, kid, reason = 0;
  659. int keylen;
  660. #ifndef IEEE80211_STA_ONLY
  661. if (ic->ic_opmode != IEEE80211_M_STA &&
  662. ic->ic_opmode != IEEE80211_M_IBSS)
  663. return;
  664. #endif
  665. if (BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) {
  666. ic->ic_stats.is_rx_eapol_replay++;
  667. return;
  668. }
  669. /* check Key MIC field using KCK */
  670. if (ieee80211_eapol_key_check_mic(key, ni->ni_ptk.kck) != 0) {
  671. DPRINTF(("key MIC failed\n"));
  672. ic->ic_stats.is_rx_eapol_badmic++;
  673. return;
  674. }
  675. info = BE_READ_2(key->info);
  676. /* check that encrypted and decrypt Key Data field using KEK */
  677. if (!(info & EAPOL_KEY_ENCRYPTED) ||
  678. ieee80211_eapol_key_decrypt(key, ni->ni_ptk.kek) != 0) {
  679. DPRINTF(("decryption failed\n"));
  680. return;
  681. }
  682. /* parse key data field (shall contain a GTK KDE) */
  683. frm = (const u_int8_t *)&key[1];
  684. efrm = frm + BE_READ_2(key->paylen);
  685. gtk = igtk = NULL;
  686. while (frm + 2 <= efrm) {
  687. if (frm + 2 + frm[1] > efrm)
  688. break;
  689. switch (frm[0]) {
  690. case IEEE80211_ELEMID_VENDOR:
  691. if (frm[1] < 4)
  692. break;
  693. if (memcmp(&frm[2], IEEE80211_OUI, 3) == 0) {
  694. switch (frm[5]) {
  695. case IEEE80211_KDE_GTK:
  696. gtk = frm;
  697. break;
  698. case IEEE80211_KDE_IGTK:
  699. if (ni->ni_flags & IEEE80211_NODE_MFP)
  700. igtk = frm;
  701. break;
  702. }
  703. }
  704. break;
  705. }
  706. frm += 2 + frm[1];
  707. }
  708. /* check that the GTK KDE is present */
  709. if (gtk == NULL) {
  710. DPRINTF(("GTK KDE missing\n"));
  711. return;
  712. }
  713. /* check that key length matches that of group cipher */
  714. keylen = ieee80211_cipher_keylen(ni->ni_rsngroupcipher);
  715. if (gtk[1] != 6 + keylen)
  716. return;
  717. /* map GTK to 802.11 key */
  718. kid = gtk[6] & 3;
  719. k = &ic->ic_nw_keys[kid];
  720. memset(k, 0, sizeof(*k));
  721. k->k_id = kid; /* 0-3 */
  722. k->k_cipher = ni->ni_rsngroupcipher;
  723. k->k_flags = IEEE80211_KEY_GROUP;
  724. if (gtk[6] & (1 << 2))
  725. k->k_flags |= IEEE80211_KEY_TX;
  726. k->k_rsc[0] = LE_READ_6(key->rsc);
  727. k->k_len = keylen;
  728. memcpy(k->k_key, &gtk[8], k->k_len);
  729. /* install the GTK */
  730. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  731. reason = IEEE80211_REASON_AUTH_LEAVE;
  732. goto deauth;
  733. }
  734. if (igtk != NULL) { /* implies MFP */
  735. /* check that the IGTK KDE is valid */
  736. if (igtk[1] != 4 + 24) {
  737. reason = IEEE80211_REASON_AUTH_LEAVE;
  738. goto deauth;
  739. }
  740. kid = LE_READ_2(&igtk[6]);
  741. if (kid != 4 && kid != 5) {
  742. DPRINTF(("unsupported IGTK id %u\n", kid));
  743. reason = IEEE80211_REASON_AUTH_LEAVE;
  744. goto deauth;
  745. }
  746. /* map IGTK to 802.11 key */
  747. k = &ic->ic_nw_keys[kid];
  748. memset(k, 0, sizeof(*k));
  749. k->k_id = kid; /* either 4 or 5 */
  750. k->k_cipher = ni->ni_rsngroupmgmtcipher;
  751. k->k_flags = IEEE80211_KEY_IGTK;
  752. k->k_mgmt_rsc = LE_READ_6(&igtk[8]); /* IPN */
  753. k->k_len = 16;
  754. memcpy(k->k_key, &igtk[14], k->k_len);
  755. /* install the IGTK */
  756. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  757. reason = IEEE80211_REASON_AUTH_LEAVE;
  758. goto deauth;
  759. }
  760. }
  761. if (info & EAPOL_KEY_SECURE) {
  762. #ifndef IEEE80211_STA_ONLY
  763. if (ic->ic_opmode != IEEE80211_M_IBSS ||
  764. ++ni->ni_key_count == 2)
  765. #endif
  766. {
  767. DPRINTF(("marking port %s valid\n",
  768. ether_sprintf(ni->ni_macaddr)));
  769. ni->ni_port_valid = 1;
  770. ieee80211_set_link_state(ic, LINK_STATE_UP);
  771. }
  772. }
  773. /* update the last seen value of the key replay counter field */
  774. ni->ni_replaycnt = BE_READ_8(key->replaycnt);
  775. if (ic->ic_if.if_flags & IFF_DEBUG)
  776. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  777. ic->ic_if.if_xname, 1, 2, "group key",
  778. ether_sprintf(ni->ni_macaddr));
  779. /* send message 2 to authenticator */
  780. (void)ieee80211_send_group_msg2(ic, ni, NULL);
  781. return;
  782. deauth:
  783. IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH, reason);
  784. ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
  785. }
  786. /*
  787. * Process Message 1 of the WPA Group Key Handshake (sent by Authenticator).
  788. */
  789. void
  790. ieee80211_recv_wpa_group_msg1(struct ieee80211com *ic,
  791. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  792. {
  793. struct ieee80211_key *k;
  794. u_int16_t info;
  795. u_int8_t kid;
  796. int keylen;
  797. #ifndef IEEE80211_STA_ONLY
  798. if (ic->ic_opmode != IEEE80211_M_STA &&
  799. ic->ic_opmode != IEEE80211_M_IBSS)
  800. return;
  801. #endif
  802. if (BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) {
  803. ic->ic_stats.is_rx_eapol_replay++;
  804. return;
  805. }
  806. /* check Key MIC field using KCK */
  807. if (ieee80211_eapol_key_check_mic(key, ni->ni_ptk.kck) != 0) {
  808. DPRINTF(("key MIC failed\n"));
  809. ic->ic_stats.is_rx_eapol_badmic++;
  810. return;
  811. }
  812. /*
  813. * EAPOL-Key data field is encrypted even though WPA doesn't set
  814. * the ENCRYPTED bit in the info field.
  815. */
  816. if (ieee80211_eapol_key_decrypt(key, ni->ni_ptk.kek) != 0) {
  817. DPRINTF(("decryption failed\n"));
  818. return;
  819. }
  820. /* check that key length matches that of group cipher */
  821. keylen = ieee80211_cipher_keylen(ni->ni_rsngroupcipher);
  822. if (BE_READ_2(key->keylen) != keylen)
  823. return;
  824. /* check that the data length is large enough to hold the key */
  825. if (BE_READ_2(key->paylen) < keylen)
  826. return;
  827. info = BE_READ_2(key->info);
  828. /* map GTK to 802.11 key */
  829. kid = (info >> EAPOL_KEY_WPA_KID_SHIFT) & 3;
  830. k = &ic->ic_nw_keys[kid];
  831. memset(k, 0, sizeof(*k));
  832. k->k_id = kid; /* 0-3 */
  833. k->k_cipher = ni->ni_rsngroupcipher;
  834. k->k_flags = IEEE80211_KEY_GROUP;
  835. if (info & EAPOL_KEY_WPA_TX)
  836. k->k_flags |= IEEE80211_KEY_TX;
  837. k->k_rsc[0] = LE_READ_6(key->rsc);
  838. k->k_len = keylen;
  839. /* key data field contains the GTK */
  840. memcpy(k->k_key, &key[1], k->k_len);
  841. /* install the GTK */
  842. if ((*ic->ic_set_key)(ic, ni, k) != 0) {
  843. IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
  844. IEEE80211_REASON_AUTH_LEAVE);
  845. ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
  846. return;
  847. }
  848. if (info & EAPOL_KEY_SECURE) {
  849. #ifndef IEEE80211_STA_ONLY
  850. if (ic->ic_opmode != IEEE80211_M_IBSS ||
  851. ++ni->ni_key_count == 2)
  852. #endif
  853. {
  854. DPRINTF(("marking port %s valid\n",
  855. ether_sprintf(ni->ni_macaddr)));
  856. ni->ni_port_valid = 1;
  857. ieee80211_set_link_state(ic, LINK_STATE_UP);
  858. }
  859. }
  860. /* update the last seen value of the key replay counter field */
  861. ni->ni_replaycnt = BE_READ_8(key->replaycnt);
  862. if (ic->ic_if.if_flags & IFF_DEBUG)
  863. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  864. ic->ic_if.if_xname, 1, 2, "group key",
  865. ether_sprintf(ni->ni_macaddr));
  866. /* send message 2 to authenticator */
  867. (void)ieee80211_send_group_msg2(ic, ni, k);
  868. }
  869. #ifndef IEEE80211_STA_ONLY
  870. /*
  871. * Process Message 2 of the Group Key Handshake (sent by Supplicant).
  872. */
  873. void
  874. ieee80211_recv_group_msg2(struct ieee80211com *ic,
  875. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  876. {
  877. if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
  878. ic->ic_opmode != IEEE80211_M_IBSS)
  879. return;
  880. /* discard if we're not expecting this message */
  881. if (ni->ni_rsn_gstate != RSNA_REKEYNEGOTIATING) {
  882. DPRINTF(("%s: unexpected in state: %d\n", ic->ic_if.if_xname,
  883. ni->ni_rsn_gstate));
  884. return;
  885. }
  886. if (BE_READ_8(key->replaycnt) != ni->ni_replaycnt) {
  887. ic->ic_stats.is_rx_eapol_replay++;
  888. return;
  889. }
  890. /* check Key MIC field using KCK */
  891. if (ieee80211_eapol_key_check_mic(key, ni->ni_ptk.kck) != 0) {
  892. DPRINTF(("key MIC failed\n"));
  893. ic->ic_stats.is_rx_eapol_badmic++;
  894. return;
  895. }
  896. timeout_del(&ni->ni_eapol_to);
  897. ni->ni_rsn_gstate = RSNA_REKEYESTABLISHED;
  898. if ((ni->ni_flags & IEEE80211_NODE_REKEY) &&
  899. --ic->ic_rsn_keydonesta == 0)
  900. ieee80211_setkeysdone(ic);
  901. ni->ni_flags &= ~IEEE80211_NODE_REKEY;
  902. ni->ni_flags |= IEEE80211_NODE_TXRXPROT;
  903. ni->ni_rsn_gstate = RSNA_IDLE;
  904. ni->ni_rsn_retries = 0;
  905. if (ic->ic_if.if_flags & IFF_DEBUG)
  906. printf("%s: received msg %d/%d of the %s handshake from %s\n",
  907. ic->ic_if.if_xname, 2, 2, "group key",
  908. ether_sprintf(ni->ni_macaddr));
  909. }
  910. /*
  911. * EAPOL-Key Request frames are sent by the supplicant to request that the
  912. * authenticator initiates either a 4-Way Handshake or Group Key Handshake,
  913. * or to report a MIC failure in a TKIP MSDU.
  914. */
  915. void
  916. ieee80211_recv_eapol_key_req(struct ieee80211com *ic,
  917. struct ieee80211_eapol_key *key, struct ieee80211_node *ni)
  918. {
  919. u_int16_t info;
  920. if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
  921. ic->ic_opmode != IEEE80211_M_IBSS)
  922. return;
  923. /* enforce monotonicity of key request replay counter */
  924. if (ni->ni_reqreplaycnt_ok &&
  925. BE_READ_8(key->replaycnt) <= ni->ni_reqreplaycnt) {
  926. ic->ic_stats.is_rx_eapol_replay++;
  927. return;
  928. }
  929. info = BE_READ_2(key->info);
  930. if (!(info & EAPOL_KEY_KEYMIC) ||
  931. ieee80211_eapol_key_check_mic(key, ni->ni_ptk.kck) != 0) {
  932. DPRINTF(("key request MIC failed\n"));
  933. ic->ic_stats.is_rx_eapol_badmic++;
  934. return;
  935. }
  936. /* update key request replay counter now that MIC is verified */
  937. ni->ni_reqreplaycnt = BE_READ_8(key->replaycnt);
  938. ni->ni_reqreplaycnt_ok = 1;
  939. if (info & EAPOL_KEY_ERROR) { /* TKIP MIC failure */
  940. /* ignore reports from STAs not using TKIP */
  941. if (ic->ic_bss->ni_rsngroupcipher != IEEE80211_CIPHER_TKIP &&
  942. ni->ni_rsncipher != IEEE80211_CIPHER_TKIP) {
  943. DPRINTF(("MIC failure report from !TKIP STA: %s\n",
  944. ether_sprintf(ni->ni_macaddr)));
  945. return;
  946. }
  947. ic->ic_stats.is_rx_remmicfail++;
  948. ieee80211_michael_mic_failure(ic, LE_READ_6(key->rsc));
  949. } else if (info & EAPOL_KEY_PAIRWISE) {
  950. /* initiate a 4-Way Handshake */
  951. } else {
  952. /*
  953. * Should change the GTK, initiate the 4-Way Handshake and
  954. * then execute a Group Key Handshake with all supplicants.
  955. */
  956. }
  957. }
  958. #endif /* IEEE80211_STA_ONLY */