Blame view

net/mac80211/key.h 4.58 KB
f0706e828   Jiri Benc   [MAC80211]: Add m...
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   * Copyright 2002-2004, Instant802 Networks, Inc.
   * Copyright 2005, Devicescape Software, Inc.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #ifndef IEEE80211_KEY_H
  #define IEEE80211_KEY_H
  
  #include <linux/types.h>
8f37171a6   Johannes Berg   [MAC80211]: remov...
14
  #include <linux/list.h>
f0706e828   Jiri Benc   [MAC80211]: Add m...
15
  #include <linux/crypto.h>
db4d1169d   Johannes Berg   mac80211: split i...
16
  #include <linux/rcupdate.h>
f0706e828   Jiri Benc   [MAC80211]: Add m...
17
  #include <net/mac80211.h>
e31b82136   Johannes Berg   cfg80211/mac80211...
18
19
  #define NUM_DEFAULT_KEYS 4
  #define NUM_DEFAULT_MGMT_KEYS 2
11a843b7e   Johannes Berg   [MAC80211]: rewor...
20
21
22
  struct ieee80211_local;
  struct ieee80211_sub_if_data;
  struct sta_info;
db4d1169d   Johannes Berg   mac80211: split i...
23
24
25
26
27
  /**
   * enum ieee80211_internal_key_flags - internal key flags
   *
   * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present
   *	in the hardware for TX crypto hardware acceleration.
95acac61b   Johannes Berg   mac80211: allow d...
28
   * @KEY_FLAG_TAINTED: Key is tainted and packets should be dropped.
c7ef38e0c   Cedric Izoard   mac80211: Get IV ...
29
   * @KEY_FLAG_CIPHER_SCHEME: This key is for a hardware cipher scheme
db4d1169d   Johannes Berg   mac80211: split i...
30
31
32
   */
  enum ieee80211_internal_key_flags {
  	KEY_FLAG_UPLOADED_TO_HARDWARE	= BIT(0),
95acac61b   Johannes Berg   mac80211: allow d...
33
  	KEY_FLAG_TAINTED		= BIT(1),
c7ef38e0c   Cedric Izoard   mac80211: Get IV ...
34
  	KEY_FLAG_CIPHER_SCHEME		= BIT(2),
db4d1169d   Johannes Berg   mac80211: split i...
35
  };
11a843b7e   Johannes Berg   [MAC80211]: rewor...
36

ca99861d5   gregor kowski   mac80211 : fix a ...
37
38
39
40
41
  enum ieee80211_internal_tkip_state {
  	TKIP_STATE_NOT_INIT,
  	TKIP_STATE_PHASE1_DONE,
  	TKIP_STATE_PHASE1_HW_UPLOADED,
  };
b0f76b335   Harvey Harrison   mac80211: add a s...
42
  struct tkip_ctx {
523b02ea2   Johannes Berg   mac80211: fix TKI...
43
44
  	u16 p1k[5];	/* p1k cache */
  	u32 p1k_iv32;	/* iv32 for which p1k computed */
ca99861d5   gregor kowski   mac80211 : fix a ...
45
  	enum ieee80211_internal_tkip_state state;
b0f76b335   Harvey Harrison   mac80211: add a s...
46
  };
f8079d43c   Eliad Peller   mac80211: move TK...
47
48
49
50
51
  struct tkip_ctx_rx {
  	struct tkip_ctx ctx;
  	u32 iv32;	/* current iv32 */
  	u16 iv16;	/* current iv16 */
  };
