eapol_auth_sm_i.h revision 04949598a23f501be6eec21697465fd46a28840a
11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)/*
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * IEEE 802.1X-2004 Authenticator - EAPOL state machine (internal definitions)
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) *
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * This software may be distributed under the terms of the BSD license.
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * See README for more details.
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) */
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef EAPOL_AUTH_SM_I_H
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define EAPOL_AUTH_SM_I_H
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "common/defs.h"
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "radius/radius.h"
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)/* IEEE Std 802.1X-2004, Ch. 8.2 */
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)typedef enum { ForceUnauthorized = 1, ForceAuthorized = 3, Auto = 2 }
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	PortTypes;
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)typedef enum { Unauthorized = 2, Authorized = 1 } PortState;
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)typedef enum { Both = 0, In = 1 } ControlledDirection;
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)typedef unsigned int Counter;
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)/**
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * struct eapol_authenticator - Global EAPOL authenticator data
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) */
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)struct eapol_authenticator {
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	struct eapol_auth_config conf;
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	struct eapol_auth_cb cb;
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	u8 *default_wep_key;
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	u8 default_wep_key_idx;
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)/**
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) * struct eapol_state_machine - Per-Supplicant Authenticator state machines
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) */
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)struct eapol_state_machine {
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	/* timers */
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	int aWhile;
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	int quietWhile;
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	int reAuthWhen;
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	/* global variables */
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	Boolean authAbort;
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	Boolean authFail;
481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	PortState authPortStatus;
491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	Boolean authStart;
50	Boolean authTimeout;
51	Boolean authSuccess;
52	Boolean eapolEap;
53	Boolean initialize;
54	Boolean keyDone;
55	Boolean keyRun;
56	Boolean keyTxEnabled;
57	PortTypes portControl;
58	Boolean portValid;
59	Boolean reAuthenticate;
60
61	/* Port Timers state machine */
62	/* 'Boolean tick' implicitly handled as registered timeout */
63
64	/* Authenticator PAE state machine */
65	enum { AUTH_PAE_INITIALIZE, AUTH_PAE_DISCONNECTED, AUTH_PAE_CONNECTING,
66	       AUTH_PAE_AUTHENTICATING, AUTH_PAE_AUTHENTICATED,
67	       AUTH_PAE_ABORTING, AUTH_PAE_HELD, AUTH_PAE_FORCE_AUTH,
68	       AUTH_PAE_FORCE_UNAUTH, AUTH_PAE_RESTART } auth_pae_state;
69	/* variables */
70	Boolean eapolLogoff;
71	Boolean eapolStart;
72	PortTypes portMode;
73	unsigned int reAuthCount;
74	/* constants */
75	unsigned int quietPeriod; /* default 60; 0..65535 */
76#define AUTH_PAE_DEFAULT_quietPeriod 60
77	unsigned int reAuthMax; /* default 2 */
78#define AUTH_PAE_DEFAULT_reAuthMax 2
79	/* counters */
80	Counter authEntersConnecting;
81	Counter authEapLogoffsWhileConnecting;
82	Counter authEntersAuthenticating;
83	Counter authAuthSuccessesWhileAuthenticating;
84	Counter authAuthTimeoutsWhileAuthenticating;
85	Counter authAuthFailWhileAuthenticating;
86	Counter authAuthEapStartsWhileAuthenticating;
87	Counter authAuthEapLogoffWhileAuthenticating;
88	Counter authAuthReauthsWhileAuthenticated;
89	Counter authAuthEapStartsWhileAuthenticated;
90	Counter authAuthEapLogoffWhileAuthenticated;
91
92	/* Backend Authentication state machine */
93	enum { BE_AUTH_REQUEST, BE_AUTH_RESPONSE, BE_AUTH_SUCCESS,
94	       BE_AUTH_FAIL, BE_AUTH_TIMEOUT, BE_AUTH_IDLE, BE_AUTH_INITIALIZE,
95	       BE_AUTH_IGNORE
96	} be_auth_state;
97	/* constants */
98	unsigned int serverTimeout; /* default 30; 1..X */
99#define BE_AUTH_DEFAULT_serverTimeout 30
100	/* counters */
101	Counter backendResponses;
102	Counter backendAccessChallenges;
103	Counter backendOtherRequestsToSupplicant;
104	Counter backendAuthSuccesses;
105	Counter backendAuthFails;
106
107	/* Reauthentication Timer state machine */
108	enum { REAUTH_TIMER_INITIALIZE, REAUTH_TIMER_REAUTHENTICATE
109	} reauth_timer_state;
110	/* constants */
111	unsigned int reAuthPeriod; /* default 3600 s */
112	Boolean reAuthEnabled;
113
114	/* Authenticator Key Transmit state machine */
115	enum { AUTH_KEY_TX_NO_KEY_TRANSMIT, AUTH_KEY_TX_KEY_TRANSMIT
116	} auth_key_tx_state;
117
118	/* Key Receive state machine */
119	enum { KEY_RX_NO_KEY_RECEIVE, KEY_RX_KEY_RECEIVE } key_rx_state;
120	/* variables */
121	Boolean rxKey;
122
123	/* Controlled Directions state machine */
124	enum { CTRL_DIR_FORCE_BOTH, CTRL_DIR_IN_OR_BOTH } ctrl_dir_state;
125	/* variables */
126	ControlledDirection adminControlledDirections;
127	ControlledDirection operControlledDirections;
128	Boolean operEdge;
129
130	/* Authenticator Statistics Table */
131	Counter dot1xAuthEapolFramesRx;
132	Counter dot1xAuthEapolFramesTx;
133	Counter dot1xAuthEapolStartFramesRx;
134	Counter dot1xAuthEapolLogoffFramesRx;
135	Counter dot1xAuthEapolRespIdFramesRx;
136	Counter dot1xAuthEapolRespFramesRx;
137	Counter dot1xAuthEapolReqIdFramesTx;
138	Counter dot1xAuthEapolReqFramesTx;
139	Counter dot1xAuthInvalidEapolFramesRx;
140	Counter dot1xAuthEapLengthErrorFramesRx;
141	Counter dot1xAuthLastEapolFrameVersion;
142
143	/* Other variables - not defined in IEEE 802.1X */
144	u8 addr[ETH_ALEN]; /* Supplicant address */
145	int flags; /* EAPOL_SM_* */
146
147	/* EAPOL/AAA <-> EAP full authenticator interface */
148	struct eap_eapol_interface *eap_if;
149
150	int radius_identifier;
151	/* TODO: check when the last messages can be released */
152	struct radius_msg *last_recv_radius;
153	u8 last_eap_id; /* last used EAP Identifier */
154	u8 *identity;
155	size_t identity_len;
156	u8 eap_type_authsrv; /* EAP type of the last EAP packet from
157			      * Authentication server */
158	u8 eap_type_supp; /* EAP type of the last EAP packet from Supplicant */
159	struct radius_class_data radius_class;
160	struct wpabuf *radius_cui; /* Chargeable-User-Identity */
161
162	/* Keys for encrypting and signing EAPOL-Key frames */
163	u8 *eapol_key_sign;
164	size_t eapol_key_sign_len;
165	u8 *eapol_key_crypt;
166	size_t eapol_key_crypt_len;
167
168	struct eap_sm *eap;
169
170	Boolean initializing; /* in process of initializing state machines */
171	Boolean changed;
172
173	struct eapol_authenticator *eapol;
174
175	void *sta; /* station context pointer to use in callbacks */
176};
177
178#endif /* EAPOL_AUTH_SM_I_H */
179