linux/net/mac80211/key.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2002-2005, Instant802 Networks, Inc.
 * Copyright 2005-2006, Devicescape Software, Inc.
 * Copyright 2006-2007	Jiri Benc <[email protected]>
 * Copyright 2007-2008	Johannes Berg <[email protected]>
 * Copyright 2013-2014  Intel Mobile Communications GmbH
 * Copyright 2015-2017	Intel Deutschland GmbH
 * Copyright 2018-2020, 2022-2024  Intel Corporation
 */

#include <crypto/utils.h>
#include <linux/if_ether.h>
#include <linux/etherdevice.h>
#include <linux/list.h>
#include <linux/rcupdate.h>
#include <linux/rtnetlink.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <net/mac80211.h>
#include <asm/unaligned.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "debugfs_key.h"
#include "aes_ccm.h"
#include "aes_cmac.h"
#include "aes_gmac.h"
#include "aes_gcm.h"


/**
 * DOC: Key handling basics
 *
 * Key handling in mac80211 is done based on per-interface (sub_if_data)
 * keys and per-station keys. Since each station belongs to an interface,
 * each station key also belongs to that interface.
 *
 * Hardware acceleration is done on a best-effort basis for algorithms
 * that are implemented in software,  for each key the hardware is asked
 * to enable that key for offloading but if it cannot do that the key is
 * simply kept for software encryption (unless it is for an algorithm
 * that isn't implemented in software).
 * There is currently no way of knowing whether a key is handled in SW
 * or HW except by looking into debugfs.
 *
 * All key management is internally protected by a mutex. Within all
 * other parts of mac80211, key references are, just as STA structure
 * references, protected by RCU. Note, however, that some things are
 * unprotected, namely the key->sta dereferences within the hardware
 * acceleration functions. This means that sta_info_destroy() must
 * remove the key which waits for an RCU grace period.
 */

static const u8 bcast_addr[ETH_ALEN] =;

static void
update_vlan_tailroom_need_count(struct ieee80211_sub_if_data *sdata, int delta)
{}

static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
{}

static void decrease_tailroom_need_count(struct ieee80211_sub_if_data *sdata,
					 int delta)
{}

static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{}

static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{}

static int _ieee80211_set_tx_key(struct ieee80211_key *key, bool force)
{}

int ieee80211_set_tx_key(struct ieee80211_key *key)
{}

static void ieee80211_pairwise_rekey(struct ieee80211_key *old,
				     struct ieee80211_key *new)
{}

static void __ieee80211_set_default_key(struct ieee80211_link_data *link,
					int idx, bool uni, bool multi)
{}

void ieee80211_set_default_key(struct ieee80211_link_data *link, int idx,
			       bool uni, bool multi)
{}

static void
__ieee80211_set_default_mgmt_key(struct ieee80211_link_data *link, int idx)
{}

void ieee80211_set_default_mgmt_key(struct ieee80211_link_data *link,
				    int idx)
{}

static void
__ieee80211_set_default_beacon_key(struct ieee80211_link_data *link, int idx)
{}

void ieee80211_set_default_beacon_key(struct ieee80211_link_data *link,
				      int idx)
{}

static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
				 struct ieee80211_link_data *link,
				 struct sta_info *sta,
				 bool pairwise,
				 struct ieee80211_key *old,
				 struct ieee80211_key *new)
{}

struct ieee80211_key *
ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
		    const u8 *key_data,
		    size_t seq_len, const u8 *seq)
{}

static void ieee80211_key_free_common(struct ieee80211_key *key)
{}

static void __ieee80211_key_destroy(struct ieee80211_key *key,
				    bool delay_tailroom)
{}

static void ieee80211_key_destroy(struct ieee80211_key *key,
				  bool delay_tailroom)
{}

void ieee80211_key_free_unused(struct ieee80211_key *key)
{}

static bool ieee80211_key_identical(struct ieee80211_sub_if_data *sdata,
				    struct ieee80211_key *old,
				    struct ieee80211_key *new)
{}

int ieee80211_key_link(struct ieee80211_key *key,
		       struct ieee80211_link_data *link,
		       struct sta_info *sta)
{}

void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom)
{}

void ieee80211_reenable_keys(struct ieee80211_sub_if_data *sdata)
{}

void ieee80211_iter_keys(struct ieee80211_hw *hw,
			 struct ieee80211_vif *vif,
			 void (*iter)(struct ieee80211_hw *hw,
				      struct ieee80211_vif *vif,
				      struct ieee80211_sta *sta,
				      struct ieee80211_key_conf *key,
				      void *data),
			 void *iter_data)
{}
EXPORT_SYMBOL();

static void
_ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
			 struct ieee80211_sub_if_data *sdata,
			 void (*iter)(struct ieee80211_hw *hw,
				      struct ieee80211_vif *vif,
				      struct ieee80211_sta *sta,
				      struct ieee80211_key_conf *key,
				      void *data),
			 void *iter_data)
{}

void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif,
			     void (*iter)(struct ieee80211_hw *hw,
					  struct ieee80211_vif *vif,
					  struct ieee80211_sta *sta,
					  struct ieee80211_key_conf *key,
					  void *data),
			     void *iter_data)
{}
EXPORT_SYMBOL();

static void ieee80211_free_keys_iface(struct ieee80211_sub_if_data *sdata,
				      struct list_head *keys)
{}

void ieee80211_remove_link_keys(struct ieee80211_link_data *link,
				struct list_head *keys)
{}

void ieee80211_free_key_list(struct ieee80211_local *local,
			     struct list_head *keys)
{}

void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
			 bool force_synchronize)
{}

void ieee80211_free_sta_keys(struct ieee80211_local *local,
			     struct sta_info *sta)
{}

void ieee80211_delayed_tailroom_dec(struct wiphy *wiphy,
				    struct wiphy_work *wk)
{}

void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
				const u8 *replay_ctr, gfp_t gfp)
{}
EXPORT_SYMBOL_GPL();

void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
			      int tid, struct ieee80211_key_seq *seq)
{}
EXPORT_SYMBOL();

void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
			      int tid, struct ieee80211_key_seq *seq)
{}
EXPORT_SYMBOL_GPL();

void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
{}
EXPORT_SYMBOL_GPL();

struct ieee80211_key_conf *
ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
			struct ieee80211_key_conf *keyconf,
			int link_id)
{}
EXPORT_SYMBOL_GPL();

void ieee80211_key_mic_failure(struct ieee80211_key_conf *keyconf)
{}
EXPORT_SYMBOL_GPL();

void ieee80211_key_replay(struct ieee80211_key_conf *keyconf)
{}
EXPORT_SYMBOL_GPL();

int ieee80211_key_switch_links(struct ieee80211_sub_if_data *sdata,
			       unsigned long del_links_mask,
			       unsigned long add_links_mask)
{}