Blame view

net/mac80211/key.h 3.85 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
ffd7891dc   Luis R. Rodriguez   mac80211: Let dri...
20
21
  #define WEP_IV_LEN		4
  #define WEP_ICV_LEN		4
ffd7891dc   Luis R. Rodriguez   mac80211: Let dri...
22
23
24
25
26
27
28
  #define ALG_CCMP_KEY_LEN	16
  #define CCMP_HDR_LEN		8
  #define CCMP_MIC_LEN		8
  #define CCMP_TK_LEN		16
  #define CCMP_PN_LEN		6
  #define TKIP_IV_LEN		8
  #define TKIP_ICV_LEN		4
3ea542d3c   Johannes Berg   mac80211: allow d...
29
  #define CMAC_PN_LEN		6
ffd7891dc   Luis R. Rodriguez   mac80211: Let dri...
30

9e26297a5   Johannes Berg   mac80211: simplif...
31
  #define NUM_RX_DATA_QUEUES	16
f0706e828   Jiri Benc   [MAC80211]: Add m...
32

11a843b7e   Johannes Berg   [MAC80211]: rewor...
33
34
35
  struct ieee80211_local;
  struct ieee80211_sub_if_data;
  struct sta_info;
db4d1169d   Johannes Berg   mac80211: split i...
36
37
38
39
40
  /**
   * 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...
41
   * @KEY_FLAG_TAINTED: Key is tainted and packets should be dropped.
db4d1169d   Johannes Berg   mac80211: split i...
42
43
44
   */
  enum ieee80211_internal_key_flags {
  	KEY_FLAG_UPLOADED_TO_HARDWARE	= BIT(0),
95acac61b   Johannes Berg   mac80211: allow d...
45
  	KEY_FLAG_TAINTED		= BIT(1),
db4d1169d   Johannes Berg   mac80211: split i...
46
  };
11a843b7e   Johannes Berg   [MAC80211]: rewor...
47

ca99861d5   gregor kowski   mac80211 : fix a ...
48
49
50
51
52
  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...
53
  struct tkip_ctx {
523b02ea2   Johannes Berg   mac80211: fix TKI...
54
55
56
57
  	u32 iv32;	/* current iv32 */
  	u16 iv16;	/* current iv16 */
  	u16 p1k[5];	/* p1k cache */
  	u32 p1k_iv32;	/* iv32 for which p1k computed */
ca99861d5   gregor kowski   mac80211 : fix a ...
58
  	enum ieee80211_internal_tkip_state state;
b0f76b335   Harvey Harrison   mac80211: add a s...
59
  };
