key.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2004, Instant802 Networks, Inc.
00003  * Copyright 2005, Devicescape Software, Inc.
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  */
00009 
00010 #ifndef IEEE80211_KEY_H
00011 #define IEEE80211_KEY_H
00012 
00013 #include <linux/types.h>
00014 #include <linux/list.h>
00015 #include <linux/crypto.h>
00016 #include <linux/rcupdate.h>
00017 #include <net/mac80211.h>
00018 
00019 #define NUM_DEFAULT_KEYS 4
00020 #define NUM_DEFAULT_MGMT_KEYS 2
00021 
00022 #define WEP_IV_LEN              4
00023 #define WEP_ICV_LEN             4
00024 #define ALG_CCMP_KEY_LEN        16
00025 #define CCMP_HDR_LEN            8
00026 #define CCMP_MIC_LEN            8
00027 #define CCMP_TK_LEN             16
00028 #define CCMP_PN_LEN             6
00029 #define TKIP_IV_LEN             8
00030 #define TKIP_ICV_LEN            4
00031 #define CMAC_PN_LEN             6
00032 
00033 #define NUM_RX_DATA_QUEUES      16
00034 
00035 struct ieee80211_local;
00036 struct ieee80211_sub_if_data;
00037 struct sta_info;
00038 
00046 enum ieee80211_internal_key_flags {
00047         KEY_FLAG_UPLOADED_TO_HARDWARE   = BIT(0),
00048         KEY_FLAG_TAINTED                = BIT(1),
00049 };
00050 
00051 enum ieee80211_internal_tkip_state {
00052         TKIP_STATE_NOT_INIT,
00053         TKIP_STATE_PHASE1_DONE,
00054         TKIP_STATE_PHASE1_HW_UPLOADED,
00055 };
00056 
00057 struct tkip_ctx {
00058         u32 iv32;       /* current iv32 */
00059         u16 iv16;       /* current iv16 */
00060         u16 p1k[5];     /* p1k cache */
00061         u32 p1k_iv32;   /* iv32 for which p1k computed */
00062         enum ieee80211_internal_tkip_state state;
00063 };
00064 
00065 struct ieee80211_key {
00066         struct ieee80211_local *local;
00067         struct ieee80211_sub_if_data *sdata;
00068         struct sta_info *sta;
00069 
00070         /* for sdata list */
00071         struct list_head list;
00072 
00073         /* protected by key mutex */
00074         unsigned int flags;
00075 
00076         union {
00077                 struct {
00078                         /* protects tx context */
00079                         spinlock_t txlock;
00080 
00081                         /* last used TSC */
00082                         struct tkip_ctx tx;
00083 
00084                         /* last received RSC */
00085                         struct tkip_ctx rx[NUM_RX_DATA_QUEUES];
00086                 } tkip;
00087                 struct {
00088                         atomic64_t tx_pn;
00089                         /*
00090                          * Last received packet number. The first
00091                          * NUM_RX_DATA_QUEUES counters are used with Data
00092                          * frames and the last counter is used with Robust
00093                          * Management frames.
00094                          */
00095                         u8 rx_pn[NUM_RX_DATA_QUEUES + 1][CCMP_PN_LEN];
00096                         struct crypto_cipher *tfm;
00097                         u32 replays; /* dot11RSNAStatsCCMPReplays */
00098                 } ccmp;
00099                 struct {
00100                         atomic64_t tx_pn;
00101                         u8 rx_pn[CMAC_PN_LEN];
00102                         struct crypto_cipher *tfm;
00103                         u32 replays; /* dot11RSNAStatsCMACReplays */
00104                         u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
00105                 } aes_cmac;
00106         } u;
00107 
00108         /* number of times this key has been used */
00109         int tx_rx_count;
00110 
00111 #ifdef CONFIG_MAC80211_DEBUGFS
00112         struct {
00113                 struct dentry *stalink;
00114                 struct dentry *dir;
00115                 int cnt;
00116         } debugfs;
00117 #endif
00118 
00119         /*
00120          * key config, must be last because it contains key
00121          * material as variable length member
00122          */
00123         struct ieee80211_key_conf conf;
00124 };
00125 
00126 struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
00127                                           const u8 *key_data,
00128                                           size_t seq_len, const u8 *seq);
00129 /*
00130  * Insert a key into data structures (sdata, sta if necessary)
00131  * to make it used, free old key.
00132  */
00133 int __must_check ieee80211_key_link(struct ieee80211_key *key,
00134                                     struct ieee80211_sub_if_data *sdata,
00135                                     struct sta_info *sta);
00136 void __ieee80211_key_free(struct ieee80211_key *key);
00137 void ieee80211_key_free(struct ieee80211_local *local,
00138                         struct ieee80211_key *key);
00139 void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
00140                                bool uni, bool multi);
00141 void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
00142                                     int idx);
00143 void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
00144 void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
00145 void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
00146 
00147 #define key_mtx_dereference(local, ref) \
00148         rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
00149 
00150 #endif /* IEEE80211_KEY_H */


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:10