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