| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2002-2004, Instant802 Networks, Inc. | 
|  | 3 | * Copyright 2005, Devicescape Software, Inc. | 
|  | 4 | * | 
|  | 5 | * This program is free software; you can redistribute it and/or modify | 
|  | 6 | * it under the terms of the GNU General Public License version 2 as | 
|  | 7 | * published by the Free Software Foundation. | 
|  | 8 | */ | 
|  | 9 |  | 
|  | 10 | #ifndef IEEE80211_KEY_H | 
|  | 11 | #define IEEE80211_KEY_H | 
|  | 12 |  | 
|  | 13 | #include <linux/types.h> | 
| Johannes Berg | 8f37171 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 14 | #include <linux/list.h> | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 15 | #include <linux/crypto.h> | 
|  | 16 | #include <net/mac80211.h> | 
|  | 17 |  | 
|  | 18 | /* ALG_TKIP | 
|  | 19 | * struct ieee80211_key::key is encoded as a 256-bit (32 byte) data block: | 
|  | 20 | * Temporal Encryption Key (128 bits) | 
|  | 21 | * Temporal Authenticator Tx MIC Key (64 bits) | 
|  | 22 | * Temporal Authenticator Rx MIC Key (64 bits) | 
|  | 23 | */ | 
|  | 24 |  | 
|  | 25 | #define WEP_IV_LEN 4 | 
|  | 26 | #define WEP_ICV_LEN 4 | 
|  | 27 |  | 
|  | 28 | #define ALG_TKIP_KEY_LEN 32 | 
|  | 29 | /* Starting offsets for each key */ | 
|  | 30 | #define ALG_TKIP_TEMP_ENCR_KEY 0 | 
|  | 31 | #define ALG_TKIP_TEMP_AUTH_TX_MIC_KEY 16 | 
|  | 32 | #define ALG_TKIP_TEMP_AUTH_RX_MIC_KEY 24 | 
|  | 33 | #define TKIP_IV_LEN 8 | 
|  | 34 | #define TKIP_ICV_LEN 4 | 
|  | 35 |  | 
|  | 36 | #define ALG_CCMP_KEY_LEN 16 | 
|  | 37 | #define CCMP_HDR_LEN 8 | 
|  | 38 | #define CCMP_MIC_LEN 8 | 
|  | 39 | #define CCMP_TK_LEN 16 | 
|  | 40 | #define CCMP_PN_LEN 6 | 
|  | 41 |  | 
|  | 42 | #define NUM_RX_DATA_QUEUES 17 | 
|  | 43 |  | 
| Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 44 | struct ieee80211_local; | 
|  | 45 | struct ieee80211_sub_if_data; | 
|  | 46 | struct sta_info; | 
|  | 47 |  | 
|  | 48 | #define KEY_FLAG_UPLOADED_TO_HARDWARE	(1<<0) | 
|  | 49 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 50 | struct ieee80211_key { | 
| Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 51 | struct ieee80211_local *local; | 
|  | 52 | struct ieee80211_sub_if_data *sdata; | 
|  | 53 | struct sta_info *sta; | 
|  | 54 |  | 
|  | 55 | struct list_head list; | 
|  | 56 |  | 
|  | 57 | unsigned int flags; | 
|  | 58 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 59 | union { | 
|  | 60 | struct { | 
|  | 61 | /* last used TSC */ | 
|  | 62 | u32 iv32; | 
|  | 63 | u16 iv16; | 
|  | 64 | u16 p1k[5]; | 
|  | 65 | int tx_initialized; | 
|  | 66 |  | 
|  | 67 | /* last received RSC */ | 
|  | 68 | u32 iv32_rx[NUM_RX_DATA_QUEUES]; | 
|  | 69 | u16 iv16_rx[NUM_RX_DATA_QUEUES]; | 
|  | 70 | u16 p1k_rx[NUM_RX_DATA_QUEUES][5]; | 
|  | 71 | int rx_initialized[NUM_RX_DATA_QUEUES]; | 
|  | 72 | } tkip; | 
|  | 73 | struct { | 
|  | 74 | u8 tx_pn[6]; | 
|  | 75 | u8 rx_pn[NUM_RX_DATA_QUEUES][6]; | 
|  | 76 | struct crypto_cipher *tfm; | 
|  | 77 | u32 replays; /* dot11RSNAStatsCCMPReplays */ | 
|  | 78 | /* scratch buffers for virt_to_page() (crypto API) */ | 
|  | 79 | #ifndef AES_BLOCK_LEN | 
|  | 80 | #define AES_BLOCK_LEN 16 | 
|  | 81 | #endif | 
|  | 82 | u8 tx_crypto_buf[6 * AES_BLOCK_LEN]; | 
|  | 83 | u8 rx_crypto_buf[6 * AES_BLOCK_LEN]; | 
|  | 84 | } ccmp; | 
|  | 85 | } u; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 86 |  | 
| Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 87 | /* number of times this key has been used */ | 
|  | 88 | int tx_rx_count; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 89 |  | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 90 | #ifdef CONFIG_MAC80211_DEBUGFS | 
|  | 91 | struct { | 
|  | 92 | struct dentry *stalink; | 
|  | 93 | struct dentry *dir; | 
|  | 94 | struct dentry *keylen; | 
| Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 95 | struct dentry *flags; | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 96 | struct dentry *keyidx; | 
|  | 97 | struct dentry *hw_key_idx; | 
|  | 98 | struct dentry *tx_rx_count; | 
|  | 99 | struct dentry *algorithm; | 
|  | 100 | struct dentry *tx_spec; | 
|  | 101 | struct dentry *rx_spec; | 
|  | 102 | struct dentry *replays; | 
|  | 103 | struct dentry *key; | 
| Johannes Berg | e7a64f1 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 104 | struct dentry *ifindex; | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 105 | } debugfs; | 
|  | 106 | #endif | 
|  | 107 |  | 
| Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 108 | /* | 
|  | 109 | * key config, must be last because it contains key | 
|  | 110 | * material as variable length member | 
|  | 111 | */ | 
|  | 112 | struct ieee80211_key_conf conf; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 113 | }; | 
|  | 114 |  | 
| Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 115 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | 
|  | 116 | struct sta_info *sta, | 
| Johannes Berg | ea49c35 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 117 | enum ieee80211_key_alg alg, | 
| Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 118 | int idx, | 
|  | 119 | size_t key_len, | 
|  | 120 | const u8 *key_data); | 
|  | 121 | void ieee80211_key_free(struct ieee80211_key *key); | 
|  | 122 | void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx); | 
|  | 123 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata); | 
|  | 124 | void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata); | 
|  | 125 | void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata); | 
|  | 126 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 127 | #endif /* IEEE80211_KEY_H */ |