^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * lib80211 -- common bits for IEEE802.11 drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright(c) 2008 John W. Linville <linville@tuxdriver.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Portions copied from old ieee80211 component, w/ original copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * notices below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Host AP crypto routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/ieee80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <net/lib80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define DRV_DESCRIPTION "common routines for IEEE802.11 drivers"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) MODULE_DESCRIPTION(DRV_DESCRIPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) MODULE_AUTHOR("John W. Linville <linville@tuxdriver.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct lib80211_crypto_alg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct lib80211_crypto_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static LIST_HEAD(lib80211_crypto_algs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static DEFINE_SPINLOCK(lib80211_crypto_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void lib80211_crypt_quiescing(struct lib80211_crypt_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static void lib80211_crypt_deinit_handler(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) spinlock_t *lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) memset(info, 0, sizeof(*info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) info->name = name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) info->lock = lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) INIT_LIST_HEAD(&info->crypt_deinit_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) timer_setup(&info->crypt_deinit_timer, lib80211_crypt_deinit_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) EXPORT_SYMBOL(lib80211_crypt_info_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) void lib80211_crypt_info_free(struct lib80211_crypt_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) lib80211_crypt_quiescing(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) del_timer_sync(&info->crypt_deinit_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) lib80211_crypt_deinit_entries(info, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) for (i = 0; i < NUM_WEP_KEYS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct lib80211_crypt_data *crypt = info->crypt[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (crypt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (crypt->ops) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) crypt->ops->deinit(crypt->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) module_put(crypt->ops->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) kfree(crypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) info->crypt[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) EXPORT_SYMBOL(lib80211_crypt_info_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct lib80211_crypt_data *entry, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) spin_lock_irqsave(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) list_for_each_entry_safe(entry, next, &info->crypt_deinit_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (atomic_read(&entry->refcnt) != 0 && !force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) list_del(&entry->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (entry->ops) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) entry->ops->deinit(entry->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) module_put(entry->ops->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) spin_unlock_irqrestore(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* After this, crypt_deinit_list won't accept new members */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static void lib80211_crypt_quiescing(struct lib80211_crypt_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) spin_lock_irqsave(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) info->crypt_quiesced = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) spin_unlock_irqrestore(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static void lib80211_crypt_deinit_handler(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct lib80211_crypt_info *info = from_timer(info, t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) crypt_deinit_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) lib80211_crypt_deinit_entries(info, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) spin_lock_irqsave(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (!list_empty(&info->crypt_deinit_list) && !info->crypt_quiesced) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) "deletion list\n", info->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) info->crypt_deinit_timer.expires = jiffies + HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) add_timer(&info->crypt_deinit_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) spin_unlock_irqrestore(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct lib80211_crypt_data **crypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct lib80211_crypt_data *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (*crypt == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) tmp = *crypt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) *crypt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* must not run ops->deinit() while there may be pending encrypt or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * decrypt operations. Use a list of delayed deinits to avoid needing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * locking. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) spin_lock_irqsave(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (!info->crypt_quiesced) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) list_add(&tmp->list, &info->crypt_deinit_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!timer_pending(&info->crypt_deinit_timer)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) info->crypt_deinit_timer.expires = jiffies + HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) add_timer(&info->crypt_deinit_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) spin_unlock_irqrestore(info->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) EXPORT_SYMBOL(lib80211_crypt_delayed_deinit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct lib80211_crypto_alg *alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) alg = kzalloc(sizeof(*alg), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (alg == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) alg->ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) spin_lock_irqsave(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) list_add(&alg->list, &lib80211_crypto_algs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) spin_unlock_irqrestore(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) printk(KERN_DEBUG "lib80211_crypt: registered algorithm '%s'\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) ops->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) EXPORT_SYMBOL(lib80211_register_crypto_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct lib80211_crypto_alg *alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) spin_lock_irqsave(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) list_for_each_entry(alg, &lib80211_crypto_algs, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (alg->ops == ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) spin_unlock_irqrestore(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) printk(KERN_DEBUG "lib80211_crypt: unregistered algorithm '%s'\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ops->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) list_del(&alg->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) spin_unlock_irqrestore(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) kfree(alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) EXPORT_SYMBOL(lib80211_unregister_crypto_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct lib80211_crypto_alg *alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) spin_lock_irqsave(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) list_for_each_entry(alg, &lib80211_crypto_algs, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (strcmp(alg->ops->name, name) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) spin_unlock_irqrestore(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) spin_unlock_irqrestore(&lib80211_crypto_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return alg->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) EXPORT_SYMBOL(lib80211_get_crypto_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static void *lib80211_crypt_null_init(int keyidx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return (void *)1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static void lib80211_crypt_null_deinit(void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static struct lib80211_crypto_ops lib80211_crypt_null = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .name = "NULL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .init = lib80211_crypt_null_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .deinit = lib80211_crypt_null_deinit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static int __init lib80211_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) pr_info(DRV_DESCRIPTION "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return lib80211_register_crypto_ops(&lib80211_crypt_null);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static void __exit lib80211_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) lib80211_unregister_crypto_ops(&lib80211_crypt_null);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) BUG_ON(!list_empty(&lib80211_crypto_algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) module_init(lib80211_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) module_exit(lib80211_exit);