wpa.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright 2002-2004, Instant802 Networks, Inc.
  4. * Copyright 2008, Jouni Malinen <[email protected]>
  5. * Copyright (C) 2016-2017 Intel Deutschland GmbH
  6. * Copyright (C) 2020-2022 Intel Corporation
  7. */
  8. #include <linux/netdevice.h>
  9. #include <linux/types.h>
  10. #include <linux/skbuff.h>
  11. #include <linux/compiler.h>
  12. #include <linux/ieee80211.h>
  13. #include <linux/gfp.h>
  14. #include <asm/unaligned.h>
  15. #include <net/mac80211.h>
  16. #include <crypto/aes.h>
  17. #include <crypto/algapi.h>
  18. #include "ieee80211_i.h"
  19. #include "michael.h"
  20. #include "tkip.h"
  21. #include "aes_ccm.h"
  22. #include "aes_cmac.h"
  23. #include "aes_gmac.h"
  24. #include "aes_gcm.h"
  25. #include "wpa.h"
  26. ieee80211_tx_result
  27. ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
  28. {
  29. u8 *data, *key, *mic;
  30. size_t data_len;
  31. unsigned int hdrlen;
  32. struct ieee80211_hdr *hdr;
  33. struct sk_buff *skb = tx->skb;
  34. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  35. int tail;
  36. hdr = (struct ieee80211_hdr *)skb->data;
  37. if (!tx->key || tx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
  38. skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
  39. return TX_CONTINUE;
  40. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  41. if (skb->len < hdrlen)
  42. return TX_DROP;
  43. data = skb->data + hdrlen;
  44. data_len = skb->len - hdrlen;
  45. if (unlikely(info->flags & IEEE80211_TX_INTFL_TKIP_MIC_FAILURE)) {
  46. /* Need to use software crypto for the test */
  47. info->control.hw_key = NULL;
  48. }
  49. if (info->control.hw_key &&
  50. (info->flags & IEEE80211_TX_CTL_DONTFRAG ||
  51. ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) &&
  52. !(tx->key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
  53. IEEE80211_KEY_FLAG_PUT_MIC_SPACE))) {
  54. /* hwaccel - with no need for SW-generated MMIC or MIC space */
  55. return TX_CONTINUE;
  56. }
  57. tail = MICHAEL_MIC_LEN;
  58. if (!info->control.hw_key)
  59. tail += IEEE80211_TKIP_ICV_LEN;
  60. if (WARN(skb_tailroom(skb) < tail ||
  61. skb_headroom(skb) < IEEE80211_TKIP_IV_LEN,
  62. "mmic: not enough head/tail (%d/%d,%d/%d)\n",
  63. skb_headroom(skb), IEEE80211_TKIP_IV_LEN,
  64. skb_tailroom(skb), tail))
  65. return TX_DROP;
  66. mic = skb_put(skb, MICHAEL_MIC_LEN);
  67. if (tx->key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) {
  68. /* Zeroed MIC can help with debug */
  69. memset(mic, 0, MICHAEL_MIC_LEN);
  70. return TX_CONTINUE;
  71. }
  72. key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY];
  73. michael_mic(key, hdr, data, data_len, mic);
  74. if (unlikely(info->flags & IEEE80211_TX_INTFL_TKIP_MIC_FAILURE))
  75. mic[0]++;
  76. return TX_CONTINUE;
  77. }
  78. ieee80211_rx_result
  79. ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
  80. {
  81. u8 *data, *key = NULL;
  82. size_t data_len;
  83. unsigned int hdrlen;
  84. u8 mic[MICHAEL_MIC_LEN];
  85. struct sk_buff *skb = rx->skb;
  86. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  87. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  88. /*
  89. * it makes no sense to check for MIC errors on anything other
  90. * than data frames.
  91. */
  92. if (!ieee80211_is_data_present(hdr->frame_control))
  93. return RX_CONTINUE;
  94. /*
  95. * No way to verify the MIC if the hardware stripped it or
  96. * the IV with the key index. In this case we have solely rely
  97. * on the driver to set RX_FLAG_MMIC_ERROR in the event of a
  98. * MIC failure report.
  99. */
  100. if (status->flag & (RX_FLAG_MMIC_STRIPPED | RX_FLAG_IV_STRIPPED)) {
  101. if (status->flag & RX_FLAG_MMIC_ERROR)
  102. goto mic_fail_no_key;
  103. if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key &&
  104. rx->key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)
  105. goto update_iv;
  106. return RX_CONTINUE;
  107. }
  108. /*
  109. * Some hardware seems to generate Michael MIC failure reports; even
  110. * though, the frame was not encrypted with TKIP and therefore has no
  111. * MIC. Ignore the flag them to avoid triggering countermeasures.
  112. */
  113. if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
  114. !(status->flag & RX_FLAG_DECRYPTED))
  115. return RX_CONTINUE;
  116. if (rx->sdata->vif.type == NL80211_IFTYPE_AP && rx->key->conf.keyidx) {
  117. /*
  118. * APs with pairwise keys should never receive Michael MIC
  119. * errors for non-zero keyidx because these are reserved for
  120. * group keys and only the AP is sending real multicast
  121. * frames in the BSS.
  122. */
  123. return RX_DROP_UNUSABLE;
  124. }
  125. if (status->flag & RX_FLAG_MMIC_ERROR)
  126. goto mic_fail;
  127. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  128. if (skb->len < hdrlen + MICHAEL_MIC_LEN)
  129. return RX_DROP_UNUSABLE;
  130. if (skb_linearize(rx->skb))
  131. return RX_DROP_UNUSABLE;
  132. hdr = (void *)skb->data;
  133. data = skb->data + hdrlen;
  134. data_len = skb->len - hdrlen - MICHAEL_MIC_LEN;
  135. key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY];
  136. michael_mic(key, hdr, data, data_len, mic);
  137. if (crypto_memneq(mic, data + data_len, MICHAEL_MIC_LEN))
  138. goto mic_fail;
  139. /* remove Michael MIC from payload */
  140. skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
  141. update_iv:
  142. /* update IV in key information to be able to detect replays */
  143. rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip.iv32;
  144. rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip.iv16;
  145. return RX_CONTINUE;
  146. mic_fail:
  147. rx->key->u.tkip.mic_failures++;
  148. mic_fail_no_key:
  149. /*
  150. * In some cases the key can be unset - e.g. a multicast packet, in
  151. * a driver that supports HW encryption. Send up the key idx only if
  152. * the key is set.
  153. */
  154. cfg80211_michael_mic_failure(rx->sdata->dev, hdr->addr2,
  155. is_multicast_ether_addr(hdr->addr1) ?
  156. NL80211_KEYTYPE_GROUP :
  157. NL80211_KEYTYPE_PAIRWISE,
  158. rx->key ? rx->key->conf.keyidx : -1,
  159. NULL, GFP_ATOMIC);
  160. return RX_DROP_UNUSABLE;
  161. }
  162. static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
  163. {
  164. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  165. struct ieee80211_key *key = tx->key;
  166. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  167. unsigned int hdrlen;
  168. int len, tail;
  169. u64 pn;
  170. u8 *pos;
  171. if (info->control.hw_key &&
  172. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
  173. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
  174. /* hwaccel - with no need for software-generated IV */
  175. return 0;
  176. }
  177. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  178. len = skb->len - hdrlen;
  179. if (info->control.hw_key)
  180. tail = 0;
  181. else
  182. tail = IEEE80211_TKIP_ICV_LEN;
  183. if (WARN_ON(skb_tailroom(skb) < tail ||
  184. skb_headroom(skb) < IEEE80211_TKIP_IV_LEN))
  185. return -1;
  186. pos = skb_push(skb, IEEE80211_TKIP_IV_LEN);
  187. memmove(pos, pos + IEEE80211_TKIP_IV_LEN, hdrlen);
  188. pos += hdrlen;
  189. /* the HW only needs room for the IV, but not the actual IV */
  190. if (info->control.hw_key &&
  191. (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))
  192. return 0;
  193. /* Increase IV for the frame */
  194. pn = atomic64_inc_return(&key->conf.tx_pn);
  195. pos = ieee80211_tkip_add_iv(pos, &key->conf, pn);
  196. /* hwaccel - with software IV */
  197. if (info->control.hw_key)
  198. return 0;
  199. /* Add room for ICV */
  200. skb_put(skb, IEEE80211_TKIP_ICV_LEN);
  201. return ieee80211_tkip_encrypt_data(&tx->local->wep_tx_ctx,
  202. key, skb, pos, len);
  203. }
  204. ieee80211_tx_result
  205. ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
  206. {
  207. struct sk_buff *skb;
  208. ieee80211_tx_set_protected(tx);
  209. skb_queue_walk(&tx->skbs, skb) {
  210. if (tkip_encrypt_skb(tx, skb) < 0)
  211. return TX_DROP;
  212. }
  213. return TX_CONTINUE;
  214. }
  215. ieee80211_rx_result
  216. ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
  217. {
  218. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
  219. int hdrlen, res, hwaccel = 0;
  220. struct ieee80211_key *key = rx->key;
  221. struct sk_buff *skb = rx->skb;
  222. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  223. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  224. if (!ieee80211_is_data(hdr->frame_control))
  225. return RX_CONTINUE;
  226. if (!rx->sta || skb->len - hdrlen < 12)
  227. return RX_DROP_UNUSABLE;
  228. /* it may be possible to optimize this a bit more */
  229. if (skb_linearize(rx->skb))
  230. return RX_DROP_UNUSABLE;
  231. hdr = (void *)skb->data;
  232. /*
  233. * Let TKIP code verify IV, but skip decryption.
  234. * In the case where hardware checks the IV as well,
  235. * we don't even get here, see ieee80211_rx_h_decrypt()
  236. */
  237. if (status->flag & RX_FLAG_DECRYPTED)
  238. hwaccel = 1;
  239. res = ieee80211_tkip_decrypt_data(&rx->local->wep_rx_ctx,
  240. key, skb->data + hdrlen,
  241. skb->len - hdrlen, rx->sta->sta.addr,
  242. hdr->addr1, hwaccel, rx->security_idx,
  243. &rx->tkip.iv32,
  244. &rx->tkip.iv16);
  245. if (res != TKIP_DECRYPT_OK)
  246. return RX_DROP_UNUSABLE;
  247. /* Trim ICV */
  248. if (!(status->flag & RX_FLAG_ICV_STRIPPED))
  249. skb_trim(skb, skb->len - IEEE80211_TKIP_ICV_LEN);
  250. /* Remove IV */
  251. memmove(skb->data + IEEE80211_TKIP_IV_LEN, skb->data, hdrlen);
  252. skb_pull(skb, IEEE80211_TKIP_IV_LEN);
  253. return RX_CONTINUE;
  254. }
  255. /*
  256. * Calculate AAD for CCMP/GCMP, returning qos_tid since we
  257. * need that in CCMP also for b_0.
  258. */
  259. static u8 ccmp_gcmp_aad(struct sk_buff *skb, u8 *aad)
  260. {
  261. struct ieee80211_hdr *hdr = (void *)skb->data;
  262. __le16 mask_fc;
  263. int a4_included, mgmt;
  264. u8 qos_tid;
  265. u16 len_a = 22;
  266. /*
  267. * Mask FC: zero subtype b4 b5 b6 (if not mgmt)
  268. * Retry, PwrMgt, MoreData, Order (if Qos Data); set Protected
  269. */
  270. mgmt = ieee80211_is_mgmt(hdr->frame_control);
  271. mask_fc = hdr->frame_control;
  272. mask_fc &= ~cpu_to_le16(IEEE80211_FCTL_RETRY |
  273. IEEE80211_FCTL_PM | IEEE80211_FCTL_MOREDATA);
  274. if (!mgmt)
  275. mask_fc &= ~cpu_to_le16(0x0070);
  276. mask_fc |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
  277. a4_included = ieee80211_has_a4(hdr->frame_control);
  278. if (a4_included)
  279. len_a += 6;
  280. if (ieee80211_is_data_qos(hdr->frame_control)) {
  281. qos_tid = ieee80211_get_tid(hdr);
  282. mask_fc &= ~cpu_to_le16(IEEE80211_FCTL_ORDER);
  283. len_a += 2;
  284. } else {
  285. qos_tid = 0;
  286. }
  287. /* AAD (extra authenticate-only data) / masked 802.11 header
  288. * FC | A1 | A2 | A3 | SC | [A4] | [QC] */
  289. put_unaligned_be16(len_a, &aad[0]);
  290. put_unaligned(mask_fc, (__le16 *)&aad[2]);
  291. memcpy(&aad[4], &hdr->addrs, 3 * ETH_ALEN);
  292. /* Mask Seq#, leave Frag# */
  293. aad[22] = *((u8 *) &hdr->seq_ctrl) & 0x0f;
  294. aad[23] = 0;
  295. if (a4_included) {
  296. memcpy(&aad[24], hdr->addr4, ETH_ALEN);
  297. aad[30] = qos_tid;
  298. aad[31] = 0;
  299. } else {
  300. memset(&aad[24], 0, ETH_ALEN + IEEE80211_QOS_CTL_LEN);
  301. aad[24] = qos_tid;
  302. }
  303. return qos_tid;
  304. }
  305. static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad)
  306. {
  307. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  308. u8 qos_tid = ccmp_gcmp_aad(skb, aad);
  309. /* In CCM, the initial vectors (IV) used for CTR mode encryption and CBC
  310. * mode authentication are not allowed to collide, yet both are derived
  311. * from this vector b_0. We only set L := 1 here to indicate that the
  312. * data size can be represented in (L+1) bytes. The CCM layer will take
  313. * care of storing the data length in the top (L+1) bytes and setting
  314. * and clearing the other bits as is required to derive the two IVs.
  315. */
  316. b_0[0] = 0x1;
  317. /* Nonce: Nonce Flags | A2 | PN
  318. * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7)
  319. */
  320. b_0[1] = qos_tid | (ieee80211_is_mgmt(hdr->frame_control) << 4);
  321. memcpy(&b_0[2], hdr->addr2, ETH_ALEN);
  322. memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN);
  323. }
  324. static inline void ccmp_pn2hdr(u8 *hdr, u8 *pn, int key_id)
  325. {
  326. hdr[0] = pn[5];
  327. hdr[1] = pn[4];
  328. hdr[2] = 0;
  329. hdr[3] = 0x20 | (key_id << 6);
  330. hdr[4] = pn[3];
  331. hdr[5] = pn[2];
  332. hdr[6] = pn[1];
  333. hdr[7] = pn[0];
  334. }
  335. static inline void ccmp_hdr2pn(u8 *pn, u8 *hdr)
  336. {
  337. pn[0] = hdr[7];
  338. pn[1] = hdr[6];
  339. pn[2] = hdr[5];
  340. pn[3] = hdr[4];
  341. pn[4] = hdr[1];
  342. pn[5] = hdr[0];
  343. }
  344. static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb,
  345. unsigned int mic_len)
  346. {
  347. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  348. struct ieee80211_key *key = tx->key;
  349. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  350. int hdrlen, len, tail;
  351. u8 *pos;
  352. u8 pn[6];
  353. u64 pn64;
  354. u8 aad[CCM_AAD_LEN];
  355. u8 b_0[AES_BLOCK_SIZE];
  356. if (info->control.hw_key &&
  357. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
  358. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
  359. !((info->control.hw_key->flags &
  360. IEEE80211_KEY_FLAG_GENERATE_IV_MGMT) &&
  361. ieee80211_is_mgmt(hdr->frame_control))) {
  362. /*
  363. * hwaccel has no need for preallocated room for CCMP
  364. * header or MIC fields
  365. */
  366. return 0;
  367. }
  368. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  369. len = skb->len - hdrlen;
  370. if (info->control.hw_key)
  371. tail = 0;
  372. else
  373. tail = mic_len;
  374. if (WARN_ON(skb_tailroom(skb) < tail ||
  375. skb_headroom(skb) < IEEE80211_CCMP_HDR_LEN))
  376. return -1;
  377. pos = skb_push(skb, IEEE80211_CCMP_HDR_LEN);
  378. memmove(pos, pos + IEEE80211_CCMP_HDR_LEN, hdrlen);
  379. /* the HW only needs room for the IV, but not the actual IV */
  380. if (info->control.hw_key &&
  381. (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))
  382. return 0;
  383. pos += hdrlen;
  384. pn64 = atomic64_inc_return(&key->conf.tx_pn);
  385. pn[5] = pn64;
  386. pn[4] = pn64 >> 8;
  387. pn[3] = pn64 >> 16;
  388. pn[2] = pn64 >> 24;
  389. pn[1] = pn64 >> 32;
  390. pn[0] = pn64 >> 40;
  391. ccmp_pn2hdr(pos, pn, key->conf.keyidx);
  392. /* hwaccel - with software CCMP header */
  393. if (info->control.hw_key)
  394. return 0;
  395. pos += IEEE80211_CCMP_HDR_LEN;
  396. ccmp_special_blocks(skb, pn, b_0, aad);
  397. return ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
  398. skb_put(skb, mic_len));
  399. }
  400. ieee80211_tx_result
  401. ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx,
  402. unsigned int mic_len)
  403. {
  404. struct sk_buff *skb;
  405. ieee80211_tx_set_protected(tx);
  406. skb_queue_walk(&tx->skbs, skb) {
  407. if (ccmp_encrypt_skb(tx, skb, mic_len) < 0)
  408. return TX_DROP;
  409. }
  410. return TX_CONTINUE;
  411. }
  412. ieee80211_rx_result
  413. ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
  414. unsigned int mic_len)
  415. {
  416. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
  417. int hdrlen;
  418. struct ieee80211_key *key = rx->key;
  419. struct sk_buff *skb = rx->skb;
  420. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  421. u8 pn[IEEE80211_CCMP_PN_LEN];
  422. int data_len;
  423. int queue;
  424. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  425. if (!ieee80211_is_data(hdr->frame_control) &&
  426. !ieee80211_is_robust_mgmt_frame(skb))
  427. return RX_CONTINUE;
  428. if (status->flag & RX_FLAG_DECRYPTED) {
  429. if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_CCMP_HDR_LEN))
  430. return RX_DROP_UNUSABLE;
  431. if (status->flag & RX_FLAG_MIC_STRIPPED)
  432. mic_len = 0;
  433. } else {
  434. if (skb_linearize(rx->skb))
  435. return RX_DROP_UNUSABLE;
  436. }
  437. /* reload hdr - skb might have been reallocated */
  438. hdr = (void *)rx->skb->data;
  439. data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
  440. if (!rx->sta || data_len < 0)
  441. return RX_DROP_UNUSABLE;
  442. if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
  443. int res;
  444. ccmp_hdr2pn(pn, skb->data + hdrlen);
  445. queue = rx->security_idx;
  446. res = memcmp(pn, key->u.ccmp.rx_pn[queue],
  447. IEEE80211_CCMP_PN_LEN);
  448. if (res < 0 ||
  449. (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) {
  450. key->u.ccmp.replays++;
  451. return RX_DROP_UNUSABLE;
  452. }
  453. if (!(status->flag & RX_FLAG_DECRYPTED)) {
  454. u8 aad[2 * AES_BLOCK_SIZE];
  455. u8 b_0[AES_BLOCK_SIZE];
  456. /* hardware didn't decrypt/verify MIC */
  457. ccmp_special_blocks(skb, pn, b_0, aad);
  458. if (ieee80211_aes_ccm_decrypt(
  459. key->u.ccmp.tfm, b_0, aad,
  460. skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN,
  461. data_len,
  462. skb->data + skb->len - mic_len))
  463. return RX_DROP_UNUSABLE;
  464. }
  465. memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
  466. if (unlikely(ieee80211_is_frag(hdr)))
  467. memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN);
  468. }
  469. /* Remove CCMP header and MIC */
  470. if (pskb_trim(skb, skb->len - mic_len))
  471. return RX_DROP_UNUSABLE;
  472. memmove(skb->data + IEEE80211_CCMP_HDR_LEN, skb->data, hdrlen);
  473. skb_pull(skb, IEEE80211_CCMP_HDR_LEN);
  474. return RX_CONTINUE;
  475. }
  476. static void gcmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *j_0, u8 *aad)
  477. {
  478. struct ieee80211_hdr *hdr = (void *)skb->data;
  479. memcpy(j_0, hdr->addr2, ETH_ALEN);
  480. memcpy(&j_0[ETH_ALEN], pn, IEEE80211_GCMP_PN_LEN);
  481. j_0[13] = 0;
  482. j_0[14] = 0;
  483. j_0[AES_BLOCK_SIZE - 1] = 0x01;
  484. ccmp_gcmp_aad(skb, aad);
  485. }
  486. static inline void gcmp_pn2hdr(u8 *hdr, const u8 *pn, int key_id)
  487. {
  488. hdr[0] = pn[5];
  489. hdr[1] = pn[4];
  490. hdr[2] = 0;
  491. hdr[3] = 0x20 | (key_id << 6);
  492. hdr[4] = pn[3];
  493. hdr[5] = pn[2];
  494. hdr[6] = pn[1];
  495. hdr[7] = pn[0];
  496. }
  497. static inline void gcmp_hdr2pn(u8 *pn, const u8 *hdr)
  498. {
  499. pn[0] = hdr[7];
  500. pn[1] = hdr[6];
  501. pn[2] = hdr[5];
  502. pn[3] = hdr[4];
  503. pn[4] = hdr[1];
  504. pn[5] = hdr[0];
  505. }
  506. static int gcmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
  507. {
  508. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  509. struct ieee80211_key *key = tx->key;
  510. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  511. int hdrlen, len, tail;
  512. u8 *pos;
  513. u8 pn[6];
  514. u64 pn64;
  515. u8 aad[GCM_AAD_LEN];
  516. u8 j_0[AES_BLOCK_SIZE];
  517. if (info->control.hw_key &&
  518. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
  519. !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
  520. !((info->control.hw_key->flags &
  521. IEEE80211_KEY_FLAG_GENERATE_IV_MGMT) &&
  522. ieee80211_is_mgmt(hdr->frame_control))) {
  523. /* hwaccel has no need for preallocated room for GCMP
  524. * header or MIC fields
  525. */
  526. return 0;
  527. }
  528. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  529. len = skb->len - hdrlen;
  530. if (info->control.hw_key)
  531. tail = 0;
  532. else
  533. tail = IEEE80211_GCMP_MIC_LEN;
  534. if (WARN_ON(skb_tailroom(skb) < tail ||
  535. skb_headroom(skb) < IEEE80211_GCMP_HDR_LEN))
  536. return -1;
  537. pos = skb_push(skb, IEEE80211_GCMP_HDR_LEN);
  538. memmove(pos, pos + IEEE80211_GCMP_HDR_LEN, hdrlen);
  539. skb_set_network_header(skb, skb_network_offset(skb) +
  540. IEEE80211_GCMP_HDR_LEN);
  541. /* the HW only needs room for the IV, but not the actual IV */
  542. if (info->control.hw_key &&
  543. (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))
  544. return 0;
  545. pos += hdrlen;
  546. pn64 = atomic64_inc_return(&key->conf.tx_pn);
  547. pn[5] = pn64;
  548. pn[4] = pn64 >> 8;
  549. pn[3] = pn64 >> 16;
  550. pn[2] = pn64 >> 24;
  551. pn[1] = pn64 >> 32;
  552. pn[0] = pn64 >> 40;
  553. gcmp_pn2hdr(pos, pn, key->conf.keyidx);
  554. /* hwaccel - with software GCMP header */
  555. if (info->control.hw_key)
  556. return 0;
  557. pos += IEEE80211_GCMP_HDR_LEN;
  558. gcmp_special_blocks(skb, pn, j_0, aad);
  559. return ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
  560. skb_put(skb, IEEE80211_GCMP_MIC_LEN));
  561. }
  562. ieee80211_tx_result
  563. ieee80211_crypto_gcmp_encrypt(struct ieee80211_tx_data *tx)
  564. {
  565. struct sk_buff *skb;
  566. ieee80211_tx_set_protected(tx);
  567. skb_queue_walk(&tx->skbs, skb) {
  568. if (gcmp_encrypt_skb(tx, skb) < 0)
  569. return TX_DROP;
  570. }
  571. return TX_CONTINUE;
  572. }
  573. ieee80211_rx_result
  574. ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
  575. {
  576. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
  577. int hdrlen;
  578. struct ieee80211_key *key = rx->key;
  579. struct sk_buff *skb = rx->skb;
  580. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  581. u8 pn[IEEE80211_GCMP_PN_LEN];
  582. int data_len, queue, mic_len = IEEE80211_GCMP_MIC_LEN;
  583. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  584. if (!ieee80211_is_data(hdr->frame_control) &&
  585. !ieee80211_is_robust_mgmt_frame(skb))
  586. return RX_CONTINUE;
  587. if (status->flag & RX_FLAG_DECRYPTED) {
  588. if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_GCMP_HDR_LEN))
  589. return RX_DROP_UNUSABLE;
  590. if (status->flag & RX_FLAG_MIC_STRIPPED)
  591. mic_len = 0;
  592. } else {
  593. if (skb_linearize(rx->skb))
  594. return RX_DROP_UNUSABLE;
  595. }
  596. /* reload hdr - skb might have been reallocated */
  597. hdr = (void *)rx->skb->data;
  598. data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len;
  599. if (!rx->sta || data_len < 0)
  600. return RX_DROP_UNUSABLE;
  601. if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
  602. int res;
  603. gcmp_hdr2pn(pn, skb->data + hdrlen);
  604. queue = rx->security_idx;
  605. res = memcmp(pn, key->u.gcmp.rx_pn[queue],
  606. IEEE80211_GCMP_PN_LEN);
  607. if (res < 0 ||
  608. (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) {
  609. key->u.gcmp.replays++;
  610. return RX_DROP_UNUSABLE;
  611. }
  612. if (!(status->flag & RX_FLAG_DECRYPTED)) {
  613. u8 aad[2 * AES_BLOCK_SIZE];
  614. u8 j_0[AES_BLOCK_SIZE];
  615. /* hardware didn't decrypt/verify MIC */
  616. gcmp_special_blocks(skb, pn, j_0, aad);
  617. if (ieee80211_aes_gcm_decrypt(
  618. key->u.gcmp.tfm, j_0, aad,
  619. skb->data + hdrlen + IEEE80211_GCMP_HDR_LEN,
  620. data_len,
  621. skb->data + skb->len -
  622. IEEE80211_GCMP_MIC_LEN))
  623. return RX_DROP_UNUSABLE;
  624. }
  625. memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN);
  626. if (unlikely(ieee80211_is_frag(hdr)))
  627. memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN);
  628. }
  629. /* Remove GCMP header and MIC */
  630. if (pskb_trim(skb, skb->len - mic_len))
  631. return RX_DROP_UNUSABLE;
  632. memmove(skb->data + IEEE80211_GCMP_HDR_LEN, skb->data, hdrlen);
  633. skb_pull(skb, IEEE80211_GCMP_HDR_LEN);
  634. return RX_CONTINUE;
  635. }
  636. static void bip_aad(struct sk_buff *skb, u8 *aad)
  637. {
  638. __le16 mask_fc;
  639. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  640. /* BIP AAD: FC(masked) || A1 || A2 || A3 */
  641. /* FC type/subtype */
  642. /* Mask FC Retry, PwrMgt, MoreData flags to zero */
  643. mask_fc = hdr->frame_control;
  644. mask_fc &= ~cpu_to_le16(IEEE80211_FCTL_RETRY | IEEE80211_FCTL_PM |
  645. IEEE80211_FCTL_MOREDATA);
  646. put_unaligned(mask_fc, (__le16 *) &aad[0]);
  647. /* A1 || A2 || A3 */
  648. memcpy(aad + 2, &hdr->addrs, 3 * ETH_ALEN);
  649. }
  650. static inline void bip_ipn_set64(u8 *d, u64 pn)
  651. {
  652. *d++ = pn;
  653. *d++ = pn >> 8;
  654. *d++ = pn >> 16;
  655. *d++ = pn >> 24;
  656. *d++ = pn >> 32;
  657. *d = pn >> 40;
  658. }
  659. static inline void bip_ipn_swap(u8 *d, const u8 *s)
  660. {
  661. *d++ = s[5];
  662. *d++ = s[4];
  663. *d++ = s[3];
  664. *d++ = s[2];
  665. *d++ = s[1];
  666. *d = s[0];
  667. }
  668. ieee80211_tx_result
  669. ieee80211_crypto_aes_cmac_encrypt(struct ieee80211_tx_data *tx)
  670. {
  671. struct sk_buff *skb;
  672. struct ieee80211_tx_info *info;
  673. struct ieee80211_key *key = tx->key;
  674. struct ieee80211_mmie *mmie;
  675. u8 aad[20];
  676. u64 pn64;
  677. if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
  678. return TX_DROP;
  679. skb = skb_peek(&tx->skbs);
  680. info = IEEE80211_SKB_CB(skb);
  681. if (info->control.hw_key &&
  682. !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
  683. return TX_CONTINUE;
  684. if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
  685. return TX_DROP;
  686. mmie = skb_put(skb, sizeof(*mmie));
  687. mmie->element_id = WLAN_EID_MMIE;
  688. mmie->length = sizeof(*mmie) - 2;
  689. mmie->key_id = cpu_to_le16(key->conf.keyidx);
  690. /* PN = PN + 1 */
  691. pn64 = atomic64_inc_return(&key->conf.tx_pn);
  692. bip_ipn_set64(mmie->sequence_number, pn64);
  693. if (info->control.hw_key)
  694. return TX_CONTINUE;
  695. bip_aad(skb, aad);
  696. /*
  697. * MIC = AES-128-CMAC(IGTK, AAD || Management Frame Body || MMIE, 64)
  698. */
  699. ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad,
  700. skb->data + 24, skb->len - 24, mmie->mic);
  701. return TX_CONTINUE;
  702. }
  703. ieee80211_tx_result
  704. ieee80211_crypto_aes_cmac_256_encrypt(struct ieee80211_tx_data *tx)
  705. {
  706. struct sk_buff *skb;
  707. struct ieee80211_tx_info *info;
  708. struct ieee80211_key *key = tx->key;
  709. struct ieee80211_mmie_16 *mmie;
  710. u8 aad[20];
  711. u64 pn64;
  712. if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
  713. return TX_DROP;
  714. skb = skb_peek(&tx->skbs);
  715. info = IEEE80211_SKB_CB(skb);
  716. if (info->control.hw_key)
  717. return TX_CONTINUE;
  718. if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
  719. return TX_DROP;
  720. mmie = skb_put(skb, sizeof(*mmie));
  721. mmie->element_id = WLAN_EID_MMIE;
  722. mmie->length = sizeof(*mmie) - 2;
  723. mmie->key_id = cpu_to_le16(key->conf.keyidx);
  724. /* PN = PN + 1 */
  725. pn64 = atomic64_inc_return(&key->conf.tx_pn);
  726. bip_ipn_set64(mmie->sequence_number, pn64);
  727. bip_aad(skb, aad);
  728. /* MIC = AES-256-CMAC(IGTK, AAD || Management Frame Body || MMIE, 128)
  729. */
  730. ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad,
  731. skb->data + 24, skb->len - 24, mmie->mic);
  732. return TX_CONTINUE;
  733. }
  734. ieee80211_rx_result
  735. ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx)
  736. {
  737. struct sk_buff *skb = rx->skb;
  738. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  739. struct ieee80211_key *key = rx->key;
  740. struct ieee80211_mmie *mmie;
  741. u8 aad[20], mic[8], ipn[6];
  742. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  743. if (!ieee80211_is_mgmt(hdr->frame_control))
  744. return RX_CONTINUE;
  745. /* management frames are already linear */
  746. if (skb->len < 24 + sizeof(*mmie))
  747. return RX_DROP_UNUSABLE;
  748. mmie = (struct ieee80211_mmie *)
  749. (skb->data + skb->len - sizeof(*mmie));
  750. if (mmie->element_id != WLAN_EID_MMIE ||
  751. mmie->length != sizeof(*mmie) - 2)
  752. return RX_DROP_UNUSABLE; /* Invalid MMIE */
  753. bip_ipn_swap(ipn, mmie->sequence_number);
  754. if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) {
  755. key->u.aes_cmac.replays++;
  756. return RX_DROP_UNUSABLE;
  757. }
  758. if (!(status->flag & RX_FLAG_DECRYPTED)) {
  759. /* hardware didn't decrypt/verify MIC */
  760. bip_aad(skb, aad);
  761. ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad,
  762. skb->data + 24, skb->len - 24, mic);
  763. if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
  764. key->u.aes_cmac.icverrors++;
  765. return RX_DROP_UNUSABLE;
  766. }
  767. }
  768. memcpy(key->u.aes_cmac.rx_pn, ipn, 6);
  769. /* Remove MMIE */
  770. skb_trim(skb, skb->len - sizeof(*mmie));
  771. return RX_CONTINUE;
  772. }
  773. ieee80211_rx_result
  774. ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx)
  775. {
  776. struct sk_buff *skb = rx->skb;
  777. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  778. struct ieee80211_key *key = rx->key;
  779. struct ieee80211_mmie_16 *mmie;
  780. u8 aad[20], mic[16], ipn[6];
  781. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  782. if (!ieee80211_is_mgmt(hdr->frame_control))
  783. return RX_CONTINUE;
  784. /* management frames are already linear */
  785. if (skb->len < 24 + sizeof(*mmie))
  786. return RX_DROP_UNUSABLE;
  787. mmie = (struct ieee80211_mmie_16 *)
  788. (skb->data + skb->len - sizeof(*mmie));
  789. if (mmie->element_id != WLAN_EID_MMIE ||
  790. mmie->length != sizeof(*mmie) - 2)
  791. return RX_DROP_UNUSABLE; /* Invalid MMIE */
  792. bip_ipn_swap(ipn, mmie->sequence_number);
  793. if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) {
  794. key->u.aes_cmac.replays++;
  795. return RX_DROP_UNUSABLE;
  796. }
  797. if (!(status->flag & RX_FLAG_DECRYPTED)) {
  798. /* hardware didn't decrypt/verify MIC */
  799. bip_aad(skb, aad);
  800. ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad,
  801. skb->data + 24, skb->len - 24, mic);
  802. if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
  803. key->u.aes_cmac.icverrors++;
  804. return RX_DROP_UNUSABLE;
  805. }
  806. }
  807. memcpy(key->u.aes_cmac.rx_pn, ipn, 6);
  808. /* Remove MMIE */
  809. skb_trim(skb, skb->len - sizeof(*mmie));
  810. return RX_CONTINUE;
  811. }
  812. ieee80211_tx_result
  813. ieee80211_crypto_aes_gmac_encrypt(struct ieee80211_tx_data *tx)
  814. {
  815. struct sk_buff *skb;
  816. struct ieee80211_tx_info *info;
  817. struct ieee80211_key *key = tx->key;
  818. struct ieee80211_mmie_16 *mmie;
  819. struct ieee80211_hdr *hdr;
  820. u8 aad[GMAC_AAD_LEN];
  821. u64 pn64;
  822. u8 nonce[GMAC_NONCE_LEN];
  823. if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
  824. return TX_DROP;
  825. skb = skb_peek(&tx->skbs);
  826. info = IEEE80211_SKB_CB(skb);
  827. if (info->control.hw_key)
  828. return TX_CONTINUE;
  829. if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
  830. return TX_DROP;
  831. mmie = skb_put(skb, sizeof(*mmie));
  832. mmie->element_id = WLAN_EID_MMIE;
  833. mmie->length = sizeof(*mmie) - 2;
  834. mmie->key_id = cpu_to_le16(key->conf.keyidx);
  835. /* PN = PN + 1 */
  836. pn64 = atomic64_inc_return(&key->conf.tx_pn);
  837. bip_ipn_set64(mmie->sequence_number, pn64);
  838. bip_aad(skb, aad);
  839. hdr = (struct ieee80211_hdr *)skb->data;
  840. memcpy(nonce, hdr->addr2, ETH_ALEN);
  841. bip_ipn_swap(nonce + ETH_ALEN, mmie->sequence_number);
  842. /* MIC = AES-GMAC(IGTK, AAD || Management Frame Body || MMIE, 128) */
  843. if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce,
  844. skb->data + 24, skb->len - 24, mmie->mic) < 0)
  845. return TX_DROP;
  846. return TX_CONTINUE;
  847. }
  848. ieee80211_rx_result
  849. ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
  850. {
  851. struct sk_buff *skb = rx->skb;
  852. struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  853. struct ieee80211_key *key = rx->key;
  854. struct ieee80211_mmie_16 *mmie;
  855. u8 aad[GMAC_AAD_LEN], *mic, ipn[6], nonce[GMAC_NONCE_LEN];
  856. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  857. if (!ieee80211_is_mgmt(hdr->frame_control))
  858. return RX_CONTINUE;
  859. /* management frames are already linear */
  860. if (skb->len < 24 + sizeof(*mmie))
  861. return RX_DROP_UNUSABLE;
  862. mmie = (struct ieee80211_mmie_16 *)
  863. (skb->data + skb->len - sizeof(*mmie));
  864. if (mmie->element_id != WLAN_EID_MMIE ||
  865. mmie->length != sizeof(*mmie) - 2)
  866. return RX_DROP_UNUSABLE; /* Invalid MMIE */
  867. bip_ipn_swap(ipn, mmie->sequence_number);
  868. if (memcmp(ipn, key->u.aes_gmac.rx_pn, 6) <= 0) {
  869. key->u.aes_gmac.replays++;
  870. return RX_DROP_UNUSABLE;
  871. }
  872. if (!(status->flag & RX_FLAG_DECRYPTED)) {
  873. /* hardware didn't decrypt/verify MIC */
  874. bip_aad(skb, aad);
  875. memcpy(nonce, hdr->addr2, ETH_ALEN);
  876. memcpy(nonce + ETH_ALEN, ipn, 6);
  877. mic = kmalloc(GMAC_MIC_LEN, GFP_ATOMIC);
  878. if (!mic)
  879. return RX_DROP_UNUSABLE;
  880. if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce,
  881. skb->data + 24, skb->len - 24,
  882. mic) < 0 ||
  883. crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
  884. key->u.aes_gmac.icverrors++;
  885. kfree(mic);
  886. return RX_DROP_UNUSABLE;
  887. }
  888. kfree(mic);
  889. }
  890. memcpy(key->u.aes_gmac.rx_pn, ipn, 6);
  891. /* Remove MMIE */
  892. skb_trim(skb, skb->len - sizeof(*mmie));
  893. return RX_CONTINUE;
  894. }