1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* $FreeBSD$ */
/*
* hostapd / EAP Standalone Authenticator state machine (RFC 4137)
* Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
*
* 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.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*/
#ifndef EAP_H
#define EAP_H
#include "defs.h"
#include "eap_defs.h"
#include "eap_methods.h"
struct eap_sm;
#define EAP_MAX_METHODS 8
struct eap_user {
struct {
int vendor;
u32 method;
} methods[EAP_MAX_METHODS];
u8 *password;
size_t password_len;
int password_hash; /* whether password is hashed with
* nt_password_hash() */
int phase2;
int force_version;
};
enum eapol_bool_var {
EAPOL_eapSuccess, EAPOL_eapRestart, EAPOL_eapFail, EAPOL_eapResp,
EAPOL_eapReq, EAPOL_eapNoReq, EAPOL_portEnabled, EAPOL_eapTimeout
};
struct eapol_callbacks {
Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
void (*set_bool)(void *ctx, enum eapol_bool_var variable,
Boolean value);
void (*set_eapReqData)(void *ctx, const u8 *eapReqData,
size_t eapReqDataLen);
void (*set_eapKeyData)(void *ctx, const u8 *eapKeyData,
size_t eapKeyDataLen);
int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
int phase2, struct eap_user *user);
const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
};
struct eap_config {
void *ssl_ctx;
void *eap_sim_db_priv;
Boolean backend_auth;
};
#ifdef EAP_SERVER
struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
struct eap_config *eap_conf);
void eap_sm_deinit(struct eap_sm *sm);
int eap_sm_step(struct eap_sm *sm);
void eap_set_eapRespData(struct eap_sm *sm, const u8 *eapRespData,
size_t eapRespDataLen);
void eap_sm_notify_cached(struct eap_sm *sm);
void eap_sm_pending_cb(struct eap_sm *sm);
int eap_sm_method_pending(struct eap_sm *sm);
#else /* EAP_SERVER */
static inline struct eap_sm * eap_sm_init(void *eapol_ctx,
struct eapol_callbacks *eapol_cb,
struct eap_config *eap_conf)
{
return NULL;
}
static inline void eap_sm_deinit(struct eap_sm *sm)
{
}
static inline int eap_sm_step(struct eap_sm *sm)
{
return 0;
}
static inline void eap_set_eapRespData(struct eap_sm *sm,
const u8 *eapRespData,
size_t eapRespDataLen)
{
}
static inline void eap_sm_notify_cached(struct eap_sm *sm)
{
}
static inline void eap_sm_pending_cb(struct eap_sm *sm)
{
}
static inline int eap_sm_method_pending(struct eap_sm *sm)
{
return 0;
}
#endif /* EAP_SERVER */
#endif /* EAP_H */
|