f0706e828   Jiri Benc   [MAC80211]: Add m...
60
  struct ieee80211_key {
11a843b7e   Johannes Berg   [MAC80211]: rewor...
61
62
63
  	struct ieee80211_local *local;
  	struct ieee80211_sub_if_data *sdata;
  	struct sta_info *sta;
3b96766f0   Johannes Berg   mac80211: fix key...
64
  	/* for sdata list */
11a843b7e   Johannes Berg   [MAC80211]: rewor...
65
  	struct list_head list;
ad0e2b5a0   Johannes Berg   mac80211: simplif...
66
  	/* protected by key mutex */
11a843b7e   Johannes Berg   [MAC80211]: rewor...
67
  	unsigned int flags;
f0706e828   Jiri Benc   [MAC80211]: Add m...
68
69
  	union {
  		struct {
523b02ea2   Johannes Berg   mac80211: fix TKI...
70
71
  			/* protects tx context */
  			spinlock_t txlock;
f0706e828   Jiri Benc   [MAC80211]: Add m...
72
  			/* last used TSC */
b0f76b335   Harvey Harrison   mac80211: add a s...
73
  			struct tkip_ctx tx;
f0706e828   Jiri Benc   [MAC80211]: Add m...
74
75
  
  			/* last received RSC */
b0f76b335   Harvey Harrison   mac80211: add a s...
76
  			struct tkip_ctx rx[NUM_RX_DATA_QUEUES];
f0706e828   Jiri Benc   [MAC80211]: Add m...
77
78
  		} tkip;
  		struct {
aba83a0b3   Johannes Berg   mac80211: fix CCM...
79
  			atomic64_t tx_pn;
9190252c9   Jouni Malinen   mac80211: Use a s...
80
81
82
83
84
85
  			/*
  			 * Last received packet number. The first
  			 * NUM_RX_DATA_QUEUES counters are used with Data
  			 * frames and the last counter is used with Robust
  			 * Management frames.
  			 */
3ea542d3c   Johannes Berg   mac80211: allow d...
86
  			u8 rx_pn[NUM_RX_DATA_QUEUES + 1][CCMP_PN_LEN];
f0706e828   Jiri Benc   [MAC80211]: Add m...
87
88
  			struct crypto_cipher *tfm;
  			u32 replays; /* dot11RSNAStatsCCMPReplays */
f0706e828   Jiri Benc   [MAC80211]: Add m...
89
  		} ccmp;
765cb46a3   Jouni Malinen   mac80211: 802.11w...
90
  		struct {
75396ae6d   Johannes Berg   mac80211: fix CMA...
91
  			atomic64_t tx_pn;
3ea542d3c   Johannes Berg   mac80211: allow d...
92
  			u8 rx_pn[CMAC_PN_LEN];
765cb46a3   Jouni Malinen   mac80211: 802.11w...
93
94
95
  			struct crypto_cipher *tfm;
  			u32 replays; /* dot11RSNAStatsCMACReplays */
  			u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
765cb46a3   Jouni Malinen   mac80211: 802.11w...
96
  		} aes_cmac;
f0706e828   Jiri Benc   [MAC80211]: Add m...
97
  	} u;
f0706e828   Jiri Benc   [MAC80211]: Add m...
98

8f20fc249   Johannes Berg   [MAC80211]: embed...
99
100
  	/* number of times this key has been used */
  	int tx_rx_count;
f0706e828   Jiri Benc   [MAC80211]: Add m...
101

e9f207f0f   Jiri Benc   [MAC80211]: Add d...
102
103
104
105
  #ifdef CONFIG_MAC80211_DEBUGFS
  	struct {
  		struct dentry *stalink;
  		struct dentry *dir;
d9c58f30b   Johannes Berg   mac80211: fix key...
106
  		int cnt;
e9f207f0f   Jiri Benc   [MAC80211]: Add d...
107
108
  	} debugfs;
  #endif
8f20fc249   Johannes Berg   [MAC80211]: embed...
109
110
111
112
113
  	/*
  	 * 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...
114
  };
97359d123   Johannes Berg   mac80211: use cip...
115
  struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
faa8fdc85   Jouni Malinen   nl80211: Add RSC ...
116
117
  					  const u8 *key_data,
  					  size_t seq_len, const u8 *seq);
db4d1169d   Johannes Berg   mac80211: split i...
118
119
120
121
  /*
   * Insert a key into data structures (sdata, sta if necessary)
   * to make it used, free old key.
   */
3ffc2a905   Johannes Berg   mac80211: allow v...
122
123
124
  int __must_check ieee80211_key_link(struct ieee80211_key *key,
  				    struct ieee80211_sub_if_data *sdata,
  				    struct sta_info *sta);
5c0c36412   Johannes Berg   mac80211: make ke...
125
  void __ieee80211_key_free(struct ieee80211_key *key);
32162a4da   Jouni Malinen   mac80211: Fix key...
126
127
  void ieee80211_key_free(struct ieee80211_local *local,
  			struct ieee80211_key *key);
f7e0104c1   Johannes Berg   mac80211: support...
128
129
  void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
  			       bool uni, bool multi);
3cfcf6ac6   Jouni Malinen   mac80211: 802.11w...
130
131
  void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
  				    int idx);
11a843b7e   Johannes Berg   [MAC80211]: rewor...
132
133
134
  void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
  void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
  void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
40b275b69   Johannes Berg   mac80211: sparse ...
135
136
  #define key_mtx_dereference(local, ref) \
  	rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
f0706e828   Jiri Benc   [MAC80211]: Add m...
137
  #endif /* IEEE80211_KEY_H */