authenticator.h
Go to the documentation of this file.
1 /**
2  * @file authenticator.h
3  * @brief 802.1X authenticator
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneEAP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _AUTHENTICATOR_H
32 #define _AUTHENTICATOR_H
33 
34 //Forward declaration of AuthenticatorContext structure
36 #define AuthenticatorContext struct _AuthenticatorContext
37 
38 //Forward declaration of AuthenticatorPort structure
39 struct _AuthenticatorPort;
40 #define AuthenticatorPort struct _AuthenticatorPort
41 
42 //Dependencies
43 #include "eap/eap.h"
44 #include "eap/eap_full_auth_fsm.h"
48 #include "mac/hmac.h"
49 
50 //802.1X authenticator support
51 #ifndef AUTHENTICATOR_SUPPORT
52  #define AUTHENTICATOR_SUPPORT ENABLED
53 #elif (AUTHENTICATOR_SUPPORT != ENABLED && AUTHENTICATOR_SUPPORT != DISABLED)
54  #error AUTHENTICATOR_SUPPORT parameter is not valid
55 #endif
56 
57 //Stack size required to run the 802.1X authenticator
58 #ifndef AUTHENTICATOR_STACK_SIZE
59  #define AUTHENTICATOR_STACK_SIZE 750
60 #elif (AUTHENTICATOR_STACK_SIZE < 1)
61  #error AUTHENTICATOR_STACK_SIZE parameter is not valid
62 #endif
63 
64 //Priority at which the 802.1X authenticator should run
65 #ifndef AUTHENTICATOR_PRIORITY
66  #define AUTHENTICATOR_PRIORITY OS_TASK_PRIORITY_NORMAL
67 #endif
68 
69 //802.1X authenticator tick interval (in milliseconds)
70 #ifndef AUTHENTICATOR_TICK_INTERVAL
71  #define AUTHENTICATOR_TICK_INTERVAL 1000
72 #elif (AUTHENTICATOR_TICK_INTERVAL < 10)
73  #error AUTHENTICATOR_TICK_INTERVAL parameter is not valid
74 #endif
75 
76 //Size of the transmission buffer
77 #ifndef AUTHENTICATOR_TX_BUFFER_SIZE
78  #define AUTHENTICATOR_TX_BUFFER_SIZE 1500
79 #elif (AUTHENTICATOR_TX_BUFFER_SIZE < 1)
80  #error AUTHENTICATOR_TX_BUFFER_SIZE parameter is not valid
81 #endif
82 
83 //Size of the reception buffer
84 #ifndef AUTHENTICATOR_RX_BUFFER_SIZE
85  #define AUTHENTICATOR_RX_BUFFER_SIZE 1500
86 #elif (AUTHENTICATOR_RX_BUFFER_SIZE < 1)
87  #error AUTHENTICATOR_RX_BUFFER_SIZE parameter is not valid
88 #endif
89 
90 //Maximum length of the RADIUS server's key
91 #ifndef AUTHENTICATOR_MAX_SERVER_KEY_LEN
92  #define AUTHENTICATOR_MAX_SERVER_KEY_LEN 64
93 #elif (AUTHENTICATOR_MAX_SERVER_KEY_LEN < 1)
94  #error AUTHENTICATOR_MAX_SERVER_KEY_LEN parameter is not valid
95 #endif
96 
97 //Default value for the quietPeriod parameter
98 #ifndef AUTHENTICATOR_DEFAULT_QUIET_PERIOD
99  #define AUTHENTICATOR_DEFAULT_QUIET_PERIOD 60
100 #elif (AUTHENTICATOR_DEFAULT_QUIET_PERIOD < 0)
101  #error AUTHENTICATOR_DEFAULT_QUIET_PERIOD parameter is not valid
102 #endif
103 
104 //Maximum acceptable value for the quietPeriod parameter
105 #ifndef AUTHENTICATOR_MAX_QUIET_PERIOD
106  #define AUTHENTICATOR_MAX_QUIET_PERIOD 65535
107 #elif (AUTHENTICATOR_MAX_QUIET_PERIOD < AUTHENTICATOR_DEFAULT_QUIET_PERIOD)
108  #error AUTHENTICATOR_MAX_QUIET_PERIOD parameter is not valid
109 #endif
110 
111 //Maximum number of reauthentication attempts
112 #ifndef AUTHENTICATOR_DEFAULT_REAUTH_MAX
113  #define AUTHENTICATOR_DEFAULT_REAUTH_MAX 2
114 #elif (AUTHENTICATOR_DEFAULT_REAUTH_MAX < 0)
115  #error AUTHENTICATOR_DEFAULT_REAUTH_MAX parameter is not valid
116 #endif
117 
118 //Minimum acceptable value for the serverTimeout parameter
119 #ifndef AUTHENTICATOR_MIN_SERVER_TIMEOUT
120  #define AUTHENTICATOR_MIN_SERVER_TIMEOUT 1
121 #elif (AUTHENTICATOR_MIN_SERVER_TIMEOUT < 0)
122  #error AUTHENTICATOR_MIN_SERVER_TIMEOUT parameter is not valid
123 #endif
124 
125 //Default value for the serverTimeout parameter
126 #ifndef AUTHENTICATOR_DEFAULT_SERVER_TIMEOUT
127  #define AUTHENTICATOR_DEFAULT_SERVER_TIMEOUT 30
128 #elif (AUTHENTICATOR_DEFAULT_SERVER_TIMEOUT < AUTHENTICATOR_MIN_SERVER_TIMEOUT)
129  #error AUTHENTICATOR_DEFAULT_SERVER_TIMEOUT parameter is not valid
130 #endif
131 
132 //Maximum acceptable value for the serverTimeout parameter
133 #ifndef AUTHENTICATOR_MAX_SERVER_TIMEOUT
134  #define AUTHENTICATOR_MAX_SERVER_TIMEOUT 3600
135 #elif (AUTHENTICATOR_MAX_SERVER_TIMEOUT < AUTHENTICATOR_DEFAULT_SERVER_TIMEOUT)
136  #error AUTHENTICATOR_MAX_SERVER_TIMEOUT parameter is not valid
137 #endif
138 
139 //Maximum number of retransmissions before aborting
140 #ifndef AUTHENTICATOR_DEFAULT_MAX_RETRANS
141  #define AUTHENTICATOR_DEFAULT_MAX_RETRANS 4
142 #elif (AUTHENTICATOR_DEFAULT_MAX_RETRANS < 0)
143  #error AUTHENTICATOR_DEFAULT_MAX_RETRANS parameter is not valid
144 #endif
145 
146 //Minimum acceptable value for the reAuthPeriod parameter
147 #ifndef AUTHENTICATOR_MIN_REAUTH_PERIOD
148  #define AUTHENTICATOR_MIN_REAUTH_PERIOD 10
149 #elif (AUTHENTICATOR_MIN_REAUTH_PERIOD < 0)
150  #error AUTHENTICATOR_MIN_REAUTH_PERIOD parameter is not valid
151 #endif
152 
153 //Default value for the reAuthPeriod parameter
154 #ifndef AUTHENTICATOR_DEFAULT_REAUTH_PERIOD
155  #define AUTHENTICATOR_DEFAULT_REAUTH_PERIOD 3600
156 #elif (AUTHENTICATOR_DEFAULT_REAUTH_PERIOD < AUTHENTICATOR_MIN_REAUTH_PERIOD)
157  #error AUTHENTICATOR_DEFAULT_REAUTH_PERIOD parameter is not valid
158 #endif
159 
160 //Maximum acceptable value for the reAuthPeriod parameter
161 #ifndef AUTHENTICATOR_MAX_REAUTH_PERIOD
162  #define AUTHENTICATOR_MAX_REAUTH_PERIOD 86400
163 #elif (AUTHENTICATOR_MAX_REAUTH_PERIOD < AUTHENTICATOR_DEFAULT_REAUTH_PERIOD)
164  #error AUTHENTICATOR_MAX_REAUTH_PERIOD parameter is not valid
165 #endif
166 
167 //Maximum length of identity
168 #ifndef AUTHENTICATOR_MAX_ID_LEN
169  #define AUTHENTICATOR_MAX_ID_LEN 64
170 #elif (AUTHENTICATOR_MAX_ID_LEN < 1)
171  #error AUTHENTICATOR_MAX_ID_LEN parameter is not valid
172 #endif
173 
174 //Maximum length of State attribute
175 #ifndef AUTHENTICATOR_MAX_STATE_SIZE
176  #define AUTHENTICATOR_MAX_STATE_SIZE 64
177 #elif (AUTHENTICATOR_MAX_STATE_SIZE < 1)
178  #error AUTHENTICATOR_MAX_STATE_SIZE parameter is not valid
179 #endif
180 
181 //Method timeout
182 #ifndef AUTHENTICATOR_DEFAULT_METHOD_TIMEOUT
183  #define AUTHENTICATOR_DEFAULT_METHOD_TIMEOUT 5
184 #elif (AUTHENTICATOR_DEFAULT_METHOD_TIMEOUT < 0)
185  #error AUTHENTICATOR_DEFAULT_METHOD_TIMEOUT parameter is not valid
186 #endif
187 
188 //Maximum number of retransmissions of RADIUS requests
189 #ifndef AUTHENTICATOR_MAX_RADIUS_RETRANS
190  #define AUTHENTICATOR_MAX_RADIUS_RETRANS 4
191 #elif (AUTHENTICATOR_MAX_RADIUS_RETRANS < 0)
192  #error AUTHENTICATOR_MAX_RADIUS_RETRANS parameter is not valid
193 #endif
194 
195 //RADIUS response timeout
196 #ifndef AUTHENTICATOR_RADIUS_TIMEOUT
197  #define AUTHENTICATOR_RADIUS_TIMEOUT 5
198 #elif (AUTHENTICATOR_RADIUS_TIMEOUT < 0)
199  #error AUTHENTICATOR_RADIUS_TIMEOUT parameter is not valid
200 #endif
201 
202 //C++ guard
203 #ifdef __cplusplus
204 extern "C" {
205 #endif
206 
207 
208 /**
209  * @brief Session terminate cause
210  **/
211 
212 typedef enum
213 {
223 
224 
225 /**
226  * @brief Authenticator PAE state change callback function
227  **/
228 
230  AuthenticatorPaeState state);
231 
232 
233 /**
234  * @brief Backend authentication state change callback function
235  **/
236 
239 
240 
241 /**
242  * @brief Reauthentication timer state change callback function
243  **/
244 
247 
248 
249 /**
250  * @brief EAP full authenticator state change callback function
251  **/
252 
254  EapFullAuthState state);
255 
256 
257 /**
258  * @brief Tick callback function
259  **/
260 
262 
263 
264 /**
265  * @brief Statistics information
266  **/
267 
268 typedef struct
269 {
270  uint32_t eapolFramesRx;
271  uint32_t eapolFramesTx;
282 
283 
284 /**
285  * @brief Session statistics information
286  **/
287 
288 typedef struct
289 {
290  uint64_t sessionOctetsRx;
291  uint64_t sessionOctetsTx;
292  uint32_t sessionFramesRx;
293  uint32_t sessionFramesTx;
294  uint32_t sessionTime;
297 
298 
299 /**
300  * @brief Port context
301  **/
302 
304 {
305  AuthenticatorContext *context; ///<802.1X authenticator context
306  uint8_t portIndex; ///<Port index
307  MacAddr macAddr; ///<MAC address of the port
308 
309  AuthenticatorPaeState authPaeState; ///<Authenticator PAE state
310  AuthenticatorBackendState authBackendState; ///<Backend authentication state
311  AuthenticatorReauthTimerState reauthTimerState; ///<Reauthentication timer state
312 
313  uint_t aWhile; ///<Timer used by the backend authentication state machine (8.2.2.1 a)
314  uint_t quietWhile; ///<Timer used by the authenticator PAE state machine (8.2.2.1 d)
315  uint_t reAuthWhen; ///<Timer used to determine when reauthentication takes place (8.2.2.1 e)
316 
317  bool_t authAbort; ///<Abort authentication procedure (8.2.2.2 a)
318  bool_t authFail; ///<Authentication process has failed (8.2.2.2 b)
319  AuthenticatorPortStatus authPortStatus; ///<Current authorization state of the authenticator PAE state machine (8.2.2.2 c)
320  bool_t authStart; ///Start authentication procedure (8.2.2.2 d)
321  bool_t authTimeout; ///<Failed to obtain a response from the supplicant(8.2.2.2 e)
322  bool_t authSuccess; ///<Successful authentication process (8.2.2.2 f)
323  bool_t eapFail; ///<The authentication has failed (8.2.2.2 g)
324  bool_t eapolEap; ///<EAPOL PDU carrying a packet Type of EAP-Packet is received (8.2.2.2 h)
325  bool_t eapSuccess; ///<The authentication process succeeds (8.2.2.2 i)
326  bool_t eapTimeout; ///<The supplicant is not responding to requests (8.2.2.2 j)
327 
328  bool_t initialize; ///<Forces all EAPOL state machines to their initial state (8.2.2.2 k)
329  bool_t keyDone; ///<This variable is set by the key machine (8.2.2.2 m)
330  bool_t keyRun; ///<Run transmit key machine (8.2.2.2 n)
331  AuthenticatorPortMode portControl; ///<Port control (8.2.2.2 p)
332  bool_t portEnabled; ///<Operational state of the port (8.2.2.2 q)
333  bool_t portValid; ///<The value of this variable is set externally (8.2.2.2 s)
334  bool_t reAuthenticate; ///<The reAuthWhen timer has expired (8.2.2.2 t)
335 
336  bool_t eapolLogoff; ///<EAPOL-Logoff received (8.2.4.1.1 a)
337  bool_t eapolStart; ///<EAPOL-Start received (8.2.4.1.1 b)
338  bool_t eapRestart; ///<Restart Authenticator state machine (8.2.4.1.1 d)
339  AuthenticatorPortMode portMode; ///<Port mode (8.2.4.1.1 e)
340  uint_t reAuthCount; ///<Number of times the CONNECTING state is re-entered (8.2.4.1.1 f)
341 
342  uint_t quietPeriod; ///<Initialization value used for the quietWhile timer (8.2.4.1.2 a)
343  uint_t reAuthMax; ///<Maximum number of reauthentication attempts (8.2.4.1.2 b)
344 
345  bool_t keyTxEnabled; ///<Current value of the KeyTransmissionEnabled parameter (8.2.6.1.2)
346 
347  uint_t reAuthPeriod; ///<Number of seconds between periodic reauthentication (8.2.8.1 a)
348  bool_t reAuthEnabled; ///<Enable or disable reauthentication (8.2.8.1 b)
349 
350  bool_t eapNoReq; ///<No EAP frame to be sent to the supplicant (8.2.9.1.1 a)
351  bool_t eapReq; ///<An EAP frame to be sent to the supplicant (8.2.9.1.1 b)
352  bool_t eapResp; ///<A new EAP frame available for the higher layer to process (8.2.9.1.1 c)
353 
354  uint_t serverTimeout; ///<Initialization value used for the aWhile timer (8.2.9.1.2 a)
355 
356  EapFullAuthState eapFullAuthState; ///<EAP full authenticator state
357 
358  const uint8_t *eapRespData; ///<The EAP packet to be processed (5.1.1)
359  size_t eapRespDataLen; ///<Length of the EAP response
360  uint_t retransWhile; ///<Timer (5.1.1)
361 
362  uint8_t *eapReqData; ///<The actual EAP request to be sent (5.1.2)
363  size_t eapReqDataLen; ///<Length of the EAP request
364  uint8_t *eapKeyData; ///<EAP key (5.1.2)
365  bool_t eapKeyAvailable; ///<Keying material is available (5.1.2)
366 
367  EapMethodType currentMethod; ///<Current method (5.3.1)
368  uint_t currentId; ///<Identifier value of the currently outstanding EAP request (5.3.1)
369  EapMethodState methodState; ///<Method state (5.3.1)
370  uint_t retransCount; ///<Current number of retransmissions (5.3.1)
371  uint8_t *lastReqData; ///<EAP packet containing the last sent request (5.3.1)
372  size_t lastReqDataLen; ///<Length of the last EAP request
373  uint_t methodTimeout; ///<Method-provided hint for suitable retransmission timeout (5.3.1)
374 
375  bool_t rxResp; ///<The current received packet is an EAP response (5.3.2)
376  uint_t respId; ///<Identifier from the current EAP response (5.3.2)
377  EapMethodType respMethod; ///<Method type of the current EAP response (5.3.2)
378  bool_t ignore; ///<The method has decided to drop the current packet (5.3.2)
379  EapDecision decision; ///<Decision (5.3.2)
380 
381  bool_t aaaEapReq; ///<A new EAP request is ready to be sent (6.1.2)
382  bool_t aaaEapNoReq; ///<No new request to send (6.1.2)
383  bool_t aaaSuccess; ///<The state machine has reached the SUCCESS state (6.1.2)
384  bool_t aaaFail; ///<The state machine has reached the FAILURE state (6.1.2)
385  uint8_t *aaaEapReqData; ///<The actual EAP request to be sent (6.1.2)
386  size_t aaaEapReqDataLen; ///<Length of the EAP request
387  uint8_t *aaaEapKeyData; ///<EAP key (6.1.2)
388  bool_t aaaEapKeyAvailable; ///<Keying material is available (6.1.2)
389  uint_t aaaMethodTimeout; ///<Method-provided hint for suitable retransmission timeout (6.1.2)
390 
391  bool_t aaaEapResp; ///<An EAP response is available for processing by the AAA server (7.1.2)
392  const uint8_t *aaaEapRespData; ///<The EAP packet to be processed (5.1.2)
393  size_t aaaEapRespDataLen; ///<Length of the EAP response
394  char_t aaaIdentity[AUTHENTICATOR_MAX_ID_LEN + 1]; ///<Identity (5.1.2)
395 
396  uint_t maxRetrans; ///<Maximum number of retransmissions before aborting (5.1.3)
397 
398  bool_t aaaTimeout; ///<No response from the AAA layer (7.1.2)
399 
400  uint8_t aaaReqId; ///<Identifier value of the currently outstanding RADIUS request
401  uint8_t *aaaReqData; ///<RADIUS request
402  size_t aaaReqDataLen; ///<Length of the RADIUS request
403  uint_t aaaRetransTimer; ///<RADIUS retransmission timer
404  uint_t aaaRetransCount; ///<Current number of retransmissions or RADIUS requests
405  uint8_t reqAuthenticator[16]; ///<Request Authenticator field
406  uint8_t serverState[AUTHENTICATOR_MAX_STATE_SIZE]; ///<State attribute received from the server
407  size_t serverStateLen; ///<Length of the state attribute, in byte
408  MacAddr supplicantMacAddr; ///<Supplicant's MAC address
409 
410  uint8_t eapTxBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]; ///<Transmission buffer for EAP requests
411  uint8_t aaaTxBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]; ///<Transmission buffer for RADIUS requests
412 
413  AuthenticatorStats stats; ///<Statistics information
414  AuthenticatorSessionStats sessionStats; ///<Session statistics information
415 };
416 
417 
418 /**
419  * @brief 802.1X authenticator settings
420  **/
421 
422 typedef struct
423 {
424  OsTaskParameters task; ///<Task parameters
425  NetInterface *interface; ///<Underlying network interface
426  uint_t numPorts; ///<Number of ports
428  NetInterface *serverInterface; ///<RADIUS server interface
429  uint_t serverPortIndex; ///<Switch port used to reach the RADIUS server
430  IpAddr serverIpAddr; ///<RADIUS server's IP address
431  uint16_t serverPort; ///<RADIUS server's port
432  const PrngAlgo *prngAlgo; ///<Pseudo-random number generator to be used
433  void *prngContext; ///<Pseudo-random number generator context
434  AuthenticatorPaeStateChangeCallback paeStateChangeCallback; ///<Authenticator PAE state change callback function
435  AuthenticatorBackendStateChangeCallback backendStateChangeCallback; ///<Backend authentication state change callback function
436  AuthenticatorReauthTimerStateChangeCallback reauthTimerStateChangeCallback; ///<Reauthentication timer state change callback function
437  EapFullAuthStateChangeCallback eapFullAuthStateChangeCallback; ///<EAP full authenticator state change callback function
438  AuthenticatorTickCallback tickCallback; ///<Tick callback function
440 
441 
442 /**
443  * @brief 802.1X authenticator context
444  **/
445 
447 {
448  bool_t running; ///<Operational state of the authenticator
449  bool_t stop; ///<Stop request
450  OsMutex mutex; ///<Mutex preventing simultaneous access to 802.1X authenticator context
451  OsEvent event; ///<Event object used to poll the sockets
452  OsTaskParameters taskParams; ///<Task parameters
453  OsTaskId taskId; ///<Task identifier
454  NetInterface *interface; ///<Underlying network interface
455  uint_t numPorts; ///<Number of ports
457  NetInterface *serverInterface; ///<RADIUS server interface
458  uint_t serverPortIndex; ///<Switch port used to reach the RADIUS server
459  IpAddr serverIpAddr; ///<RADIUS server's IP address
460  uint16_t serverPort; ///<RADIUS server's port
461  uint8_t serverKey[AUTHENTICATOR_MAX_SERVER_KEY_LEN]; ///<RADIUS server's key
462  size_t serverKeyLen; ///<Length of the RADIUS server's key, in bytes
463  const PrngAlgo *prngAlgo; ///<Pseudo-random number generator to be used
464  void *prngContext; ///<Pseudo-random number generator context
465  Socket *peerSocket; ///<Raw socket used to send/receive EAP packets
466  Socket *serverSocket; ///<UDP socket used to send/receive RADIUS packets
467  AuthenticatorPaeStateChangeCallback paeStateChangeCallback; ///<Authenticator PAE state change callback function
468  AuthenticatorBackendStateChangeCallback backendStateChangeCallback; ///<Backend authentication state change callback function
469  AuthenticatorReauthTimerStateChangeCallback reauthTimerStateChangeCallback; ///<Reauthentication timer state change callback function
470  EapFullAuthStateChangeCallback eapFullAuthStateChangeCallback; ///<EAP full authenticator state change callback function
471  AuthenticatorTickCallback tickCallback; ///<Tick callback function
472  systime_t timestamp; ///<Timestamp to manage timeout
473 
474  uint_t radiusId; ///<RADIUS packet identifier
475  bool_t busy; ///<Busy flag
476 
477  uint8_t txBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]; ///<Transmission buffer
478  uint8_t rxBuffer[AUTHENTICATOR_RX_BUFFER_SIZE]; ///<Reception buffer
479  HmacContext hmacContext; ///<HMAC context
480 };
481 
482 
483 //Authenticator related functions
485 
487  const AuthenticatorSettings *settings);
488 
490  const IpAddr *serverIpAddr, uint16_t serverPort);
491 
493  const uint8_t *key, size_t keyLen);
494 
496  uint_t portIndex);
497 
499  uint_t portIndex);
500 
502  uint_t portIndex, AuthenticatorPortMode portControl);
503 
505  uint_t portIndex, uint_t quietPeriod);
506 
508  uint_t portIndex, uint_t serverTimeout);
509 
511  uint_t portIndex, bool_t reAuthEnabled);
512 
514  uint_t portIndex, uint_t reAuthPeriod);
515 
517  uint_t portIndex, AuthenticatorPortMode *portControl);
518 
520  uint_t portIndex, uint_t *quietPeriod);
521 
523  uint_t portIndex, uint_t *serverTimeout);
524 
526  uint_t portIndex, bool_t *reAuthEnabled);
527 
529  uint_t portIndex, uint_t *reAuthPeriod);
530 
532  uint_t portIndex, AuthenticatorPortStatus *portStatus);
533 
535  uint_t portIndex, AuthenticatorPaeState *paeState);
536 
538  uint_t portIndex, AuthenticatorBackendState *backendState);
539 
541  uint_t portIndex, AuthenticatorReauthTimerState *reauthTimerState);
542 
544  uint_t portIndex, EapFullAuthState *eapFullAuthState);
545 
548 
550 
552 
553 //C++ guard
554 #ifdef __cplusplus
555 }
556 #endif
557 
558 #endif
error_t authenticatorSetReAuthEnabled(AuthenticatorContext *context, uint_t portIndex, bool_t reAuthEnabled)
Set the value of the reAuthEnabled parameter.
error_t authenticatorSetReAuthPeriod(AuthenticatorContext *context, uint_t portIndex, uint_t reAuthPeriod)
Set the value of the reAuthPeriod parameter.
void(* EapFullAuthStateChangeCallback)(AuthenticatorPort *port, EapFullAuthState state)
EAP full authenticator state change callback function.
error_t authenticatorSetServerKey(AuthenticatorContext *context, const uint8_t *key, size_t keyLen)
Set RADIUS server's key.
error_t authenticatorSetQuietPeriod(AuthenticatorContext *context, uint_t portIndex, uint_t quietPeriod)
Set the value of the quietPeriod parameter.
error_t authenticatorGetQuietPeriod(AuthenticatorContext *context, uint_t portIndex, uint_t *quietPeriod)
Get the current value of the quietPeriod parameter.
void(* AuthenticatorTickCallback)(AuthenticatorContext *context)
Tick callback function.
error_t authenticatorGetServerTimeout(AuthenticatorContext *context, uint_t portIndex, uint_t *serverTimeout)
Get the current value of the serverTimeout parameter.
void authenticatorGetDefaultSettings(AuthenticatorSettings *settings)
Initialize settings with default values.
Definition: authenticator.c:51
error_t authenticatorStop(AuthenticatorContext *context)
Stop 802.1X authenticator.
error_t authenticatorStart(AuthenticatorContext *context)
Start 802.1X authenticator.
#define AUTHENTICATOR_MAX_STATE_SIZE
void authenticatorDeinit(AuthenticatorContext *context)
Release 802.1X authenticator context.
error_t authenticatorGetPaeState(AuthenticatorContext *context, uint_t portIndex, AuthenticatorPaeState *paeState)
Get the current state of the authenticator PAE state state machine.
void(* AuthenticatorReauthTimerStateChangeCallback)(AuthenticatorPort *port, AuthenticatorReauthTimerState state)
Reauthentication timer state change callback function.
error_t authenticatorGetReAuthPeriod(AuthenticatorContext *context, uint_t portIndex, uint_t *reAuthPeriod)
Get the current value of the reAuthPeriod parameter.
error_t authenticatorGetReauthTimerState(AuthenticatorContext *context, uint_t portIndex, AuthenticatorReauthTimerState *reauthTimerState)
Get the current state of the reauthentication timer state machine.
#define AuthenticatorPort
Definition: authenticator.h:40
error_t authenticatorGetReAuthEnabled(AuthenticatorContext *context, uint_t portIndex, bool_t *reAuthEnabled)
Get the current value of the reAuthEnabled parameter.
AuthenticatorTerminateCause
Session terminate cause.
@ AUTHENTICATOR_TERMINATE_CAUSE_SUPPLICANT_RESTART
@ AUTHENTICATOR_TERMINATE_CAUSE_SUPPLICANT_LOGOFF
@ AUTHENTICATOR_TERMINATE_CAUSE_PORT_ADMIN_DISABLED
@ AUTHENTICATOR_TERMINATE_CAUSE_NOT_TERMINATED_YET
@ AUTHENTICATOR_TERMINATE_CAUSE_PORT_FAILURE
@ AUTHENTICATOR_TERMINATE_CAUSE_PORT_REINIT
@ AUTHENTICATOR_TERMINATE_CAUSE_AUTH_CONTROL_FORCE_UNAUTH
@ AUTHENTICATOR_TERMINATE_CAUSE_REAUTH_FAILED
error_t authenticatorGetPortControl(AuthenticatorContext *context, uint_t portIndex, AuthenticatorPortMode *portControl)
Get the current value of the AuthControlledPortControl parameter.
#define AUTHENTICATOR_MAX_SERVER_KEY_LEN
Definition: authenticator.h:92
error_t authenticatorInit(AuthenticatorContext *context, const AuthenticatorSettings *settings)
Initialize 802.1X authenticator context.
error_t authenticatorGetBackendState(AuthenticatorContext *context, uint_t portIndex, AuthenticatorBackendState *backendState)
Get the current state of the backend authentication state machine.
error_t authenticatorGetEapFullAuthState(AuthenticatorContext *context, uint_t portIndex, EapFullAuthState *eapFullAuthState)
Get the current state of the EAP full authenticator state machine.
error_t authenticatorGetPortStatus(AuthenticatorContext *context, uint_t portIndex, AuthenticatorPortStatus *portStatus)
Get the current value of the AuthControlledPortStatus variable.
#define AUTHENTICATOR_TX_BUFFER_SIZE
Definition: authenticator.h:78
#define AUTHENTICATOR_RX_BUFFER_SIZE
Definition: authenticator.h:85
void(* AuthenticatorBackendStateChangeCallback)(AuthenticatorPort *port, AuthenticatorBackendState state)
Backend authentication state change callback function.
#define AUTHENTICATOR_MAX_ID_LEN
#define AuthenticatorContext
Definition: authenticator.h:36
void(* AuthenticatorPaeStateChangeCallback)(AuthenticatorPort *port, AuthenticatorPaeState state)
Authenticator PAE state change callback function.
error_t authenticatorInitPort(AuthenticatorContext *context, uint_t portIndex)
Reinitialize the specified port.
void authenticatorTask(AuthenticatorContext *context)
802.1X authenticator task
error_t authenticatorSetServerTimeout(AuthenticatorContext *context, uint_t portIndex, uint_t serverTimeout)
Set the value of the serverTimeout parameter.
error_t authenticatorSetPortControl(AuthenticatorContext *context, uint_t portIndex, AuthenticatorPortMode portControl)
Set the value of the AuthControlledPortControl parameter.
error_t authenticatorReauthenticate(AuthenticatorContext *context, uint_t portIndex)
Force the authenticator to reauthenticate the supplicant.
error_t authenticatorSetServerAddr(AuthenticatorContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
Specify the IP address of the RADIUS server.
Backend authentication state machine.
AuthenticatorBackendState
Backend authentication states.
Authenticator PAE state machine.
AuthenticatorPortStatus
Port status.
AuthenticatorPaeState
Authenticator PAE states.
AuthenticatorPortMode
Port modes.
Reauthentication timer state machine.
AuthenticatorReauthTimerState
Reauthentication timer states.
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
int bool_t
Definition: compiler_port.h:53
#define PrngAlgo
Definition: crypto.h:917
uint16_t port
Definition: dns_common.h:267
EAP (Extensible Authentication Protocol)
EapMethodType
EAP method types.
Definition: eap.h:164
EAP full authenticator state machine.
EapMethodState
EAP method states.
EapFullAuthState
EAP full authenticator states.
EapDecision
Decisions.
error_t
Error codes.
Definition: error.h:43
MacAddr
Definition: ethernet.h:195
HMAC (Keyed-Hashing for Message Authentication)
#define NetInterface
Definition: net.h:36
uint32_t systime_t
System time.
thread_t * OsTaskId
Task identifier.
#define Socket
Definition: socket.h:36
802.1X authenticator context
systime_t timestamp
Timestamp to manage timeout.
NetInterface * serverInterface
RADIUS server interface.
AuthenticatorPort * ports
Ports.
AuthenticatorTickCallback tickCallback
Tick callback function.
bool_t stop
Stop request.
Socket * serverSocket
UDP socket used to send/receive RADIUS packets.
AuthenticatorPaeStateChangeCallback paeStateChangeCallback
Authenticator PAE state change callback function.
uint8_t serverKey[AUTHENTICATOR_MAX_SERVER_KEY_LEN]
RADIUS server's key.
uint_t radiusId
RADIUS packet identifier.
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
uint8_t txBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]
Transmission buffer.
size_t serverKeyLen
Length of the RADIUS server's key, in bytes.
OsTaskId taskId
Task identifier.
uint_t numPorts
Number of ports.
IpAddr serverIpAddr
RADIUS server's IP address.
Socket * peerSocket
Raw socket used to send/receive EAP packets.
uint16_t serverPort
RADIUS server's port.
bool_t running
Operational state of the authenticator.
bool_t busy
Busy flag.
OsTaskParameters taskParams
Task parameters.
EapFullAuthStateChangeCallback eapFullAuthStateChangeCallback
EAP full authenticator state change callback function.
AuthenticatorReauthTimerStateChangeCallback reauthTimerStateChangeCallback
Reauthentication timer state change callback function.
AuthenticatorBackendStateChangeCallback backendStateChangeCallback
Backend authentication state change callback function.
OsEvent event
Event object used to poll the sockets.
HmacContext hmacContext
HMAC context.
uint8_t rxBuffer[AUTHENTICATOR_RX_BUFFER_SIZE]
Reception buffer.
NetInterface * interface
Underlying network interface.
uint_t serverPortIndex
Switch port used to reach the RADIUS server.
OsMutex mutex
Mutex preventing simultaneous access to 802.1X authenticator context.
void * prngContext
Pseudo-random number generator context.
Port context.
AuthenticatorStats stats
Statistics information.
uint_t aWhile
Timer used by the backend authentication state machine (8.2.2.1 a)
uint_t retransCount
Current number of retransmissions (5.3.1)
bool_t portValid
The value of this variable is set externally (8.2.2.2 s)
uint8_t portIndex
Port index.
AuthenticatorPaeState authPaeState
Authenticator PAE state.
size_t eapRespDataLen
Length of the EAP response.
uint_t quietPeriod
Initialization value used for the quietWhile timer (8.2.4.1.2 a)
AuthenticatorContext * context
802.1X authenticator context
AuthenticatorPortStatus authPortStatus
Current authorization state of the authenticator PAE state machine (8.2.2.2 c)
AuthenticatorPortMode portMode
Port mode (8.2.4.1.1 e)
EapMethodType currentMethod
Current method (5.3.1)
EapDecision decision
Decision (5.3.2)
bool_t eapRestart
Restart Authenticator state machine (8.2.4.1.1 d)
AuthenticatorBackendState authBackendState
Backend authentication state.
char_t aaaIdentity[AUTHENTICATOR_MAX_ID_LEN+1]
Identity (5.1.2)
size_t eapReqDataLen
Length of the EAP request.
bool_t aaaEapNoReq
No new request to send (6.1.2)
AuthenticatorReauthTimerState reauthTimerState
Reauthentication timer state.
bool_t eapolLogoff
EAPOL-Logoff received (8.2.4.1.1 a)
bool_t eapTimeout
The supplicant is not responding to requests (8.2.2.2 j)
size_t aaaEapReqDataLen
Length of the EAP request.
bool_t authSuccess
Successful authentication process (8.2.2.2 f)
bool_t ignore
The method has decided to drop the current packet (5.3.2)
uint_t respId
Identifier from the current EAP response (5.3.2)
AuthenticatorSessionStats sessionStats
Session statistics information.
bool_t eapReq
An EAP frame to be sent to the supplicant (8.2.9.1.1 b)
uint8_t * eapReqData
The actual EAP request to be sent (5.1.2)
bool_t rxResp
The current received packet is an EAP response (5.3.2)
bool_t aaaEapReq
A new EAP request is ready to be sent (6.1.2)
uint_t currentId
Identifier value of the currently outstanding EAP request (5.3.1)
bool_t eapResp
A new EAP frame available for the higher layer to process (8.2.9.1.1 c)
const uint8_t * eapRespData
The EAP packet to be processed (5.1.1)
bool_t keyRun
Run transmit key machine (8.2.2.2 n)
uint_t reAuthMax
Maximum number of reauthentication attempts (8.2.4.1.2 b)
EapFullAuthState eapFullAuthState
EAP full authenticator state.
EapMethodState methodState
Method state (5.3.1)
uint_t reAuthCount
Number of times the CONNECTING state is re-entered (8.2.4.1.1 f)
bool_t reAuthEnabled
Enable or disable reauthentication (8.2.8.1 b)
uint8_t * eapKeyData
EAP key (5.1.2)
bool_t aaaSuccess
The state machine has reached the SUCCESS state (6.1.2)
const uint8_t * aaaEapRespData
The EAP packet to be processed (5.1.2)
bool_t keyTxEnabled
Current value of the KeyTransmissionEnabled parameter (8.2.6.1.2)
MacAddr macAddr
MAC address of the port.
uint8_t * lastReqData
EAP packet containing the last sent request (5.3.1)
size_t lastReqDataLen
Length of the last EAP request.
AuthenticatorPortMode portControl
Port control (8.2.2.2 p)
bool_t eapKeyAvailable
Keying material is available (5.1.2)
size_t aaaEapRespDataLen
Length of the EAP response.
uint8_t * aaaEapKeyData
EAP key (6.1.2)
bool_t eapFail
The authentication has failed (8.2.2.2 g)
bool_t eapSuccess
The authentication process succeeds (8.2.2.2 i)
uint8_t serverState[AUTHENTICATOR_MAX_STATE_SIZE]
State attribute received from the server.
uint8_t reqAuthenticator[16]
Request Authenticator field.
uint_t methodTimeout
Method-provided hint for suitable retransmission timeout (5.3.1)
bool_t authAbort
Abort authentication procedure (8.2.2.2 a)
bool_t aaaEapKeyAvailable
Keying material is available (6.1.2)
bool_t reAuthenticate
The reAuthWhen timer has expired (8.2.2.2 t)
uint8_t * aaaEapReqData
The actual EAP request to be sent (6.1.2)
bool_t eapolEap
EAPOL PDU carrying a packet Type of EAP-Packet is received (8.2.2.2 h)
uint8_t eapTxBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]
Transmission buffer for EAP requests.
bool_t keyDone
This variable is set by the key machine (8.2.2.2 m)
uint_t aaaRetransTimer
RADIUS retransmission timer.
uint_t reAuthWhen
Timer used to determine when reauthentication takes place (8.2.2.1 e)
bool_t eapNoReq
No EAP frame to be sent to the supplicant (8.2.9.1.1 a)
uint_t aaaMethodTimeout
Method-provided hint for suitable retransmission timeout (6.1.2)
uint8_t * aaaReqData
RADIUS request.
EapMethodType respMethod
Method type of the current EAP response (5.3.2)
uint_t reAuthPeriod
Number of seconds between periodic reauthentication (8.2.8.1 a)
bool_t authTimeout
Start authentication procedure (8.2.2.2 d)
uint_t maxRetrans
Maximum number of retransmissions before aborting (5.1.3)
size_t serverStateLen
Length of the state attribute, in byte.
bool_t eapolStart
EAPOL-Start received (8.2.4.1.1 b)
MacAddr supplicantMacAddr
Supplicant's MAC address.
bool_t aaaFail
The state machine has reached the FAILURE state (6.1.2)
bool_t authFail
Authentication process has failed (8.2.2.2 b)
uint_t quietWhile
Timer used by the authenticator PAE state machine (8.2.2.1 d)
uint_t serverTimeout
Initialization value used for the aWhile timer (8.2.9.1.2 a)
bool_t aaaTimeout
No response from the AAA layer (7.1.2)
bool_t initialize
Forces all EAPOL state machines to their initial state (8.2.2.2 k)
uint8_t aaaReqId
Identifier value of the currently outstanding RADIUS request.
uint8_t aaaTxBuffer[AUTHENTICATOR_TX_BUFFER_SIZE]
Transmission buffer for RADIUS requests.
bool_t aaaEapResp
An EAP response is available for processing by the AAA server (7.1.2)
uint_t retransWhile
Timer (5.1.1)
uint_t aaaRetransCount
Current number of retransmissions or RADIUS requests.
bool_t portEnabled
Operational state of the port (8.2.2.2 q)
size_t aaaReqDataLen
Length of the RADIUS request.
Session statistics information.
802.1X authenticator settings
OsTaskParameters task
Task parameters.
NetInterface * serverInterface
RADIUS server interface.
AuthenticatorPort * ports
Ports.
AuthenticatorTickCallback tickCallback
Tick callback function.
AuthenticatorPaeStateChangeCallback paeStateChangeCallback
Authenticator PAE state change callback function.
const PrngAlgo * prngAlgo
Pseudo-random number generator to be used.
uint_t numPorts
Number of ports.
IpAddr serverIpAddr
RADIUS server's IP address.
uint16_t serverPort
RADIUS server's port.
EapFullAuthStateChangeCallback eapFullAuthStateChangeCallback
EAP full authenticator state change callback function.
AuthenticatorReauthTimerStateChangeCallback reauthTimerStateChangeCallback
Reauthentication timer state change callback function.
AuthenticatorBackendStateChangeCallback backendStateChangeCallback
Backend authentication state change callback function.
NetInterface * interface
Underlying network interface.
uint_t serverPortIndex
Switch port used to reach the RADIUS server.
void * prngContext
Pseudo-random number generator context.
Statistics information.
uint32_t eapolLogoffFramesRx
uint32_t eapolReqFramesTx
uint32_t eapolRespFramesRx
uint32_t eapLengthErrorFramesRx
uint32_t eapolReqIdFramesTx
uint32_t lastEapolFrameVersion
uint32_t eapolStartFramesRx
uint32_t eapolRespIdFramesRx
uint32_t invalidEapolFramesRx
HMAC algorithm context.
Definition: hmac.h:59
IP network address.
Definition: ip.h:79
Event object.
Mutex object.
Task parameters.