Lines Matching +full:mic +full:- +full:pos

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
95 vap->iv_stats.is_crypto_nomem++; in wep_attach()
99 ctx->wc_vap = vap; in wep_attach()
100 ctx->wc_ic = vap->iv_ic; in wep_attach()
101 net80211_get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); in wep_attach()
109 struct wep_ctx *ctx = k->wk_private; in wep_detach()
113 nrefs--; /* NB: we assume caller locking */ in wep_detach()
119 return k->wk_keylen >= 40/NBBY; in wep_setkey()
125 struct wep_ctx *ctx = k->wk_private; in wep_setiv()
126 struct ieee80211vap *vap = ctx->wc_vap; in wep_setiv()
151 iv = ctx->wc_iv; in wep_setiv()
157 ctx->wc_iv = iv + 1; in wep_setiv()
181 struct wep_ctx *ctx = k->wk_private; in wep_encap()
182 struct ieee80211com *ic = ctx->wc_ic; in wep_encap()
195 if (is_mgmt && (k->wk_flags & IEEE80211_KEY_NOIVMGT)) in wep_encap()
197 if ((! is_mgmt) && (k->wk_flags & IEEE80211_KEY_NOIV)) in wep_encap()
215 if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) && in wep_encap()
223 * Add MIC to the frame as needed.
240 struct wep_ctx *ctx = k->wk_private; in wep_decap()
241 struct ieee80211vap *vap = ctx->wc_vap; in wep_decap()
246 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_IV_STRIP)) in wep_decap()
254 if ((k->wk_flags & IEEE80211_KEY_SWDECRYPT) && in wep_decap()
261 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2, in wep_decap()
263 vap->iv_stats.is_rx_wepfail++; in wep_decap()
275 m_adj(m, -wep.ic_trailer); in wep_decap()
281 * Verify and strip MIC from the frame.
348 struct wep_ctx *ctx = key->wk_private; in wep_encrypt()
349 struct ieee80211vap *vap = ctx->wc_vap; in wep_encrypt()
356 uint8_t *pos; in wep_encrypt() local
359 vap->iv_stats.is_crypto_wep++; in wep_encrypt()
363 memcpy(rc4key + IEEE80211_WEP_IVLEN, key->wk_key, key->wk_keylen); in wep_encrypt()
369 keylen = key->wk_keylen + IEEE80211_WEP_IVLEN; in wep_encrypt()
376 data_len = m->m_pkthdr.len - off; in wep_encrypt()
381 pos = mtod(m, uint8_t *) + off; in wep_encrypt()
382 buflen = m->m_len - off; in wep_encrypt()
386 data_len -= buflen; in wep_encrypt()
388 crc = crc32_table[(crc ^ *pos) & 0xff] ^ (crc >> 8); in wep_encrypt()
392 *pos++ ^= S[(S[i] + S[j]) & 0xff]; in wep_encrypt()
394 if (m->m_next == NULL) { in wep_encrypt()
398 struct ieee80211_frame *)->i_addr2), in wep_encrypt()
406 m = m->m_next; in wep_encrypt()
407 pos = mtod(m, uint8_t *); in wep_encrypt()
408 buflen = m->m_len; in wep_encrypt()
412 /* Append little-endian CRC32 and encrypt it to produce ICV */ in wep_encrypt()
431 struct wep_ctx *ctx = key->wk_private; in wep_decrypt()
432 struct ieee80211vap *vap = ctx->wc_vap; in wep_decrypt()
439 uint8_t *pos; in wep_decrypt() local
442 vap->iv_stats.is_crypto_wep++; in wep_decrypt()
446 memcpy(rc4key + IEEE80211_WEP_IVLEN, key->wk_key, key->wk_keylen); in wep_decrypt()
452 keylen = key->wk_keylen + IEEE80211_WEP_IVLEN; in wep_decrypt()
459 data_len = m->m_pkthdr.len - (off + wep.ic_trailer); in wep_decrypt()
464 pos = mtod(m, uint8_t *) + off; in wep_decrypt()
465 buflen = m->m_len - off; in wep_decrypt()
469 data_len -= buflen; in wep_decrypt()
474 *pos ^= S[(S[i] + S[j]) & 0xff]; in wep_decrypt()
475 crc = crc32_table[(crc ^ *pos) & 0xff] ^ (crc >> 8); in wep_decrypt()
476 pos++; in wep_decrypt()
478 m = m->m_next; in wep_decrypt()
482 mtod(m0, struct ieee80211_frame *)->i_addr2, in wep_decrypt()
489 pos = mtod(m, uint8_t *); in wep_decrypt()
490 buflen = m->m_len; in wep_decrypt()
494 /* Encrypt little-endian CRC32 and verify that it matches with in wep_decrypt()
505 if ((icv[k] ^ S[(S[i] + S[j]) & 0xff]) != *pos++) { in wep_decrypt()
506 /* ICV mismatch - drop frame */ in wep_decrypt()