Lines Matching +full:mic +full:- +full:int

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
90 "AES-OCB", in ath_keyprint()
91 "AES-CCM", in ath_keyprint()
96 int i, n; in ath_keyprint()
98 printf("%s: [%02u] %-7s ", tag, ix, ciphers[hk->kv_type]); in ath_keyprint()
99 for (i = 0, n = hk->kv_len; i < n; i++) in ath_keyprint()
100 printf("%02x", hk->kv_val[i]); in ath_keyprint()
102 if (hk->kv_type == HAL_CIPHER_TKIP) { in ath_keyprint()
103 printf(" %s ", sc->sc_splitmic ? "mic" : "rxmic"); in ath_keyprint()
104 for (i = 0; i < sizeof(hk->kv_mic); i++) in ath_keyprint()
105 printf("%02x", hk->kv_mic[i]); in ath_keyprint()
106 if (!sc->sc_splitmic) { in ath_keyprint()
108 for (i = 0; i < sizeof(hk->kv_txmic); i++) in ath_keyprint()
109 printf("%02x", hk->kv_txmic[i]); in ath_keyprint()
121 static int
127 struct ath_hal *ah = sc->sc_ah; in ath_keyset_tkip()
129 KASSERT(k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP, in ath_keyset_tkip()
130 ("got a non-TKIP key, cipher %u", k->wk_cipher->ic_cipher)); in ath_keyset_tkip()
131 if ((k->wk_flags & IEEE80211_KEY_XR) == IEEE80211_KEY_XR) { in ath_keyset_tkip()
132 if (sc->sc_splitmic) { in ath_keyset_tkip()
135 * The hal handles the MIC keys at index+64. in ath_keyset_tkip()
137 memcpy(hk->kv_mic, k->wk_txmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
138 KEYPRINTF(sc, k->wk_keyix, hk, zerobssid); in ath_keyset_tkip()
139 if (!ath_hal_keyset(ah, k->wk_keyix, hk, zerobssid)) in ath_keyset_tkip()
142 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
143 KEYPRINTF(sc, k->wk_keyix+32, hk, mac); in ath_keyset_tkip()
145 return ath_hal_keyset(ah, k->wk_keyix+32, hk, mac); in ath_keyset_tkip()
148 * Room for both TX+RX MIC keys in one key cache in ath_keyset_tkip()
152 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
153 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
154 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
155 return ath_hal_keyset(ah, k->wk_keyix, hk, mac); in ath_keyset_tkip()
157 } else if (k->wk_flags & IEEE80211_KEY_XMIT) { in ath_keyset_tkip()
158 if (sc->sc_splitmic) { in ath_keyset_tkip()
160 * NB: must pass MIC key in expected location when in ath_keyset_tkip()
161 * the keycache only holds one MIC key per entry. in ath_keyset_tkip()
163 memcpy(hk->kv_mic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
165 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
166 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
167 return ath_hal_keyset(ah, k->wk_keyix, hk, mac); in ath_keyset_tkip()
168 } else if (k->wk_flags & IEEE80211_KEY_RECV) { in ath_keyset_tkip()
169 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
170 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
171 return ath_hal_keyset(ah, k->wk_keyix, hk, mac); in ath_keyset_tkip()
180 * cache slots for TKIP with hardware MIC support.
182 int
192 (u_int8_t) -1, /* 4 is not allocated */ in ath_keyset()
196 struct ath_hal *ah = sc->sc_ah; in ath_keyset()
197 const struct ieee80211_cipher *cip = k->wk_cipher; in ath_keyset()
201 int ret; in ath_keyset()
205 * Software crypto uses a "clear key" so non-crypto in ath_keyset()
209 if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) { in ath_keyset()
210 KASSERT(cip->ic_cipher < nitems(ciphermap), in ath_keyset()
211 ("invalid cipher type %u", cip->ic_cipher)); in ath_keyset()
212 hk.kv_type = ciphermap[cip->ic_cipher]; in ath_keyset()
213 hk.kv_len = k->wk_keylen; in ath_keyset()
214 memcpy(hk.kv_val, k->wk_key, k->wk_keylen); in ath_keyset()
223 if (hk.kv_type == HAL_CIPHER_CLR && sc->sc_hasclrkey == 0) { in ath_keyset()
237 if ((vap->iv_opmode == IEEE80211_M_HOSTAP || in ath_keyset()
238 vap->iv_opmode == IEEE80211_M_IBSS) && in ath_keyset()
242 (k->wk_flags & IEEE80211_KEY_GROUP) && in ath_keyset()
243 sc->sc_mcastkey) { in ath_keyset()
247 * the multicast bit set instead of the app-specified address. in ath_keyset()
249 IEEE80211_ADDR_COPY(gmac, bss->ni_macaddr); in ath_keyset()
253 mac = k->wk_macaddr; in ath_keyset()
258 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) { in ath_keyset()
261 KEYPRINTF(sc, k->wk_keyix, &hk, mac); in ath_keyset()
262 ret = ath_hal_keyset(ah, k->wk_keyix, &hk, mac); in ath_keyset()
272 * each key, one for decrypt/encrypt and the other for the MIC.
280 KASSERT(sc->sc_splitmic, ("key cache !split")); in key_alloc_2pair()
282 for (i = 0; i < nitems(sc->sc_keymap)/4; i++) { in key_alloc_2pair()
283 u_int8_t b = sc->sc_keymap[i]; in key_alloc_2pair()
295 if (isset(sc->sc_keymap, keyix+32) || in key_alloc_2pair()
296 isset(sc->sc_keymap, keyix+64) || in key_alloc_2pair()
297 isset(sc->sc_keymap, keyix+32+64)) { in key_alloc_2pair()
306 setbit(sc->sc_keymap, keyix); in key_alloc_2pair()
307 setbit(sc->sc_keymap, keyix+64); in key_alloc_2pair()
308 setbit(sc->sc_keymap, keyix+32); in key_alloc_2pair()
309 setbit(sc->sc_keymap, keyix+32+64); in key_alloc_2pair()
325 * each key, one for decrypt/encrypt and the other for the MIC.
333 KASSERT(!sc->sc_splitmic, ("key cache split")); in key_alloc_pair()
335 for (i = 0; i < nitems(sc->sc_keymap)/4; i++) { in key_alloc_pair()
336 u_int8_t b = sc->sc_keymap[i]; in key_alloc_pair()
347 if (isset(sc->sc_keymap, keyix+64)) { in key_alloc_pair()
356 setbit(sc->sc_keymap, keyix); in key_alloc_pair()
357 setbit(sc->sc_keymap, keyix+64); in key_alloc_pair()
372 static int
378 if (sc->sc_hasclrkey == 0) { in key_alloc_single()
387 for (i = 0; i < nitems(sc->sc_keymap); i++) { in key_alloc_single()
388 u_int8_t b = sc->sc_keymap[i]; in key_alloc_single()
396 setbit(sc->sc_keymap, keyix); in key_alloc_single()
410 * TKIP with split cipher+MIC keys we allocate two key cache slot
411 * pairs so that we can setup separate TX and RX MIC keys. Note
412 * that the MIC key for a TKIP key at slot i is assumed by the
416 int
420 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_alloc()
431 * multi-station operation. in ath_key_alloc()
433 if (k->wk_keyix != IEEE80211_KEYIX_NONE) { in ath_key_alloc()
443 if (vap->iv_opmode != IEEE80211_M_HOSTAP || in ath_key_alloc()
444 !(k->wk_flags & IEEE80211_KEY_GROUP) || in ath_key_alloc()
445 !sc->sc_mcastkey) { in ath_key_alloc()
447 * XXX we pre-allocate the global keys so in ath_key_alloc()
458 k->wk_keyix = IEEE80211_KEYIX_NONE; in ath_key_alloc()
463 * the MIC. For everything else, including software crypto, in ath_key_alloc()
465 * a pass-through slot on the 5211 and 5212. The 5210 does in ath_key_alloc()
466 * not support pass-through cache entries and we map all in ath_key_alloc()
469 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) { in ath_key_alloc()
471 } else if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_alloc()
472 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) { in ath_key_alloc()
473 if (sc->sc_splitmic) in ath_key_alloc()
485 int
488 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_delete()
489 struct ath_hal *ah = sc->sc_ah; in ath_key_delete()
490 const struct ieee80211_cipher *cip = k->wk_cipher; in ath_key_delete()
491 u_int keyix = k->wk_keyix; in ath_key_delete()
499 * Handle split tx/rx keying required for TKIP with h/w MIC. in ath_key_delete()
501 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_delete()
502 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && sc->sc_splitmic) in ath_key_delete()
509 clrbit(sc->sc_keymap, keyix); in ath_key_delete()
510 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_delete()
511 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) { in ath_key_delete()
512 clrbit(sc->sc_keymap, keyix+64); /* TX key MIC */ in ath_key_delete()
513 if (sc->sc_splitmic) { in ath_key_delete()
514 /* +32 for RX key, +32+64 for RX key MIC */ in ath_key_delete()
515 clrbit(sc->sc_keymap, keyix+32); in ath_key_delete()
516 clrbit(sc->sc_keymap, keyix+32+64); in ath_key_delete()
529 int
532 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_set()
534 return ath_keyset(sc, vap, k, vap->iv_bss); in ath_key_set()