ieee80211_crypto.c revision 1.23.2.3 1 1.23.2.3 phil /* $NetBSD: ieee80211_crypto.c,v 1.23.2.3 2018/07/16 20:11:11 phil Exp $ */
2 1.23.2.2 phil
3 1.23.2.1 phil /*-
4 1.23.2.1 phil * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 1.23.2.1 phil *
6 1.1 dyoung * Copyright (c) 2001 Atsushi Onoe
7 1.23.2.1 phil * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
8 1.1 dyoung * All rights reserved.
9 1.1 dyoung *
10 1.1 dyoung * Redistribution and use in source and binary forms, with or without
11 1.1 dyoung * modification, are permitted provided that the following conditions
12 1.1 dyoung * are met:
13 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
14 1.1 dyoung * notice, this list of conditions and the following disclaimer.
15 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 dyoung * notice, this list of conditions and the following disclaimer in the
17 1.1 dyoung * documentation and/or other materials provided with the distribution.
18 1.1 dyoung *
19 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 1.1 dyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 1.1 dyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 1.1 dyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 1.1 dyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 1.1 dyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 1.1 dyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 1.1 dyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 1.1 dyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 1.1 dyoung */
30 1.1 dyoung
31 1.1 dyoung #include <sys/cdefs.h>
32 1.23.2.3 phil #if __FreeBSD__
33 1.23.2.1 phil __FBSDID("$FreeBSD$");
34 1.23.2.2 phil #endif
35 1.1 dyoung
36 1.7 dyoung /*
37 1.7 dyoung * IEEE 802.11 generic crypto support.
38 1.7 dyoung */
39 1.23.2.1 phil #include "opt_wlan.h"
40 1.23.2.1 phil
41 1.1 dyoung #include <sys/param.h>
42 1.23.2.1 phil #include <sys/kernel.h>
43 1.23.2.1 phil #include <sys/malloc.h>
44 1.23.2.1 phil #include <sys/mbuf.h>
45 1.7 dyoung
46 1.1 dyoung #include <sys/socket.h>
47 1.1 dyoung
48 1.1 dyoung #include <net/if.h>
49 1.1 dyoung #include <net/if_media.h>
50 1.23.2.3 phil #if __FreeBSD__
51 1.23.2.1 phil #include <net/ethernet.h> /* XXX ETHER_HDR_LEN */
52 1.23.2.2 phil #endif
53 1.23.2.3 phil #if __NetBSD__
54 1.23.2.3 phil #include <net/if_ether.h>
55 1.23.2.2 phil #include <net/route.h>
56 1.23.2.2 phil #endif
57 1.1 dyoung
58 1.1 dyoung #include <net80211/ieee80211_var.h>
59 1.1 dyoung
60 1.23.2.2 phil #ifdef __NetBSD__
61 1.23.2.2 phil #undef KASSERT
62 1.23.2.2 phil #define KASSERT(__cond, __complaint) FBSDKASSERT(__cond, __complaint)
63 1.23.2.2 phil #endif
64 1.23.2.2 phil
65 1.23.2.1 phil MALLOC_DEFINE(M_80211_CRYPTO, "80211crypto", "802.11 crypto state");
66 1.23.2.1 phil
67 1.23.2.1 phil static int _ieee80211_crypto_delkey(struct ieee80211vap *,
68 1.23.2.1 phil struct ieee80211_key *);
69 1.23.2.1 phil
70 1.7 dyoung /*
71 1.7 dyoung * Table of registered cipher modules.
72 1.7 dyoung */
73 1.23.2.1 phil static const struct ieee80211_cipher *ciphers[IEEE80211_CIPHER_MAX];
74 1.7 dyoung
75 1.7 dyoung /*
76 1.7 dyoung * Default "null" key management routines.
77 1.7 dyoung */
78 1.7 dyoung static int
79 1.23.2.1 phil null_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k,
80 1.23.2.1 phil ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
81 1.7 dyoung {
82 1.23.2.1 phil if (!(&vap->iv_nw_keys[0] <= k &&
83 1.23.2.1 phil k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
84 1.9 dyoung /*
85 1.9 dyoung * Not in the global key table, the driver should handle this
86 1.9 dyoung * by allocating a slot in the h/w key table/cache. In
87 1.9 dyoung * lieu of that return key slot 0 for any unicast key
88 1.9 dyoung * request. We disallow the request if this is a group key.
89 1.9 dyoung * This default policy does the right thing for legacy hardware
90 1.9 dyoung * with a 4 key table. It also handles devices that pass
91 1.9 dyoung * packets through untouched when marked with the WEP bit
92 1.9 dyoung * and key index 0.
93 1.9 dyoung */
94 1.10 skrll if (k->wk_flags & IEEE80211_KEY_GROUP)
95 1.10 skrll return 0;
96 1.10 skrll *keyix = 0; /* NB: use key index 0 for ucast key */
97 1.10 skrll } else {
98 1.23.2.1 phil *keyix = ieee80211_crypto_get_key_wepidx(vap, k);
99 1.9 dyoung }
100 1.10 skrll *rxkeyix = IEEE80211_KEYIX_NONE; /* XXX maybe *keyix? */
101 1.10 skrll return 1;
102 1.7 dyoung }
103 1.7 dyoung static int
104 1.23.2.1 phil null_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
105 1.7 dyoung {
106 1.7 dyoung return 1;
107 1.7 dyoung }
108 1.23.2.1 phil static int
109 1.23.2.1 phil null_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
110 1.7 dyoung {
111 1.7 dyoung return 1;
112 1.7 dyoung }
113 1.23.2.1 phil static void null_key_update(struct ieee80211vap *vap) {}
114 1.7 dyoung
115 1.7 dyoung /*
116 1.7 dyoung * Write-arounds for common operations.
117 1.7 dyoung */
118 1.7 dyoung static __inline void
119 1.7 dyoung cipher_detach(struct ieee80211_key *key)
120 1.7 dyoung {
121 1.7 dyoung key->wk_cipher->ic_detach(key);
122 1.7 dyoung }
123 1.7 dyoung
124 1.23.2.1 phil static __inline void *
125 1.23.2.1 phil cipher_attach(struct ieee80211vap *vap, struct ieee80211_key *key)
126 1.23.2.1 phil {
127 1.23.2.1 phil return key->wk_cipher->ic_attach(vap, key);
128 1.23.2.1 phil }
129 1.23.2.1 phil
130 1.23.2.1 phil /*
131 1.7 dyoung * Wrappers for driver key management methods.
132 1.7 dyoung */
133 1.7 dyoung static __inline int
134 1.23.2.1 phil dev_key_alloc(struct ieee80211vap *vap,
135 1.23.2.1 phil struct ieee80211_key *key,
136 1.23.2.1 phil ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
137 1.7 dyoung {
138 1.23.2.1 phil return vap->iv_key_alloc(vap, key, keyix, rxkeyix);
139 1.7 dyoung }
140 1.7 dyoung
141 1.7 dyoung static __inline int
142 1.23.2.1 phil dev_key_delete(struct ieee80211vap *vap,
143 1.23.2.1 phil const struct ieee80211_key *key)
144 1.7 dyoung {
145 1.23.2.1 phil return vap->iv_key_delete(vap, key);
146 1.7 dyoung }
147 1.1 dyoung
148 1.7 dyoung static __inline int
149 1.23.2.1 phil dev_key_set(struct ieee80211vap *vap, const struct ieee80211_key *key)
150 1.7 dyoung {
151 1.23.2.1 phil return vap->iv_key_set(vap, key);
152 1.7 dyoung }
153 1.1 dyoung
154 1.7 dyoung /*
155 1.23.2.1 phil * Setup crypto support for a device/shared instance.
156 1.7 dyoung */
157 1.1 dyoung void
158 1.7 dyoung ieee80211_crypto_attach(struct ieee80211com *ic)
159 1.1 dyoung {
160 1.23.2.1 phil /* NB: we assume everything is pre-zero'd */
161 1.23.2.1 phil ciphers[IEEE80211_CIPHER_NONE] = &ieee80211_cipher_none;
162 1.23.2.1 phil }
163 1.23.2.1 phil
164 1.23.2.1 phil /*
165 1.23.2.1 phil * Teardown crypto support.
166 1.23.2.1 phil */
167 1.23.2.1 phil void
168 1.23.2.1 phil ieee80211_crypto_detach(struct ieee80211com *ic)
169 1.23.2.1 phil {
170 1.23.2.1 phil }
171 1.23.2.1 phil
172 1.23.2.1 phil /*
173 1.23.2.1 phil * Setup crypto support for a vap.
174 1.23.2.1 phil */
175 1.23.2.1 phil void
176 1.23.2.1 phil ieee80211_crypto_vattach(struct ieee80211vap *vap)
177 1.23.2.1 phil {
178 1.7 dyoung int i;
179 1.1 dyoung
180 1.7 dyoung /* NB: we assume everything is pre-zero'd */
181 1.23.2.1 phil vap->iv_max_keyix = IEEE80211_WEP_NKID;
182 1.23.2.1 phil vap->iv_def_txkey = IEEE80211_KEYIX_NONE;
183 1.7 dyoung for (i = 0; i < IEEE80211_WEP_NKID; i++)
184 1.23.2.1 phil ieee80211_crypto_resetkey(vap, &vap->iv_nw_keys[i],
185 1.7 dyoung IEEE80211_KEYIX_NONE);
186 1.1 dyoung /*
187 1.7 dyoung * Initialize the driver key support routines to noop entries.
188 1.7 dyoung * This is useful especially for the cipher test modules.
189 1.1 dyoung */
190 1.23.2.1 phil vap->iv_key_alloc = null_key_alloc;
191 1.23.2.1 phil vap->iv_key_set = null_key_set;
192 1.23.2.1 phil vap->iv_key_delete = null_key_delete;
193 1.23.2.1 phil vap->iv_key_update_begin = null_key_update;
194 1.23.2.1 phil vap->iv_key_update_end = null_key_update;
195 1.1 dyoung }
196 1.1 dyoung
197 1.7 dyoung /*
198 1.23.2.1 phil * Teardown crypto support for a vap.
199 1.7 dyoung */
200 1.1 dyoung void
201 1.23.2.1 phil ieee80211_crypto_vdetach(struct ieee80211vap *vap)
202 1.1 dyoung {
203 1.23.2.1 phil ieee80211_crypto_delglobalkeys(vap);
204 1.7 dyoung }
205 1.1 dyoung
206 1.7 dyoung /*
207 1.7 dyoung * Register a crypto cipher module.
208 1.7 dyoung */
209 1.7 dyoung void
210 1.7 dyoung ieee80211_crypto_register(const struct ieee80211_cipher *cip)
211 1.7 dyoung {
212 1.7 dyoung if (cip->ic_cipher >= IEEE80211_CIPHER_MAX) {
213 1.7 dyoung printf("%s: cipher %s has an invalid cipher index %u\n",
214 1.7 dyoung __func__, cip->ic_name, cip->ic_cipher);
215 1.7 dyoung return;
216 1.7 dyoung }
217 1.7 dyoung if (ciphers[cip->ic_cipher] != NULL && ciphers[cip->ic_cipher] != cip) {
218 1.7 dyoung printf("%s: cipher %s registered with a different template\n",
219 1.7 dyoung __func__, cip->ic_name);
220 1.7 dyoung return;
221 1.1 dyoung }
222 1.7 dyoung ciphers[cip->ic_cipher] = cip;
223 1.1 dyoung }
224 1.1 dyoung
225 1.7 dyoung /*
226 1.7 dyoung * Unregister a crypto cipher module.
227 1.7 dyoung */
228 1.7 dyoung void
229 1.7 dyoung ieee80211_crypto_unregister(const struct ieee80211_cipher *cip)
230 1.1 dyoung {
231 1.7 dyoung if (cip->ic_cipher >= IEEE80211_CIPHER_MAX) {
232 1.7 dyoung printf("%s: cipher %s has an invalid cipher index %u\n",
233 1.7 dyoung __func__, cip->ic_name, cip->ic_cipher);
234 1.7 dyoung return;
235 1.1 dyoung }
236 1.7 dyoung if (ciphers[cip->ic_cipher] != NULL && ciphers[cip->ic_cipher] != cip) {
237 1.7 dyoung printf("%s: cipher %s registered with a different template\n",
238 1.7 dyoung __func__, cip->ic_name);
239 1.7 dyoung return;
240 1.5 dyoung }
241 1.7 dyoung /* NB: don't complain about not being registered */
242 1.7 dyoung /* XXX disallow if references */
243 1.7 dyoung ciphers[cip->ic_cipher] = NULL;
244 1.7 dyoung }
245 1.7 dyoung
246 1.7 dyoung int
247 1.7 dyoung ieee80211_crypto_available(u_int cipher)
248 1.7 dyoung {
249 1.7 dyoung return cipher < IEEE80211_CIPHER_MAX && ciphers[cipher] != NULL;
250 1.7 dyoung }
251 1.7 dyoung
252 1.23.2.3 phil #if __FreeBSD__
253 1.7 dyoung /* XXX well-known names! */
254 1.23.2.1 phil static const char *cipher_modnames[IEEE80211_CIPHER_MAX] = {
255 1.23.2.1 phil [IEEE80211_CIPHER_WEP] = "wlan_wep",
256 1.23.2.1 phil [IEEE80211_CIPHER_TKIP] = "wlan_tkip",
257 1.23.2.1 phil [IEEE80211_CIPHER_AES_OCB] = "wlan_aes_ocb",
258 1.23.2.1 phil [IEEE80211_CIPHER_AES_CCM] = "wlan_ccmp",
259 1.23.2.1 phil [IEEE80211_CIPHER_TKIPMIC] = "#4", /* NB: reserved */
260 1.23.2.1 phil [IEEE80211_CIPHER_CKIP] = "wlan_ckip",
261 1.23.2.1 phil [IEEE80211_CIPHER_NONE] = "wlan_none",
262 1.7 dyoung };
263 1.23.2.2 phil #endif
264 1.7 dyoung
265 1.23.2.1 phil /* NB: there must be no overlap between user-supplied and device-owned flags */
266 1.23.2.1 phil CTASSERT((IEEE80211_KEY_COMMON & IEEE80211_KEY_DEVICE) == 0);
267 1.23.2.1 phil
268 1.7 dyoung /*
269 1.7 dyoung * Establish a relationship between the specified key and cipher
270 1.7 dyoung * and, if necessary, allocate a hardware index from the driver.
271 1.23.2.1 phil * Note that when a fixed key index is required it must be specified.
272 1.7 dyoung *
273 1.7 dyoung * This must be the first call applied to a key; all the other key
274 1.7 dyoung * routines assume wk_cipher is setup.
275 1.7 dyoung *
276 1.7 dyoung * Locking must be handled by the caller using:
277 1.23.2.1 phil * ieee80211_key_update_begin(vap);
278 1.23.2.1 phil * ieee80211_key_update_end(vap);
279 1.7 dyoung */
280 1.7 dyoung int
281 1.23.2.1 phil ieee80211_crypto_newkey(struct ieee80211vap *vap,
282 1.23.2.1 phil int cipher, int flags, struct ieee80211_key *key)
283 1.7 dyoung {
284 1.23.2.1 phil struct ieee80211com *ic = vap->iv_ic;
285 1.7 dyoung const struct ieee80211_cipher *cip;
286 1.10 skrll ieee80211_keyix keyix, rxkeyix;
287 1.7 dyoung void *keyctx;
288 1.7 dyoung int oflags;
289 1.7 dyoung
290 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
291 1.23.2.1 phil "%s: cipher %u flags 0x%x keyix %u\n",
292 1.23.2.1 phil __func__, cipher, flags, key->wk_keyix);
293 1.23.2.1 phil
294 1.7 dyoung /*
295 1.7 dyoung * Validate cipher and set reference to cipher routines.
296 1.7 dyoung */
297 1.7 dyoung if (cipher >= IEEE80211_CIPHER_MAX) {
298 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
299 1.23.2.1 phil "%s: invalid cipher %u\n", __func__, cipher);
300 1.23.2.1 phil vap->iv_stats.is_crypto_badcipher++;
301 1.7 dyoung return 0;
302 1.1 dyoung }
303 1.7 dyoung cip = ciphers[cipher];
304 1.7 dyoung if (cip == NULL) {
305 1.23.2.2 phil #if __FreeBSD__
306 1.1 dyoung /*
307 1.7 dyoung * Auto-load cipher module if we have a well-known name
308 1.7 dyoung * for it. It might be better to use string names rather
309 1.7 dyoung * than numbers and craft a module name based on the cipher
310 1.7 dyoung * name; e.g. wlan_cipher_<cipher-name>.
311 1.1 dyoung */
312 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
313 1.23.2.1 phil "%s: unregistered cipher %u, load module %s\n",
314 1.23.2.1 phil __func__, cipher, cipher_modnames[cipher]);
315 1.23.2.1 phil ieee80211_load_module(cipher_modnames[cipher]);
316 1.23.2.1 phil /*
317 1.23.2.1 phil * If cipher module loaded it should immediately
318 1.23.2.1 phil * call ieee80211_crypto_register which will fill
319 1.23.2.1 phil * in the entry in the ciphers array.
320 1.23.2.1 phil */
321 1.23.2.1 phil cip = ciphers[cipher];
322 1.7 dyoung if (cip == NULL) {
323 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
324 1.23.2.1 phil "%s: unable to load cipher %u, module %s\n",
325 1.23.2.1 phil __func__, cipher, cipher_modnames[cipher]);
326 1.23.2.1 phil vap->iv_stats.is_crypto_nocipher++;
327 1.7 dyoung return 0;
328 1.1 dyoung }
329 1.23.2.2 phil #else
330 1.23.2.2 phil panic("wlan_cipher not usable."); /* NNN NetBSD modules? */
331 1.23.2.2 phil #endif
332 1.7 dyoung }
333 1.7 dyoung
334 1.7 dyoung oflags = key->wk_flags;
335 1.7 dyoung flags &= IEEE80211_KEY_COMMON;
336 1.23.2.1 phil /* NB: preserve device attributes */
337 1.23.2.1 phil flags |= (oflags & IEEE80211_KEY_DEVICE);
338 1.7 dyoung /*
339 1.7 dyoung * If the hardware does not support the cipher then
340 1.23.2.1 phil * fallback to a host-based implementation.
341 1.7 dyoung */
342 1.23.2.1 phil if ((ic->ic_cryptocaps & (1<<cipher)) == 0) {
343 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
344 1.7 dyoung "%s: no h/w support for cipher %s, falling back to s/w\n",
345 1.7 dyoung __func__, cip->ic_name);
346 1.7 dyoung flags |= IEEE80211_KEY_SWCRYPT;
347 1.7 dyoung }
348 1.7 dyoung /*
349 1.7 dyoung * Hardware TKIP with software MIC is an important
350 1.7 dyoung * combination; we handle it by flagging each key,
351 1.7 dyoung * the cipher modules honor it.
352 1.7 dyoung */
353 1.7 dyoung if (cipher == IEEE80211_CIPHER_TKIP &&
354 1.23.2.1 phil (ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIPMIC) == 0) {
355 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
356 1.7 dyoung "%s: no h/w support for TKIP MIC, falling back to s/w\n",
357 1.7 dyoung __func__);
358 1.7 dyoung flags |= IEEE80211_KEY_SWMIC;
359 1.7 dyoung }
360 1.7 dyoung
361 1.7 dyoung /*
362 1.7 dyoung * Bind cipher to key instance. Note we do this
363 1.7 dyoung * after checking the device capabilities so the
364 1.7 dyoung * cipher module can optimize space usage based on
365 1.7 dyoung * whether or not it needs to do the cipher work.
366 1.7 dyoung */
367 1.7 dyoung if (key->wk_cipher != cip || key->wk_flags != flags) {
368 1.7 dyoung /*
369 1.7 dyoung * Fillin the flags so cipher modules can see s/w
370 1.7 dyoung * crypto requirements and potentially allocate
371 1.7 dyoung * different state and/or attach different method
372 1.7 dyoung * pointers.
373 1.7 dyoung */
374 1.7 dyoung key->wk_flags = flags;
375 1.23.2.1 phil keyctx = cip->ic_attach(vap, key);
376 1.7 dyoung if (keyctx == NULL) {
377 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
378 1.7 dyoung "%s: unable to attach cipher %s\n",
379 1.7 dyoung __func__, cip->ic_name);
380 1.7 dyoung key->wk_flags = oflags; /* restore old flags */
381 1.23.2.1 phil vap->iv_stats.is_crypto_attachfail++;
382 1.7 dyoung return 0;
383 1.1 dyoung }
384 1.7 dyoung cipher_detach(key);
385 1.7 dyoung key->wk_cipher = cip; /* XXX refcnt? */
386 1.7 dyoung key->wk_private = keyctx;
387 1.7 dyoung }
388 1.7 dyoung
389 1.7 dyoung /*
390 1.7 dyoung * Ask the driver for a key index if we don't have one.
391 1.7 dyoung * Note that entries in the global key table always have
392 1.7 dyoung * an index; this means it's safe to call this routine
393 1.7 dyoung * for these entries just to setup the reference to the
394 1.7 dyoung * cipher template. Note also that when using software
395 1.7 dyoung * crypto we also call the driver to give us a key index.
396 1.7 dyoung */
397 1.23.2.1 phil if ((key->wk_flags & IEEE80211_KEY_DEVKEY) == 0) {
398 1.23.2.1 phil if (!dev_key_alloc(vap, key, &keyix, &rxkeyix)) {
399 1.7 dyoung /*
400 1.23.2.1 phil * Unable to setup driver state.
401 1.7 dyoung */
402 1.23.2.1 phil vap->iv_stats.is_crypto_keyfail++;
403 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
404 1.7 dyoung "%s: unable to setup cipher %s\n",
405 1.7 dyoung __func__, cip->ic_name);
406 1.7 dyoung return 0;
407 1.1 dyoung }
408 1.23.2.1 phil if (key->wk_flags != flags) {
409 1.23.2.1 phil /*
410 1.23.2.1 phil * Driver overrode flags we setup; typically because
411 1.23.2.1 phil * resources were unavailable to handle _this_ key.
412 1.23.2.1 phil * Re-attach the cipher context to allow cipher
413 1.23.2.1 phil * modules to handle differing requirements.
414 1.23.2.1 phil */
415 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
416 1.23.2.1 phil "%s: driver override for cipher %s, flags "
417 1.23.2.1 phil "0x%x -> 0x%x\n", __func__, cip->ic_name,
418 1.23.2.1 phil oflags, key->wk_flags);
419 1.23.2.1 phil keyctx = cip->ic_attach(vap, key);
420 1.23.2.1 phil if (keyctx == NULL) {
421 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
422 1.23.2.1 phil "%s: unable to attach cipher %s with "
423 1.23.2.1 phil "flags 0x%x\n", __func__, cip->ic_name,
424 1.23.2.1 phil key->wk_flags);
425 1.23.2.1 phil key->wk_flags = oflags; /* restore old flags */
426 1.23.2.1 phil vap->iv_stats.is_crypto_attachfail++;
427 1.23.2.1 phil return 0;
428 1.23.2.1 phil }
429 1.23.2.1 phil cipher_detach(key);
430 1.23.2.1 phil key->wk_cipher = cip; /* XXX refcnt? */
431 1.23.2.1 phil key->wk_private = keyctx;
432 1.23.2.1 phil }
433 1.10 skrll key->wk_keyix = keyix;
434 1.10 skrll key->wk_rxkeyix = rxkeyix;
435 1.23.2.1 phil key->wk_flags |= IEEE80211_KEY_DEVKEY;
436 1.7 dyoung }
437 1.7 dyoung return 1;
438 1.7 dyoung }
439 1.7 dyoung
440 1.7 dyoung /*
441 1.7 dyoung * Remove the key (no locking, for internal use).
442 1.7 dyoung */
443 1.7 dyoung static int
444 1.23.2.1 phil _ieee80211_crypto_delkey(struct ieee80211vap *vap, struct ieee80211_key *key)
445 1.7 dyoung {
446 1.23.2.1 phil KASSERT(key->wk_cipher != NULL, ("No cipher!"));
447 1.7 dyoung
448 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
449 1.7 dyoung "%s: %s keyix %u flags 0x%x rsc %ju tsc %ju len %u\n",
450 1.7 dyoung __func__, key->wk_cipher->ic_name,
451 1.7 dyoung key->wk_keyix, key->wk_flags,
452 1.23.2.1 phil key->wk_keyrsc[IEEE80211_NONQOS_TID], key->wk_keytsc,
453 1.23.2.1 phil key->wk_keylen);
454 1.7 dyoung
455 1.23.2.1 phil if (key->wk_flags & IEEE80211_KEY_DEVKEY) {
456 1.7 dyoung /*
457 1.7 dyoung * Remove hardware entry.
458 1.7 dyoung */
459 1.7 dyoung /* XXX key cache */
460 1.23.2.1 phil if (!dev_key_delete(vap, key)) {
461 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
462 1.7 dyoung "%s: driver did not delete key index %u\n",
463 1.23.2.1 phil __func__, key->wk_keyix);
464 1.23.2.1 phil vap->iv_stats.is_crypto_delkey++;
465 1.7 dyoung /* XXX recovery? */
466 1.1 dyoung }
467 1.1 dyoung }
468 1.7 dyoung cipher_detach(key);
469 1.7 dyoung memset(key, 0, sizeof(*key));
470 1.23.2.1 phil ieee80211_crypto_resetkey(vap, key, IEEE80211_KEYIX_NONE);
471 1.7 dyoung return 1;
472 1.7 dyoung }
473 1.7 dyoung
474 1.7 dyoung /*
475 1.7 dyoung * Remove the specified key.
476 1.7 dyoung */
477 1.7 dyoung int
478 1.23.2.1 phil ieee80211_crypto_delkey(struct ieee80211vap *vap, struct ieee80211_key *key)
479 1.7 dyoung {
480 1.7 dyoung int status;
481 1.1 dyoung
482 1.23.2.1 phil ieee80211_key_update_begin(vap);
483 1.23.2.1 phil status = _ieee80211_crypto_delkey(vap, key);
484 1.23.2.1 phil ieee80211_key_update_end(vap);
485 1.7 dyoung return status;
486 1.1 dyoung }
487 1.1 dyoung
488 1.1 dyoung /*
489 1.7 dyoung * Clear the global key table.
490 1.1 dyoung */
491 1.7 dyoung void
492 1.23.2.1 phil ieee80211_crypto_delglobalkeys(struct ieee80211vap *vap)
493 1.7 dyoung {
494 1.7 dyoung int i;
495 1.7 dyoung
496 1.23.2.1 phil ieee80211_key_update_begin(vap);
497 1.7 dyoung for (i = 0; i < IEEE80211_WEP_NKID; i++)
498 1.23.2.1 phil (void) _ieee80211_crypto_delkey(vap, &vap->iv_nw_keys[i]);
499 1.23.2.1 phil ieee80211_key_update_end(vap);
500 1.7 dyoung }
501 1.7 dyoung
502 1.7 dyoung /*
503 1.7 dyoung * Set the contents of the specified key.
504 1.7 dyoung *
505 1.7 dyoung * Locking must be handled by the caller using:
506 1.23.2.1 phil * ieee80211_key_update_begin(vap);
507 1.23.2.1 phil * ieee80211_key_update_end(vap);
508 1.7 dyoung */
509 1.7 dyoung int
510 1.23.2.1 phil ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key)
511 1.7 dyoung {
512 1.7 dyoung const struct ieee80211_cipher *cip = key->wk_cipher;
513 1.7 dyoung
514 1.23.2.1 phil KASSERT(cip != NULL, ("No cipher!"));
515 1.7 dyoung
516 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
517 1.7 dyoung "%s: %s keyix %u flags 0x%x mac %s rsc %ju tsc %ju len %u\n",
518 1.7 dyoung __func__, cip->ic_name, key->wk_keyix,
519 1.23.2.1 phil key->wk_flags, ether_sprintf(key->wk_macaddr),
520 1.23.2.1 phil key->wk_keyrsc[IEEE80211_NONQOS_TID], key->wk_keytsc,
521 1.23.2.1 phil key->wk_keylen);
522 1.7 dyoung
523 1.23.2.1 phil if ((key->wk_flags & IEEE80211_KEY_DEVKEY) == 0) {
524 1.23.2.1 phil /* XXX nothing allocated, should not happen */
525 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
526 1.23.2.1 phil "%s: no device key setup done; should not happen!\n",
527 1.23.2.1 phil __func__);
528 1.23.2.1 phil vap->iv_stats.is_crypto_setkey_nokey++;
529 1.23.2.1 phil return 0;
530 1.23.2.1 phil }
531 1.7 dyoung /*
532 1.7 dyoung * Give cipher a chance to validate key contents.
533 1.7 dyoung * XXX should happen before modifying state.
534 1.7 dyoung */
535 1.7 dyoung if (!cip->ic_setkey(key)) {
536 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
537 1.7 dyoung "%s: cipher %s rejected key index %u len %u flags 0x%x\n",
538 1.7 dyoung __func__, cip->ic_name, key->wk_keyix,
539 1.7 dyoung key->wk_keylen, key->wk_flags);
540 1.23.2.1 phil vap->iv_stats.is_crypto_setkey_cipher++;
541 1.7 dyoung return 0;
542 1.7 dyoung }
543 1.23.2.1 phil return dev_key_set(vap, key);
544 1.7 dyoung }
545 1.1 dyoung
546 1.7 dyoung /*
547 1.23.2.1 phil * Return index if the key is a WEP key (0..3); -1 otherwise.
548 1.22 maxv *
549 1.23.2.1 phil * This is different to "get_keyid" which defaults to returning
550 1.23.2.1 phil * 0 for unicast keys; it assumes that it won't be used for WEP.
551 1.7 dyoung */
552 1.23.2.1 phil int
553 1.23.2.1 phil ieee80211_crypto_get_key_wepidx(const struct ieee80211vap *vap,
554 1.23.2.1 phil const struct ieee80211_key *k)
555 1.23.2.1 phil {
556 1.23.2.1 phil
557 1.23.2.1 phil if (k >= &vap->iv_nw_keys[0] &&
558 1.23.2.1 phil k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])
559 1.23.2.1 phil return (k - vap->iv_nw_keys);
560 1.23.2.1 phil return (-1);
561 1.23.2.1 phil }
562 1.23.2.1 phil
563 1.23.2.1 phil /*
564 1.23.2.1 phil * Note: only supports a single unicast key (0).
565 1.23.2.1 phil */
566 1.23.2.1 phil uint8_t
567 1.23.2.1 phil ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k)
568 1.23.2.1 phil {
569 1.23.2.1 phil if (k >= &vap->iv_nw_keys[0] &&
570 1.23.2.1 phil k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])
571 1.23.2.1 phil return (k - vap->iv_nw_keys);
572 1.23.2.1 phil else
573 1.23.2.1 phil return (0);
574 1.23.2.1 phil }
575 1.23.2.1 phil
576 1.7 dyoung struct ieee80211_key *
577 1.23.2.1 phil ieee80211_crypto_get_txkey(struct ieee80211_node *ni, struct mbuf *m)
578 1.7 dyoung {
579 1.23.2.1 phil struct ieee80211vap *vap = ni->ni_vap;
580 1.7 dyoung struct ieee80211_frame *wh;
581 1.1 dyoung
582 1.7 dyoung /*
583 1.7 dyoung * Multicast traffic always uses the multicast key.
584 1.7 dyoung * Otherwise if a unicast key is set we use that and
585 1.7 dyoung * it is always key index 0. When no unicast key is
586 1.7 dyoung * set we fall back to the default transmit key.
587 1.7 dyoung */
588 1.7 dyoung wh = mtod(m, struct ieee80211_frame *);
589 1.7 dyoung if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
590 1.23.2.1 phil IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) {
591 1.23.2.1 phil if (vap->iv_def_txkey == IEEE80211_KEYIX_NONE) {
592 1.23.2.1 phil IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO,
593 1.23.2.1 phil wh->i_addr1,
594 1.23.2.1 phil "no default transmit key (%s) deftxkey %u",
595 1.23.2.1 phil __func__, vap->iv_def_txkey);
596 1.23.2.1 phil vap->iv_stats.is_tx_nodefkey++;
597 1.10 skrll return NULL;
598 1.1 dyoung }
599 1.23.2.1 phil return &vap->iv_nw_keys[vap->iv_def_txkey];
600 1.1 dyoung }
601 1.20 maxv
602 1.23.2.1 phil return &ni->ni_ucastkey;
603 1.23.2.1 phil }
604 1.23.2.1 phil
605 1.23.2.1 phil /*
606 1.23.2.1 phil * Add privacy headers appropriate for the specified key.
607 1.23.2.1 phil */
608 1.23.2.1 phil struct ieee80211_key *
609 1.23.2.1 phil ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
610 1.23.2.1 phil {
611 1.23.2.1 phil struct ieee80211_key *k;
612 1.23.2.1 phil const struct ieee80211_cipher *cip;
613 1.23.2.1 phil
614 1.23.2.1 phil if ((k = ieee80211_crypto_get_txkey(ni, m)) != NULL) {
615 1.23.2.1 phil cip = k->wk_cipher;
616 1.23.2.1 phil return (cip->ic_encap(k, m) ? k : NULL);
617 1.20 maxv }
618 1.20 maxv
619 1.23.2.1 phil return NULL;
620 1.1 dyoung }
621 1.1 dyoung
622 1.1 dyoung /*
623 1.7 dyoung * Validate and strip privacy headers (and trailer) for a
624 1.7 dyoung * received frame that has the WEP/Privacy bit set.
625 1.1 dyoung */
626 1.23.2.1 phil int
627 1.23.2.1 phil ieee80211_crypto_decap(struct ieee80211_node *ni, struct mbuf *m, int hdrlen,
628 1.23.2.1 phil struct ieee80211_key **key)
629 1.7 dyoung {
630 1.23.2.1 phil #define IEEE80211_WEP_HDRLEN (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
631 1.23.2.1 phil #define IEEE80211_WEP_MINLEN \
632 1.23.2.1 phil (sizeof(struct ieee80211_frame) + \
633 1.23.2.1 phil IEEE80211_WEP_HDRLEN + IEEE80211_WEP_CRCLEN)
634 1.23.2.1 phil struct ieee80211vap *vap = ni->ni_vap;
635 1.7 dyoung struct ieee80211_key *k;
636 1.7 dyoung struct ieee80211_frame *wh;
637 1.23.2.1 phil const struct ieee80211_rx_stats *rxs;
638 1.23.2.1 phil const struct ieee80211_cipher *cip;
639 1.23.2.1 phil uint8_t keyid;
640 1.21 maxv
641 1.21 maxv /*
642 1.23.2.1 phil * Check for hardware decryption and IV stripping.
643 1.23.2.1 phil * If the IV is stripped then we definitely can't find a key.
644 1.23.2.1 phil * Set the key to NULL but return true; upper layers
645 1.23.2.1 phil * will need to handle a NULL key for a successful
646 1.23.2.1 phil * decrypt.
647 1.23.2.1 phil */
648 1.23.2.1 phil rxs = ieee80211_get_rx_params_ptr(m);
649 1.23.2.1 phil if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) {
650 1.23.2.1 phil if (rxs->c_pktflags & IEEE80211_RX_F_IV_STRIP) {
651 1.23.2.1 phil /*
652 1.23.2.1 phil * Hardware decrypted, IV stripped.
653 1.23.2.1 phil * We can't find a key with a stripped IV.
654 1.23.2.1 phil * Return successful.
655 1.23.2.1 phil */
656 1.23.2.1 phil *key = NULL;
657 1.23.2.1 phil return (1);
658 1.23.2.1 phil }
659 1.23.2.1 phil }
660 1.23.2.1 phil
661 1.23.2.1 phil /* NB: this minimum size data frame could be bigger */
662 1.7 dyoung if (m->m_pkthdr.len < IEEE80211_WEP_MINLEN) {
663 1.23.2.1 phil IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY,
664 1.7 dyoung "%s: WEP data frame too short, len %u\n",
665 1.7 dyoung __func__, m->m_pkthdr.len);
666 1.23.2.1 phil vap->iv_stats.is_rx_tooshort++; /* XXX need unique stat? */
667 1.23.2.1 phil *key = NULL;
668 1.23.2.1 phil return (0);
669 1.7 dyoung }
670 1.7 dyoung
671 1.7 dyoung /*
672 1.7 dyoung * Locate the key. If unicast and there is no unicast
673 1.7 dyoung * key then we fall back to the key id in the header.
674 1.7 dyoung * This assumes unicast keys are only configured when
675 1.7 dyoung * the key id in the header is meaningless (typically 0).
676 1.7 dyoung */
677 1.7 dyoung wh = mtod(m, struct ieee80211_frame *);
678 1.11 dyoung m_copydata(m, hdrlen + IEEE80211_WEP_IVLEN, sizeof(keyid), &keyid);
679 1.7 dyoung if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
680 1.23.2.1 phil IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey))
681 1.23.2.1 phil k = &vap->iv_nw_keys[keyid >> 6];
682 1.23.2.1 phil else
683 1.7 dyoung k = &ni->ni_ucastkey;
684 1.1 dyoung
685 1.7 dyoung /*
686 1.7 dyoung * Insure crypto header is contiguous for all decap work.
687 1.7 dyoung */
688 1.7 dyoung cip = k->wk_cipher;
689 1.23.2.1 phil if (m->m_len < hdrlen + cip->ic_header &&
690 1.23.2.1 phil (m = m_pullup(m, hdrlen + cip->ic_header)) == NULL) {
691 1.23.2.1 phil IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
692 1.23.2.1 phil "unable to pullup %s header", cip->ic_name);
693 1.23.2.1 phil vap->iv_stats.is_rx_wepfail++; /* XXX */
694 1.23.2.1 phil *key = NULL;
695 1.23.2.1 phil return (0);
696 1.19 maxv }
697 1.19 maxv
698 1.23.2.1 phil /*
699 1.23.2.1 phil * Attempt decryption.
700 1.23.2.1 phil *
701 1.23.2.1 phil * If we fail then don't return the key - return NULL
702 1.23.2.1 phil * and an error.
703 1.23.2.1 phil */
704 1.23.2.1 phil if (cip->ic_decap(k, m, hdrlen)) {
705 1.23.2.1 phil /* success */
706 1.23.2.1 phil *key = k;
707 1.23.2.1 phil return (1);
708 1.7 dyoung }
709 1.1 dyoung
710 1.23.2.1 phil /* Failure */
711 1.23.2.1 phil *key = NULL;
712 1.23.2.1 phil return (0);
713 1.23.2.1 phil #undef IEEE80211_WEP_MINLEN
714 1.23.2.1 phil #undef IEEE80211_WEP_HDRLEN
715 1.23.2.1 phil }
716 1.23.2.1 phil
717 1.23.2.1 phil /*
718 1.23.2.1 phil * Check and remove any MIC.
719 1.23.2.1 phil */
720 1.23.2.1 phil int
721 1.23.2.1 phil ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
722 1.23.2.1 phil struct mbuf *m, int force)
723 1.23.2.1 phil {
724 1.23.2.1 phil const struct ieee80211_cipher *cip;
725 1.23.2.1 phil const struct ieee80211_rx_stats *rxs;
726 1.23.2.1 phil struct ieee80211_frame *wh;
727 1.23.2.1 phil
728 1.23.2.1 phil rxs = ieee80211_get_rx_params_ptr(m);
729 1.23.2.1 phil wh = mtod(m, struct ieee80211_frame *);
730 1.23.2.1 phil
731 1.21 maxv /*
732 1.23.2.1 phil * Handle demic / mic errors from hardware-decrypted offload devices.
733 1.21 maxv */
734 1.23.2.1 phil if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) {
735 1.23.2.1 phil if (rxs->c_pktflags & IEEE80211_RX_F_FAIL_MIC) {
736 1.23.2.1 phil /*
737 1.23.2.1 phil * Hardware has said MIC failed. We don't care about
738 1.23.2.1 phil * whether it was stripped or not.
739 1.23.2.1 phil *
740 1.23.2.1 phil * Eventually - teach the demic methods in crypto
741 1.23.2.1 phil * modules to handle a NULL key and not to dereference
742 1.23.2.1 phil * it.
743 1.23.2.1 phil */
744 1.23.2.1 phil ieee80211_notify_michael_failure(vap, wh, -1);
745 1.23.2.1 phil return (0);
746 1.23.2.1 phil }
747 1.23.2.1 phil
748 1.23.2.1 phil if (rxs->c_pktflags & IEEE80211_RX_F_MMIC_STRIP) {
749 1.23.2.1 phil /*
750 1.23.2.1 phil * Hardware has decrypted and not indicated a
751 1.23.2.1 phil * MIC failure and has stripped the MIC.
752 1.23.2.1 phil * We may not have a key, so for now just
753 1.23.2.1 phil * return OK.
754 1.23.2.1 phil */
755 1.23.2.1 phil return (1);
756 1.23.2.1 phil }
757 1.23.2.1 phil }
758 1.23.2.1 phil
759 1.23.2.1 phil /*
760 1.23.2.1 phil * If we don't have a key at this point then we don't
761 1.23.2.1 phil * have to demic anything.
762 1.23.2.1 phil */
763 1.23.2.1 phil if (k == NULL)
764 1.23.2.1 phil return (1);
765 1.23.2.1 phil
766 1.23.2.1 phil cip = k->wk_cipher;
767 1.23.2.1 phil return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1);
768 1.23.2.1 phil }
769 1.23.2.1 phil
770 1.23.2.1 phil
771 1.23.2.1 phil static void
772 1.23.2.1 phil load_ucastkey(void *arg, struct ieee80211_node *ni)
773 1.23.2.1 phil {
774 1.23.2.1 phil struct ieee80211vap *vap = ni->ni_vap;
775 1.23.2.1 phil struct ieee80211_key *k;
776 1.23.2.1 phil
777 1.23.2.1 phil if (vap->iv_state != IEEE80211_S_RUN)
778 1.23.2.1 phil return;
779 1.23.2.1 phil k = &ni->ni_ucastkey;
780 1.23.2.1 phil if (k->wk_flags & IEEE80211_KEY_DEVKEY)
781 1.23.2.1 phil dev_key_set(vap, k);
782 1.23.2.1 phil }
783 1.23.2.1 phil
784 1.23.2.1 phil /*
785 1.23.2.1 phil * Re-load all keys known to the 802.11 layer that may
786 1.23.2.1 phil * have hardware state backing them. This is used by
787 1.23.2.1 phil * drivers on resume to push keys down into the device.
788 1.23.2.1 phil */
789 1.23.2.1 phil void
790 1.23.2.1 phil ieee80211_crypto_reload_keys(struct ieee80211com *ic)
791 1.23.2.1 phil {
792 1.23.2.1 phil struct ieee80211vap *vap;
793 1.23.2.1 phil int i;
794 1.23.2.1 phil
795 1.23.2.1 phil /*
796 1.23.2.1 phil * Keys in the global key table of each vap.
797 1.23.2.1 phil */
798 1.23.2.1 phil /* NB: used only during resume so don't lock for now */
799 1.23.2.1 phil TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
800 1.23.2.1 phil if (vap->iv_state != IEEE80211_S_RUN)
801 1.23.2.1 phil continue;
802 1.23.2.1 phil for (i = 0; i < IEEE80211_WEP_NKID; i++) {
803 1.23.2.1 phil const struct ieee80211_key *k = &vap->iv_nw_keys[i];
804 1.23.2.1 phil if (k->wk_flags & IEEE80211_KEY_DEVKEY)
805 1.23.2.1 phil dev_key_set(vap, k);
806 1.23.2.1 phil }
807 1.21 maxv }
808 1.23.2.1 phil /*
809 1.23.2.1 phil * Unicast keys.
810 1.23.2.1 phil */
811 1.23.2.1 phil ieee80211_iterate_nodes(&ic->ic_sta, load_ucastkey, NULL);
812 1.23.2.1 phil }
813 1.23.2.1 phil
814 1.23.2.1 phil /*
815 1.23.2.1 phil * Set the default key index for WEP, or KEYIX_NONE for no default TX key.
816 1.23.2.1 phil *
817 1.23.2.1 phil * This should be done as part of a key update block (iv_key_update_begin /
818 1.23.2.1 phil * iv_key_update_end.)
819 1.23.2.1 phil */
820 1.23.2.1 phil void
821 1.23.2.1 phil ieee80211_crypto_set_deftxkey(struct ieee80211vap *vap, ieee80211_keyix kid)
822 1.23.2.1 phil {
823 1.23.2.1 phil
824 1.23.2.1 phil /* XXX TODO: assert we're in a key update block */
825 1.21 maxv
826 1.23.2.1 phil vap->iv_update_deftxkey(vap, kid);
827 1.1 dyoung }
828