f0706e828   Jiri Benc   [MAC80211]: Add m...
52
  struct ieee80211_key {
11a843b7e   Johannes Berg   [MAC80211]: rewor...
53
54
55
  	struct ieee80211_local *local;
  	struct ieee80211_sub_if_data *sdata;
  	struct sta_info *sta;
3b96766f0   Johannes Berg   mac80211: fix key...
56
  	/* for sdata list */
11a843b7e   Johannes Berg   [MAC80211]: rewor...
57
  	struct list_head list;
ad0e2b5a0   Johannes Berg   mac80211: simplif...
58
  	/* protected by key mutex */
11a843b7e   Johannes Berg   [MAC80211]: rewor...
59
  	unsigned int flags;
f0706e828   Jiri Benc   [MAC80211]: Add m...
60
61
  	union {
  		struct {
523b02ea2   Johannes Berg   mac80211: fix TKI...
62
63
  			/* protects tx context */
  			spinlock_t txlock;
f0706e828   Jiri Benc   [MAC80211]: Add m...
64
  			/* last used TSC */
b0f76b335   Harvey Harrison   mac80211: add a s...
65
  			struct tkip_ctx tx;
f0706e828   Jiri Benc   [MAC80211]: Add m...
66
67
  
  			/* last received RSC */
f8079d43c   Eliad Peller   mac80211: move TK...
68
  			struct tkip_ctx_rx rx[IEEE80211_NUM_TIDS];
b98ea0586   Saravana   mac80211: add deb...
69
70
71
  
  			/* number of mic failures */
  			u32 mic_failures;
f0706e828   Jiri Benc   [MAC80211]: Add m...
72
73
  		} tkip;
  		struct {
9190252c9   Jouni Malinen   mac80211: Use a s...
74
75
  			/*
  			 * Last received packet number. The first
5a306f588   Johannes Berg   mac80211: introdu...
76
  			 * IEEE80211_NUM_TIDS counters are used with Data
9190252c9   Jouni Malinen   mac80211: Use a s...
77
78
79
  			 * frames and the last counter is used with Robust
  			 * Management frames.
  			 */
4325f6caa   Johannes Berg   wireless: move cr...
80
  			u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN];
7ec7c4a9a   Ard Biesheuvel   mac80211: port CC...
81
  			struct crypto_aead *tfm;
f0706e828   Jiri Benc   [MAC80211]: Add m...
82
  			u32 replays; /* dot11RSNAStatsCCMPReplays */
f0706e828   Jiri Benc   [MAC80211]: Add m...
83
  		} ccmp;
765cb46a3   Jouni Malinen   mac80211: 802.11w...
84
  		struct {
4325f6caa   Johannes Berg   wireless: move cr...
85
  			u8 rx_pn[IEEE80211_CMAC_PN_LEN];
26717828b   Ard Biesheuvel   mac80211: aes-cma...
86
  			struct crypto_shash *tfm;
765cb46a3   Jouni Malinen   mac80211: 802.11w...
87
88
  			u32 replays; /* dot11RSNAStatsCMACReplays */
  			u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
765cb46a3   Jouni Malinen   mac80211: 802.11w...
89
  		} aes_cmac;
2475b1cc0   Max Stepanov   mac80211: add gen...
90
  		struct {
8ade538bf   Jouni Malinen   mac80111: Add BIP...
91
92
93
94
95
96
  			u8 rx_pn[IEEE80211_GMAC_PN_LEN];
  			struct crypto_aead *tfm;
  			u32 replays; /* dot11RSNAStatsCMACReplays */
  			u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
  		} aes_gmac;
  		struct {
00b9cfa3f   Jouni Malinen   mac80111: Add GCM...
97
98
99
100
101
102
103
104
105
106
  			/* Last received packet number. The first
  			 * IEEE80211_NUM_TIDS counters are used with Data
  			 * frames and the last counter is used with Robust
  			 * Management frames.
  			 */
  			u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_GCMP_PN_LEN];
  			struct crypto_aead *tfm;
  			u32 replays; /* dot11RSNAStatsGCMPReplays */
  		} gcmp;
  		struct {
2475b1cc0   Max Stepanov   mac80211: add gen...
107
  			/* generic cipher scheme */
a31cf1c69   Johannes Berg   mac80211: extend ...
108
  			u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_MAX_PN_LEN];
2475b1cc0   Max Stepanov   mac80211: add gen...
109
  		} gen;
f0706e828   Jiri Benc   [MAC80211]: Add m...
110
  	} u;
f0706e828   Jiri Benc   [MAC80211]: Add m...
111

e9f207f0f   Jiri Benc   [MAC80211]: Add d...
112
113
114
115
  #ifdef CONFIG_MAC80211_DEBUGFS
  	struct {
  		struct dentry *stalink;
  		struct dentry *dir;
d9c58f30b   Johannes Berg   mac80211: fix key...
116
  		int cnt;
e9f207f0f   Jiri Benc   [MAC80211]: Add d...
117
118
  	} debugfs;
  #endif
8f20fc249   Johannes Berg   [MAC80211]: embed...
119
120
121
122
123
  	/*
  	 * key config, must be last because it contains key
  	 * material as variable length member
  	 */
  	struct ieee80211_key_conf conf;
f0706e828   Jiri Benc   [MAC80211]: Add m...
124
  };
2475b1cc0   Max Stepanov   mac80211: add gen...
125
126
127
128
129
  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,
  		    const struct ieee80211_cipher_scheme *cs);
db4d1169d   Johannes Berg   mac80211: split i...
130
131
  /*
   * Insert a key into data structures (sdata, sta if necessary)
79cf2dfa3   Johannes Berg   mac80211: clean u...
132
   * to make it used, free old key. On failure, also free the new key.
db4d1169d   Johannes Berg   mac80211: split i...
133
   */
79cf2dfa3   Johannes Berg   mac80211: clean u...
134
135
136
  int ieee80211_key_link(struct ieee80211_key *key,
  		       struct ieee80211_sub_if_data *sdata,
  		       struct sta_info *sta);
3b8d9c290   Johannes Berg   mac80211: remove ...
137
  void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom);
79cf2dfa3   Johannes Berg   mac80211: clean u...
138
  void ieee80211_key_free_unused(struct ieee80211_key *key);
f7e0104c1   Johannes Berg   mac80211: support...
139
140
  void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
  			       bool uni, bool multi);
3cfcf6ac6   Jouni Malinen   mac80211: 802.11w...
141
142
  void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
  				    int idx);
7907c7d33   Johannes Berg   mac80211: free al...
143
144
  void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
  			 bool force_synchronize);
6d10e46be   Johannes Berg   mac80211: batch k...
145
146
  void ieee80211_free_sta_keys(struct ieee80211_local *local,
  			     struct sta_info *sta);
11a843b7e   Johannes Berg   [MAC80211]: rewor...
147
  void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
f9dca80b9   Michal Kazior   mac80211: fix AP_...
148
  void ieee80211_reset_crypto_tx_tailroom(struct ieee80211_sub_if_data *sdata);
11a843b7e   Johannes Berg   [MAC80211]: rewor...
149

40b275b69   Johannes Berg   mac80211: sparse ...
150
151
  #define key_mtx_dereference(local, ref) \
  	rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
8d1f7ecd2   Johannes Berg   mac80211: defer t...
152
  void ieee80211_delayed_tailroom_dec(struct work_struct *wk);
f0706e828   Jiri Benc   [MAC80211]: Add m...
153
  #endif /* IEEE80211_KEY_H */