2 * wpa_supplicant - Internal WPA state machine definitions
3 * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #define WPA_NONCE_LEN 32
19 #define WPA_REPLAY_COUNTER_LEN 8
22 struct rsn_pmksa_candidate
;
25 * struct wpa_ptk - WPA Pairwise Transient Key
26 * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
29 u8 kck
[16]; /* EAPOL-Key Key Confirmation Key (KCK) */
30 u8 kek
[16]; /* EAPOL-Key Key Encryption Key (KEK) */
31 u8 tk1
[16]; /* Temporal Key 1 (TK1) */
33 u8 tk2
[16]; /* Temporal Key 2 (TK2) */
39 } __attribute__ ((packed
));
43 * struct rsn_pmksa_cache - PMKSA cache entry
45 struct rsn_pmksa_cache
{
46 struct rsn_pmksa_cache
*next
;
52 int akmp
; /* WPA_KEY_MGMT_* */
54 struct wpa_ssid
*ssid
;
60 * struct wpa_sm - Internal WPA state machine data
65 struct wpa_ptk ptk
, tptk
;
66 int ptk_set
, tptk_set
;
67 u8 snonce
[WPA_NONCE_LEN
];
68 u8 anonce
[WPA_NONCE_LEN
]; /* ANonce from the last 1/4 msg */
70 u8 rx_replay_counter
[WPA_REPLAY_COUNTER_LEN
];
71 int rx_replay_counter_set
;
72 u8 request_counter
[WPA_REPLAY_COUNTER_LEN
];
74 struct eapol_sm
*eapol
; /* EAPOL state machine from upper level code */
76 struct rsn_pmksa_cache
*pmksa
; /* PMKSA cache */
77 struct rsn_pmksa_cache
*cur_pmksa
; /* current PMKSA entry */
78 int pmksa_count
; /* number of entries in PMKSA cache */
79 struct rsn_pmksa_candidate
*pmksa_candidates
;
81 struct l2_packet_data
*l2_preauth
;
82 u8 preauth_bssid
[ETH_ALEN
]; /* current RSN pre-auth peer or
83 * 00:00:00:00:00:00 if no pre-auth is
85 struct eapol_sm
*preauth_eapol
;
87 struct wpa_sm_ctx
*ctx
;
89 void *scard_ctx
; /* context for smartcard callbacks */
90 int fast_reauth
; /* whether EAP fast re-authentication is enabled */
92 struct wpa_ssid
*cur_ssid
;
94 u8 own_addr
[ETH_ALEN
];
98 unsigned int dot11RSNAConfigPMKLifetime
;
99 unsigned int dot11RSNAConfigPMKReauthThreshold
;
100 unsigned int dot11RSNAConfigSATimeout
;
102 unsigned int dot11RSNA4WayHandshakeFailures
;
104 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
106 unsigned int pairwise_cipher
;
107 unsigned int group_cipher
;
108 unsigned int key_mgmt
;
110 u8
*assoc_wpa_ie
; /* Own WPA/RSN IE from (Re)AssocReq */
111 size_t assoc_wpa_ie_len
;
112 u8
*ap_wpa_ie
, *ap_rsn_ie
;
113 size_t ap_wpa_ie_len
, ap_rsn_ie_len
;
117 static inline void wpa_sm_set_state(struct wpa_sm
*sm
, wpa_states state
)
119 sm
->ctx
->set_state(sm
->ctx
->ctx
, state
);
122 static inline wpa_states
wpa_sm_get_state(struct wpa_sm
*sm
)
124 return sm
->ctx
->get_state(sm
->ctx
->ctx
);
127 static inline void wpa_sm_req_scan(struct wpa_sm
*sm
, int sec
, int usec
)
129 sm
->ctx
->req_scan(sm
->ctx
->ctx
, sec
, usec
);
132 static inline void wpa_sm_deauthenticate(struct wpa_sm
*sm
, int reason_code
)
134 sm
->ctx
->deauthenticate(sm
->ctx
->ctx
, reason_code
);
137 static inline void wpa_sm_disassociate(struct wpa_sm
*sm
, int reason_code
)
139 sm
->ctx
->disassociate(sm
->ctx
->ctx
, reason_code
);
142 static inline int wpa_sm_set_key(struct wpa_sm
*sm
, wpa_alg alg
,
143 const u8
*addr
, int key_idx
, int set_tx
,
144 const u8
*seq
, size_t seq_len
,
145 const u8
*key
, size_t key_len
)
147 return sm
->ctx
->set_key(sm
->ctx
->ctx
, alg
, addr
, key_idx
, set_tx
,
148 seq
, seq_len
, key
, key_len
);
151 static inline struct wpa_ssid
* wpa_sm_get_ssid(struct wpa_sm
*sm
)
153 return sm
->ctx
->get_ssid(sm
->ctx
->ctx
);
156 static inline int wpa_sm_get_bssid(struct wpa_sm
*sm
, u8
*bssid
)
158 return sm
->ctx
->get_bssid(sm
->ctx
->ctx
, bssid
);
161 static inline int wpa_sm_ether_send(struct wpa_sm
*sm
, const u8
*dest
,
162 u16 proto
, const u8
*buf
, size_t len
)
164 return sm
->ctx
->ether_send(sm
->ctx
->ctx
, dest
, proto
, buf
, len
);
167 static inline int wpa_sm_get_beacon_ie(struct wpa_sm
*sm
)
169 return sm
->ctx
->get_beacon_ie(sm
->ctx
->ctx
);
172 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm
*sm
)
174 sm
->ctx
->cancel_auth_timeout(sm
->ctx
->ctx
);
177 static inline u8
* wpa_sm_alloc_eapol(struct wpa_sm
*sm
, u8 type
,
178 const void *data
, u16 data_len
,
179 size_t *msg_len
, void **data_pos
)
181 return sm
->ctx
->alloc_eapol(sm
->ctx
->ctx
, type
, data
, data_len
,
185 static inline int wpa_sm_add_pmkid(struct wpa_sm
*sm
, const u8
*bssid
,
188 return sm
->ctx
->add_pmkid(sm
->ctx
->ctx
, bssid
, pmkid
);
191 static inline int wpa_sm_remove_pmkid(struct wpa_sm
*sm
, const u8
*bssid
,
194 return sm
->ctx
->remove_pmkid(sm
->ctx
->ctx
, bssid
, pmkid
);