0001
0002
0003
0004
0005
0006
0007
0008 #ifndef IEEE80211_KEY_H
0009 #define IEEE80211_KEY_H
0010
0011 #include <linux/types.h>
0012 #include <linux/list.h>
0013 #include <linux/crypto.h>
0014 #include <linux/rcupdate.h>
0015 #include <crypto/arc4.h>
0016 #include <net/mac80211.h>
0017
0018 #define NUM_DEFAULT_KEYS 4
0019 #define NUM_DEFAULT_MGMT_KEYS 2
0020 #define NUM_DEFAULT_BEACON_KEYS 2
0021 #define INVALID_PTK_KEYIDX 2
0022
0023 struct ieee80211_local;
0024 struct ieee80211_sub_if_data;
0025 struct sta_info;
0026
0027
0028
0029
0030
0031
0032
0033
0034 enum ieee80211_internal_key_flags {
0035 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0),
0036 KEY_FLAG_TAINTED = BIT(1),
0037 };
0038
0039 enum ieee80211_internal_tkip_state {
0040 TKIP_STATE_NOT_INIT,
0041 TKIP_STATE_PHASE1_DONE,
0042 TKIP_STATE_PHASE1_HW_UPLOADED,
0043 };
0044
0045 struct tkip_ctx {
0046 u16 p1k[5];
0047 u32 p1k_iv32;
0048 enum ieee80211_internal_tkip_state state;
0049 };
0050
0051 struct tkip_ctx_rx {
0052 struct tkip_ctx ctx;
0053 u32 iv32;
0054 u16 iv16;
0055 };
0056
0057 struct ieee80211_key {
0058 struct ieee80211_local *local;
0059 struct ieee80211_sub_if_data *sdata;
0060 struct sta_info *sta;
0061
0062
0063 struct list_head list;
0064
0065
0066 unsigned int flags;
0067
0068 union {
0069 struct {
0070
0071 spinlock_t txlock;
0072
0073
0074 struct tkip_ctx tx;
0075
0076
0077 struct tkip_ctx_rx rx[IEEE80211_NUM_TIDS];
0078
0079
0080 u32 mic_failures;
0081 } tkip;
0082 struct {
0083
0084
0085
0086
0087
0088
0089 u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN];
0090 struct crypto_aead *tfm;
0091 u32 replays;
0092 } ccmp;
0093 struct {
0094 u8 rx_pn[IEEE80211_CMAC_PN_LEN];
0095 struct crypto_shash *tfm;
0096 u32 replays;
0097 u32 icverrors;
0098 } aes_cmac;
0099 struct {
0100 u8 rx_pn[IEEE80211_GMAC_PN_LEN];
0101 struct crypto_aead *tfm;
0102 u32 replays;
0103 u32 icverrors;
0104 } aes_gmac;
0105 struct {
0106
0107
0108
0109
0110
0111 u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_GCMP_PN_LEN];
0112 struct crypto_aead *tfm;
0113 u32 replays;
0114 } gcmp;
0115 struct {
0116
0117 u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_MAX_PN_LEN];
0118 } gen;
0119 } u;
0120
0121 #ifdef CONFIG_MAC80211_DEBUGFS
0122 struct {
0123 struct dentry *stalink;
0124 struct dentry *dir;
0125 int cnt;
0126 } debugfs;
0127 #endif
0128
0129 unsigned int color;
0130
0131
0132
0133
0134
0135 struct ieee80211_key_conf conf;
0136 };
0137
0138 struct ieee80211_key *
0139 ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
0140 const u8 *key_data,
0141 size_t seq_len, const u8 *seq);
0142
0143
0144
0145
0146 int ieee80211_key_link(struct ieee80211_key *key,
0147 struct ieee80211_sub_if_data *sdata,
0148 struct sta_info *sta);
0149 int ieee80211_set_tx_key(struct ieee80211_key *key);
0150 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom);
0151 void ieee80211_key_free_unused(struct ieee80211_key *key);
0152 void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
0153 bool uni, bool multi);
0154 void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
0155 int idx);
0156 void ieee80211_set_default_beacon_key(struct ieee80211_sub_if_data *sdata,
0157 int idx);
0158 void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
0159 bool force_synchronize);
0160 void ieee80211_free_sta_keys(struct ieee80211_local *local,
0161 struct sta_info *sta);
0162 void ieee80211_reenable_keys(struct ieee80211_sub_if_data *sdata);
0163
0164 #define key_mtx_dereference(local, ref) \
0165 rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
0166 #define rcu_dereference_check_key_mtx(local, ref) \
0167 rcu_dereference_check(ref, lockdep_is_held(&((local)->key_mtx)))
0168
0169 void ieee80211_delayed_tailroom_dec(struct work_struct *wk);
0170
0171 #endif