Lines Matching refs:tkey
312 struct lib80211_tkip_data *tkey = priv; in lib80211_tkip_hdr() local
324 if (!tkey->tx_phase1_done) { in lib80211_tkip_hdr()
325 tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, in lib80211_tkip_hdr()
326 tkey->tx_iv32); in lib80211_tkip_hdr()
327 tkey->tx_phase1_done = 1; in lib80211_tkip_hdr()
329 tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); in lib80211_tkip_hdr()
338 *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ; in lib80211_tkip_hdr()
339 *pos++ = tkey->tx_iv32 & 0xff; in lib80211_tkip_hdr()
340 *pos++ = (tkey->tx_iv32 >> 8) & 0xff; in lib80211_tkip_hdr()
341 *pos++ = (tkey->tx_iv32 >> 16) & 0xff; in lib80211_tkip_hdr()
342 *pos++ = (tkey->tx_iv32 >> 24) & 0xff; in lib80211_tkip_hdr()
344 tkey->tx_iv16++; in lib80211_tkip_hdr()
345 if (tkey->tx_iv16 == 0) { in lib80211_tkip_hdr()
346 tkey->tx_phase1_done = 0; in lib80211_tkip_hdr()
347 tkey->tx_iv32++; in lib80211_tkip_hdr()
355 struct lib80211_tkip_data *tkey = priv; in lib80211_tkip_encrypt() local
356 struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 }; in lib80211_tkip_encrypt()
362 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { in lib80211_tkip_encrypt()
385 crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); in lib80211_tkip_encrypt()
405 struct lib80211_tkip_data *tkey = priv; in lib80211_tkip_decrypt() local
406 struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 }; in lib80211_tkip_decrypt()
419 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { in lib80211_tkip_decrypt()
436 if (tkey->key_idx != keyidx) { in lib80211_tkip_decrypt()
438 "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv); in lib80211_tkip_decrypt()
441 if (!tkey->key_set) { in lib80211_tkip_decrypt()
450 if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) { in lib80211_tkip_decrypt()
453 hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, in lib80211_tkip_decrypt()
456 tkey->dot11RSNAStatsTKIPReplays++; in lib80211_tkip_decrypt()
460 if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { in lib80211_tkip_decrypt()
461 tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); in lib80211_tkip_decrypt()
462 tkey->rx_phase1_done = 1; in lib80211_tkip_decrypt()
464 tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); in lib80211_tkip_decrypt()
468 crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); in lib80211_tkip_decrypt()
482 if (iv32 != tkey->rx_iv32) { in lib80211_tkip_decrypt()
485 tkey->rx_phase1_done = 0; in lib80211_tkip_decrypt()
491 tkey->dot11RSNAStatsTKIPICVErrors++; in lib80211_tkip_decrypt()
497 tkey->rx_iv32_new = iv32; in lib80211_tkip_decrypt()
498 tkey->rx_iv16_new = iv16; in lib80211_tkip_decrypt()
568 struct lib80211_tkip_data *tkey = priv; in lib80211_michael_mic_add() local
578 michael_mic_hdr(skb, tkey->tx_hdr); in lib80211_michael_mic_add()
580 if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, in lib80211_michael_mic_add()
611 struct lib80211_tkip_data *tkey = priv; in lib80211_michael_mic_verify() local
614 if (!tkey->key_set) in lib80211_michael_mic_verify()
617 michael_mic_hdr(skb, tkey->rx_hdr); in lib80211_michael_mic_verify()
618 if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, in lib80211_michael_mic_verify()
630 tkey->dot11RSNAStatsTKIPLocalMICFailures++; in lib80211_michael_mic_verify()
636 tkey->rx_iv32 = tkey->rx_iv32_new; in lib80211_michael_mic_verify()
637 tkey->rx_iv16 = tkey->rx_iv16_new; in lib80211_michael_mic_verify()
646 struct lib80211_tkip_data *tkey = priv; in lib80211_tkip_set_key() local
648 struct crypto_hash *tfm = tkey->tx_tfm_michael; in lib80211_tkip_set_key()
649 struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4; in lib80211_tkip_set_key()
650 struct crypto_hash *tfm3 = tkey->rx_tfm_michael; in lib80211_tkip_set_key()
651 struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4; in lib80211_tkip_set_key()
653 keyidx = tkey->key_idx; in lib80211_tkip_set_key()
654 memset(tkey, 0, sizeof(*tkey)); in lib80211_tkip_set_key()
655 tkey->key_idx = keyidx; in lib80211_tkip_set_key()
656 tkey->tx_tfm_michael = tfm; in lib80211_tkip_set_key()
657 tkey->tx_tfm_arc4 = tfm2; in lib80211_tkip_set_key()
658 tkey->rx_tfm_michael = tfm3; in lib80211_tkip_set_key()
659 tkey->rx_tfm_arc4 = tfm4; in lib80211_tkip_set_key()
661 memcpy(tkey->key, key, TKIP_KEY_LEN); in lib80211_tkip_set_key()
662 tkey->key_set = 1; in lib80211_tkip_set_key()
663 tkey->tx_iv16 = 1; /* TSC is initialized to 1 */ in lib80211_tkip_set_key()
665 tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) | in lib80211_tkip_set_key()
667 tkey->rx_iv16 = (seq[1] << 8) | seq[0]; in lib80211_tkip_set_key()
670 tkey->key_set = 0; in lib80211_tkip_set_key()
679 struct lib80211_tkip_data *tkey = priv; in lib80211_tkip_get_key() local
684 if (!tkey->key_set) in lib80211_tkip_get_key()
686 memcpy(key, tkey->key, TKIP_KEY_LEN); in lib80211_tkip_get_key()
690 u16 iv16 = tkey->tx_iv16; in lib80211_tkip_get_key()
691 u32 iv32 = tkey->tx_iv32; in lib80211_tkip_get_key()
695 seq[0] = tkey->tx_iv16; in lib80211_tkip_get_key()
696 seq[1] = tkey->tx_iv16 >> 8; in lib80211_tkip_get_key()
697 seq[2] = tkey->tx_iv32; in lib80211_tkip_get_key()
698 seq[3] = tkey->tx_iv32 >> 8; in lib80211_tkip_get_key()
699 seq[4] = tkey->tx_iv32 >> 16; in lib80211_tkip_get_key()
700 seq[5] = tkey->tx_iv32 >> 24; in lib80211_tkip_get_key()