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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2004, Instant802 Networks, Inc.
15 #include "driver-ops.h"
23 * 2-byte by 2-byte subset of the full AES S-box table; second part of this
24 * table is identical to first part but byte-swapped
67 static u8 *write_tkip_iv(u8 *pos, u16 iv16) in write_tkip_iv() argument
69 *pos++ = iv16 >> 8; in write_tkip_iv()
70 *pos++ = ((iv16 >> 8) | 0x20) & 0x7f; in write_tkip_iv()
71 *pos++ = iv16 & 0xFF; in write_tkip_iv()
72 return pos; in write_tkip_iv()
86 u16 *p1k = ctx->p1k; in tkip_mixing_phase1()
102 ctx->state = TKIP_STATE_PHASE1_DONE; in tkip_mixing_phase1()
103 ctx->p1k_iv32 = tsc_IV32; in tkip_mixing_phase1()
110 const u16 *p1k = ctx->p1k; in tkip_mixing_phase2()
140 /* Add TKIP IV and Ext. IV at @pos. @iv0, @iv1, and @iv2 are the first octets
143 u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn) in ieee80211_tkip_add_iv() argument
145 pos = write_tkip_iv(pos, TKIP_PN_TO_IV16(pn)); in ieee80211_tkip_add_iv()
146 *pos++ = (keyconf->keyidx << 6) | (1 << 5) /* Ext IV */; in ieee80211_tkip_add_iv()
147 put_unaligned_le32(TKIP_PN_TO_IV32(pn), pos); in ieee80211_tkip_add_iv()
148 return pos + 4; in ieee80211_tkip_add_iv()
154 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_compute_tkip_p1k()
155 struct tkip_ctx *ctx = &key->u.tkip.tx; in ieee80211_compute_tkip_p1k()
156 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; in ieee80211_compute_tkip_p1k()
158 lockdep_assert_held(&key->u.tkip.txlock); in ieee80211_compute_tkip_p1k()
163 * This might flip-flop back and forth if packets are processed in ieee80211_compute_tkip_p1k()
164 * out-of-order due to the different ACs, but then we have to in ieee80211_compute_tkip_p1k()
167 if (ctx->p1k_iv32 != iv32 || ctx->state == TKIP_STATE_NOT_INIT) in ieee80211_compute_tkip_p1k()
168 tkip_mixing_phase1(tk, ctx, sdata->vif.addr, iv32); in ieee80211_compute_tkip_p1k()
176 struct tkip_ctx *ctx = &key->u.tkip.tx; in ieee80211_get_tkip_p1k_iv()
178 spin_lock_bh(&key->u.tkip.txlock); in ieee80211_get_tkip_p1k_iv()
180 memcpy(p1k, ctx->p1k, sizeof(ctx->p1k)); in ieee80211_get_tkip_p1k_iv()
181 spin_unlock_bh(&key->u.tkip.txlock); in ieee80211_get_tkip_p1k_iv()
188 const u8 *tk = &keyconf->key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; in ieee80211_get_tkip_rx_p1k()
201 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; in ieee80211_get_tkip_p2k()
202 struct tkip_ctx *ctx = &key->u.tkip.tx; in ieee80211_get_tkip_p2k()
203 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_get_tkip_p2k()
204 const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); in ieee80211_get_tkip_p2k()
208 spin_lock(&key->u.tkip.txlock); in ieee80211_get_tkip_p2k()
211 spin_unlock(&key->u.tkip.txlock); in ieee80211_get_tkip_p2k()
216 * Encrypt packet payload with TKIP using @key. @pos is a pointer to the
229 ieee80211_get_tkip_p2k(&key->conf, skb, rc4key); in ieee80211_tkip_encrypt_data()
235 /* Decrypt packet payload with TKIP using @key. @pos is a pointer to the
237 * including IV, Ext. IV, real data, Michael MIC, ICV. @payload_len is the
238 * length of payload, including IV, Ext. IV, MIC, ICV. */
247 u8 rc4key[16], keyid, *pos = payload; in ieee80211_tkip_decrypt_data() local
249 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; in ieee80211_tkip_decrypt_data()
250 struct tkip_ctx_rx *rx_ctx = &key->u.tkip.rx[queue]; in ieee80211_tkip_decrypt_data()
253 return -1; in ieee80211_tkip_decrypt_data()
255 iv16 = (pos[0] << 8) | pos[2]; in ieee80211_tkip_decrypt_data()
256 keyid = pos[3]; in ieee80211_tkip_decrypt_data()
257 iv32 = get_unaligned_le32(pos + 4); in ieee80211_tkip_decrypt_data()
258 pos += 8; in ieee80211_tkip_decrypt_data()
263 if ((keyid >> 6) != key->conf.keyidx) in ieee80211_tkip_decrypt_data()
275 if (iv32 < rx_ctx->iv32 || in ieee80211_tkip_decrypt_data()
276 (iv32 == rx_ctx->iv32 && in ieee80211_tkip_decrypt_data()
277 (iv16 < rx_ctx->iv16 || in ieee80211_tkip_decrypt_data()
278 (iv16 == rx_ctx->iv16 && in ieee80211_tkip_decrypt_data()
279 (rx_ctx->iv32 || rx_ctx->iv16 || in ieee80211_tkip_decrypt_data()
280 rx_ctx->ctx.state != TKIP_STATE_NOT_INIT))))) in ieee80211_tkip_decrypt_data()
285 rx_ctx->ctx.state = TKIP_STATE_PHASE1_HW_UPLOADED; in ieee80211_tkip_decrypt_data()
289 if (rx_ctx->ctx.state == TKIP_STATE_NOT_INIT || in ieee80211_tkip_decrypt_data()
290 rx_ctx->iv32 != iv32) { in ieee80211_tkip_decrypt_data()
291 /* IV16 wrapped around - perform TKIP phase 1 */ in ieee80211_tkip_decrypt_data()
292 tkip_mixing_phase1(tk, &rx_ctx->ctx, ta, iv32); in ieee80211_tkip_decrypt_data()
294 if (key->local->ops->update_tkip_key && in ieee80211_tkip_decrypt_data()
295 key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && in ieee80211_tkip_decrypt_data()
296 rx_ctx->ctx.state != TKIP_STATE_PHASE1_HW_UPLOADED) { in ieee80211_tkip_decrypt_data()
297 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_tkip_decrypt_data()
299 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_tkip_decrypt_data()
300 sdata = container_of(key->sdata->bss, in ieee80211_tkip_decrypt_data()
302 drv_update_tkip_key(key->local, sdata, &key->conf, key->sta, in ieee80211_tkip_decrypt_data()
303 iv32, rx_ctx->ctx.p1k); in ieee80211_tkip_decrypt_data()
304 rx_ctx->ctx.state = TKIP_STATE_PHASE1_HW_UPLOADED; in ieee80211_tkip_decrypt_data()
307 tkip_mixing_phase2(tk, &rx_ctx->ctx, iv16, rc4key); in ieee80211_tkip_decrypt_data()
309 res = ieee80211_wep_decrypt_data(ctx, rc4key, 16, pos, payload_len - 12); in ieee80211_tkip_decrypt_data()
314 * key information after MIC verification. It is possible in ieee80211_tkip_decrypt_data()
316 * because the Michael MIC verication will then fail. in ieee80211_tkip_decrypt_data()