Lines Matching refs:key

127 static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)  in ieee80211_key_enable_hw_accel()  argument
129 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_key_enable_hw_accel()
135 if (key->flags & KEY_FLAG_TAINTED) { in ieee80211_key_enable_hw_accel()
143 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
147 if (!key->local->ops->set_key) in ieee80211_key_enable_hw_accel()
150 assert_key_lock(key->local); in ieee80211_key_enable_hw_accel()
152 sta = key->sta; in ieee80211_key_enable_hw_accel()
158 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && in ieee80211_key_enable_hw_accel()
159 !ieee80211_hw_check(&key->local->hw, SUPPORTS_PER_STA_GTK)) in ieee80211_key_enable_hw_accel()
170 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) in ieee80211_key_enable_hw_accel()
174 ret = drv_set_key(key->local, SET_KEY, sdata, in ieee80211_key_enable_hw_accel()
175 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_enable_hw_accel()
178 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
180 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
182 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) in ieee80211_key_enable_hw_accel()
185 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && in ieee80211_key_enable_hw_accel()
186 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); in ieee80211_key_enable_hw_accel()
188 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) && in ieee80211_key_enable_hw_accel()
189 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)); in ieee80211_key_enable_hw_accel()
197 key->conf.keyidx, in ieee80211_key_enable_hw_accel()
201 switch (key->conf.cipher) { in ieee80211_key_enable_hw_accel()
216 if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) { in ieee80211_key_enable_hw_accel()
227 static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) in ieee80211_key_disable_hw_accel() argument
235 if (!key || !key->local->ops->set_key) in ieee80211_key_disable_hw_accel()
238 assert_key_lock(key->local); in ieee80211_key_disable_hw_accel()
240 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_disable_hw_accel()
243 sta = key->sta; in ieee80211_key_disable_hw_accel()
244 sdata = key->sdata; in ieee80211_key_disable_hw_accel()
246 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_disable_hw_accel()
248 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) in ieee80211_key_disable_hw_accel()
251 ret = drv_set_key(key->local, DISABLE_KEY, sdata, in ieee80211_key_disable_hw_accel()
252 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_disable_hw_accel()
257 key->conf.keyidx, in ieee80211_key_disable_hw_accel()
260 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_disable_hw_accel()
266 struct ieee80211_key *key = NULL; in __ieee80211_set_default_key() local
271 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); in __ieee80211_set_default_key()
274 rcu_assign_pointer(sdata->default_unicast_key, key); in __ieee80211_set_default_key()
281 rcu_assign_pointer(sdata->default_multicast_key, key); in __ieee80211_set_default_key()
297 struct ieee80211_key *key = NULL; in __ieee80211_set_default_mgmt_key() local
303 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); in __ieee80211_set_default_mgmt_key()
305 rcu_assign_pointer(sdata->default_mgmt_key, key); in __ieee80211_set_default_mgmt_key()
391 struct ieee80211_key *key; in ieee80211_key_alloc() local
397 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); in ieee80211_key_alloc()
398 if (!key) in ieee80211_key_alloc()
405 key->conf.flags = 0; in ieee80211_key_alloc()
406 key->flags = 0; in ieee80211_key_alloc()
408 key->conf.cipher = cipher; in ieee80211_key_alloc()
409 key->conf.keyidx = idx; in ieee80211_key_alloc()
410 key->conf.keylen = key_len; in ieee80211_key_alloc()
414 key->conf.iv_len = IEEE80211_WEP_IV_LEN; in ieee80211_key_alloc()
415 key->conf.icv_len = IEEE80211_WEP_ICV_LEN; in ieee80211_key_alloc()
418 key->conf.iv_len = IEEE80211_TKIP_IV_LEN; in ieee80211_key_alloc()
419 key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; in ieee80211_key_alloc()
422 key->u.tkip.rx[i].iv32 = in ieee80211_key_alloc()
424 key->u.tkip.rx[i].iv16 = in ieee80211_key_alloc()
428 spin_lock_init(&key->u.tkip.txlock); in ieee80211_key_alloc()
431 key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; in ieee80211_key_alloc()
432 key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; in ieee80211_key_alloc()
436 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
443 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
445 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
446 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
447 kfree(key); in ieee80211_key_alloc()
452 key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN; in ieee80211_key_alloc()
453 key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN; in ieee80211_key_alloc()
456 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
461 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
463 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
464 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
465 kfree(key); in ieee80211_key_alloc()
471 key->conf.iv_len = 0; in ieee80211_key_alloc()
473 key->conf.icv_len = sizeof(struct ieee80211_mmie); in ieee80211_key_alloc()
475 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
478 key->u.aes_cmac.rx_pn[j] = in ieee80211_key_alloc()
484 key->u.aes_cmac.tfm = in ieee80211_key_alloc()
486 if (IS_ERR(key->u.aes_cmac.tfm)) { in ieee80211_key_alloc()
487 err = PTR_ERR(key->u.aes_cmac.tfm); in ieee80211_key_alloc()
488 kfree(key); in ieee80211_key_alloc()
494 key->conf.iv_len = 0; in ieee80211_key_alloc()
495 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
498 key->u.aes_gmac.rx_pn[j] = in ieee80211_key_alloc()
503 key->u.aes_gmac.tfm = in ieee80211_key_alloc()
505 if (IS_ERR(key->u.aes_gmac.tfm)) { in ieee80211_key_alloc()
506 err = PTR_ERR(key->u.aes_gmac.tfm); in ieee80211_key_alloc()
507 kfree(key); in ieee80211_key_alloc()
513 key->conf.iv_len = IEEE80211_GCMP_HDR_LEN; in ieee80211_key_alloc()
514 key->conf.icv_len = IEEE80211_GCMP_MIC_LEN; in ieee80211_key_alloc()
517 key->u.gcmp.rx_pn[i][j] = in ieee80211_key_alloc()
522 key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data, in ieee80211_key_alloc()
524 if (IS_ERR(key->u.gcmp.tfm)) { in ieee80211_key_alloc()
525 err = PTR_ERR(key->u.gcmp.tfm); in ieee80211_key_alloc()
526 kfree(key); in ieee80211_key_alloc()
533 kfree(key); in ieee80211_key_alloc()
537 key->conf.iv_len = cs->hdr_len; in ieee80211_key_alloc()
538 key->conf.icv_len = cs->mic_len; in ieee80211_key_alloc()
541 key->u.gen.rx_pn[i][j] = in ieee80211_key_alloc()
543 key->flags |= KEY_FLAG_CIPHER_SCHEME; in ieee80211_key_alloc()
546 memcpy(key->conf.key, key_data, key_len); in ieee80211_key_alloc()
547 INIT_LIST_HEAD(&key->list); in ieee80211_key_alloc()
549 return key; in ieee80211_key_alloc()
552 static void ieee80211_key_free_common(struct ieee80211_key *key) in ieee80211_key_free_common() argument
554 switch (key->conf.cipher) { in ieee80211_key_free_common()
557 ieee80211_aes_key_free(key->u.ccmp.tfm); in ieee80211_key_free_common()
561 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); in ieee80211_key_free_common()
565 ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm); in ieee80211_key_free_common()
569 ieee80211_aes_gcm_key_free(key->u.gcmp.tfm); in ieee80211_key_free_common()
572 kzfree(key); in ieee80211_key_free_common()
575 static void __ieee80211_key_destroy(struct ieee80211_key *key, in __ieee80211_key_destroy() argument
578 if (key->local) in __ieee80211_key_destroy()
579 ieee80211_key_disable_hw_accel(key); in __ieee80211_key_destroy()
581 if (key->local) { in __ieee80211_key_destroy()
582 struct ieee80211_sub_if_data *sdata = key->sdata; in __ieee80211_key_destroy()
584 ieee80211_debugfs_key_remove(key); in __ieee80211_key_destroy()
596 ieee80211_key_free_common(key); in __ieee80211_key_destroy()
599 static void ieee80211_key_destroy(struct ieee80211_key *key, in ieee80211_key_destroy() argument
602 if (!key) in ieee80211_key_destroy()
611 __ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_destroy()
614 void ieee80211_key_free_unused(struct ieee80211_key *key) in ieee80211_key_free_unused() argument
616 WARN_ON(key->sdata || key->local); in ieee80211_key_free_unused()
617 ieee80211_key_free_common(key); in ieee80211_key_free_unused()
630 tk_old = old->conf.key; in ieee80211_key_identical()
631 tk_new = new->conf.key; in ieee80211_key_identical()
653 int ieee80211_key_link(struct ieee80211_key *key, in ieee80211_key_link() argument
659 int idx = key->conf.keyidx; in ieee80211_key_link()
660 bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; in ieee80211_key_link()
682 if (ieee80211_key_identical(sdata, old_key, key)) { in ieee80211_key_link()
683 ieee80211_key_free_unused(key); in ieee80211_key_link()
688 key->local = sdata->local; in ieee80211_key_link()
689 key->sdata = sdata; in ieee80211_key_link()
690 key->sta = sta; in ieee80211_key_link()
694 ieee80211_key_replace(sdata, sta, pairwise, old_key, key); in ieee80211_key_link()
697 ieee80211_debugfs_key_add(key); in ieee80211_key_link()
700 ret = ieee80211_key_enable_hw_accel(key); in ieee80211_key_link()
702 ieee80211_key_free(key, delay_tailroom); in ieee80211_key_link()
713 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) in ieee80211_key_free() argument
715 if (!key) in ieee80211_key_free()
721 if (key->sdata) in ieee80211_key_free()
722 ieee80211_key_replace(key->sdata, key->sta, in ieee80211_key_free()
723 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_key_free()
724 key, NULL); in ieee80211_key_free()
725 ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_free()
730 struct ieee80211_key *key; in ieee80211_enable_keys() local
749 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_enable_keys()
751 ieee80211_key_enable_hw_accel(key); in ieee80211_enable_keys()
778 struct ieee80211_key_conf *key, in ieee80211_iter_keys() argument
783 struct ieee80211_key *key, *tmp; in ieee80211_iter_keys() local
791 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) in ieee80211_iter_keys()
793 key->sta ? &key->sta->sta : NULL, in ieee80211_iter_keys()
794 &key->conf, iter_data); in ieee80211_iter_keys()
797 list_for_each_entry_safe(key, tmp, in ieee80211_iter_keys()
800 key->sta ? &key->sta->sta : NULL, in ieee80211_iter_keys()
801 &key->conf, iter_data); in ieee80211_iter_keys()
813 struct ieee80211_key_conf *key, in _ieee80211_iter_keys_rcu() argument
817 struct ieee80211_key *key; in _ieee80211_iter_keys_rcu() local
819 list_for_each_entry_rcu(key, &sdata->key_list, list) { in _ieee80211_iter_keys_rcu()
821 if (key->sta && key->sta->removed) in _ieee80211_iter_keys_rcu()
823 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in _ieee80211_iter_keys_rcu()
827 key->sta ? &key->sta->sta : NULL, in _ieee80211_iter_keys_rcu()
828 &key->conf, iter_data); in _ieee80211_iter_keys_rcu()
837 struct ieee80211_key_conf *key, in ieee80211_iter_keys_rcu() argument
857 struct ieee80211_key *key, *tmp; in ieee80211_free_keys_iface() local
865 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_free_keys_iface()
866 ieee80211_key_replace(key->sdata, key->sta, in ieee80211_free_keys_iface()
867 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_keys_iface()
868 key, NULL); in ieee80211_free_keys_iface()
869 list_add_tail(&key->list, keys); in ieee80211_free_keys_iface()
881 struct ieee80211_key *key, *tmp; in ieee80211_free_keys() local
897 list_for_each_entry_safe(key, tmp, &keys, list) in ieee80211_free_keys()
898 __ieee80211_key_destroy(key, false); in ieee80211_free_keys()
926 struct ieee80211_key *key; in ieee80211_free_sta_keys() local
931 key = key_mtx_dereference(local, sta->gtk[i]); in ieee80211_free_sta_keys()
932 if (!key) in ieee80211_free_sta_keys()
934 ieee80211_key_replace(key->sdata, key->sta, in ieee80211_free_sta_keys()
935 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
936 key, NULL); in ieee80211_free_sta_keys()
937 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
942 key = key_mtx_dereference(local, sta->ptk[i]); in ieee80211_free_sta_keys()
943 if (!key) in ieee80211_free_sta_keys()
945 ieee80211_key_replace(key->sdata, key->sta, in ieee80211_free_sta_keys()
946 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
947 key, NULL); in ieee80211_free_sta_keys()
948 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
999 struct ieee80211_key *key; in ieee80211_get_key_rx_seq() local
1002 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_get_key_rx_seq()
1004 switch (key->conf.cipher) { in ieee80211_get_key_rx_seq()
1008 seq->tkip.iv32 = key->u.tkip.rx[tid].iv32; in ieee80211_get_key_rx_seq()
1009 seq->tkip.iv16 = key->u.tkip.rx[tid].iv16; in ieee80211_get_key_rx_seq()
1016 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1018 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1025 pn = key->u.aes_cmac.rx_pn; in ieee80211_get_key_rx_seq()
1032 pn = key->u.aes_gmac.rx_pn; in ieee80211_get_key_rx_seq()
1040 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1042 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1052 struct ieee80211_key *key; in ieee80211_set_key_rx_seq() local
1055 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_set_key_rx_seq()
1057 switch (key->conf.cipher) { in ieee80211_set_key_rx_seq()
1061 key->u.tkip.rx[tid].iv32 = seq->tkip.iv32; in ieee80211_set_key_rx_seq()
1062 key->u.tkip.rx[tid].iv16 = seq->tkip.iv16; in ieee80211_set_key_rx_seq()
1069 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1071 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1078 pn = key->u.aes_cmac.rx_pn; in ieee80211_set_key_rx_seq()
1085 pn = key->u.aes_gmac.rx_pn; in ieee80211_set_key_rx_seq()
1093 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1095 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1107 struct ieee80211_key *key; in ieee80211_remove_key() local
1109 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_remove_key()
1111 assert_key_lock(key->local); in ieee80211_remove_key()
1117 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_remove_key()
1118 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_remove_key()
1120 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_remove_key()
1122 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) in ieee80211_remove_key()
1123 increment_tailroom_need_count(key->sdata); in ieee80211_remove_key()
1126 ieee80211_key_free(key, false); in ieee80211_remove_key()
1136 struct ieee80211_key *key; in ieee80211_gtk_rekey_add() local
1145 key = ieee80211_key_alloc(keyconf->cipher, keyconf->keyidx, in ieee80211_gtk_rekey_add()
1146 keyconf->keylen, keyconf->key, in ieee80211_gtk_rekey_add()
1148 if (IS_ERR(key)) in ieee80211_gtk_rekey_add()
1149 return ERR_CAST(key); in ieee80211_gtk_rekey_add()
1152 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; in ieee80211_gtk_rekey_add()
1154 err = ieee80211_key_link(key, sdata, NULL); in ieee80211_gtk_rekey_add()
1158 return &key->conf; in ieee80211_gtk_rekey_add()