wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
eap_tls_common.h
Go to the documentation of this file.
1 
5 #ifndef EAP_TLS_COMMON_H
6 #define EAP_TLS_COMMON_H
7 
12 struct eap_ssl_data {
18 
23  struct wpabuf *tls_out;
24 
29  size_t tls_out_pos;
30 
35  size_t tls_out_limit;
36 
41  struct wpabuf *tls_in;
42 
47  size_t tls_in_left;
48 
53  size_t tls_in_total;
54 
59  int phase2;
60 
66 
71  struct eap_sm *eap;
72 
77  void *ssl_ctx;
78 
84 };
85 
86 
87 /* EAP TLS Flags */
88 #define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
89 #define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
90 #define EAP_TLS_FLAGS_START 0x20
91 #define EAP_TLS_VERSION_MASK 0x07
92 
93  /* could be up to 128 bytes, but only the first 64 bytes are used */
94 #define EAP_TLS_KEY_LEN 64
95 
96 /* dummy type used as a flag for UNAUTH-TLS */
97 #define EAP_UNAUTH_TLS_TYPE 255
98 #define EAP_WFA_UNAUTH_TLS_TYPE 254
99 
100 
101 int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
102  struct eap_peer_config *config, u8 eap_type);
103 void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
104 u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
105  const char *label, size_t len);
106 u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
107  struct eap_ssl_data *data, u8 eap_type,
108  size_t *len);
109 int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
110  EapType eap_type, int peap_version,
111  u8 id, const struct wpabuf *in_data,
112  struct wpabuf **out_data);
113 struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type,
114  int peap_version);
115 int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data);
116 int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
117  char *buf, size_t buflen, int verbose);
118 const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
119  struct eap_ssl_data *data,
120  EapType eap_type,
121  struct eap_method_ret *ret,
122  const struct wpabuf *reqData,
123  size_t *len, u8 *flags);
124 void eap_peer_tls_reset_input(struct eap_ssl_data *data);
125 void eap_peer_tls_reset_output(struct eap_ssl_data *data);
126 int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
127  const struct wpabuf *in_data,
128  struct wpabuf **in_decrypted);
129 int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
130  EapType eap_type, int peap_version, u8 id,
131  const struct wpabuf *in_data,
132  struct wpabuf **out_data);
134  const char *prefix,
135  struct eap_method_type **types,
136  size_t *num_types);
137 int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
138  struct eap_hdr *hdr, struct wpabuf **resp);
139 
140 #endif /* EAP_TLS_COMMON_H */
size_t tls_out_limit
Maximum fragment size for outgoing TLS messages.
Definition: eap_tls_common.h:35
int include_tls_length
Whether the TLS length field is included even if the TLS data is not fragmented.
Definition: eap_tls_common.h:65
EAP return values from struct eap_method::process()
Definition: eap_i.h:32
int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data, EapType eap_type, int peap_version, u8 id, const struct wpabuf *in_data, struct wpabuf **out_data)
Process TLS handshake message.
Definition: eap_tls_common.c:632
int eap_peer_select_phase2_methods(struct eap_peer_config *config, const char *prefix, struct eap_method_type **types, size_t *num_types)
Select phase 2 EAP method.
Definition: eap_tls_common.c:997
struct wpabuf * tls_out
TLS message to be sent out in fragments.
Definition: eap_tls_common.h:23
struct eap_sm * eap
EAP state machine allocated with eap_peer_sm_init()
Definition: eap_tls_common.h:71
size_t tls_out_pos
The current position in the outgoing TLS message.
Definition: eap_tls_common.h:29
u8 eap_type
EAP method used in Phase 1 (EAP_TYPE_TLS/PEAP/TTLS/FAST)
Definition: eap_tls_common.h:83
u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data, const char *label, size_t len)
Derive a key based on TLS session data.
Definition: eap_tls_common.c:310
Definition: wpabuf.h:16
int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data, EapType eap_type, int peap_version, u8 id, const struct wpabuf *in_data, struct wpabuf **out_data)
Encrypt phase 2 TLS message.
Definition: eap_tls_common.c:963
size_t tls_in_left
Number of remaining bytes in the incoming TLS message.
Definition: eap_tls_common.h:47
void eap_peer_tls_reset_output(struct eap_ssl_data *data)
Reset output buffers.
Definition: eap_tls_common.c:915
int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types, struct eap_hdr *hdr, struct wpabuf **resp)
Generate EAP-Nak for Phase 2.
Definition: eap_tls_common.c:1080
int phase2
Whether this TLS connection is used in EAP phase 2 (tunnel)
Definition: eap_tls_common.h:59
Definition: eap.h:16
TLS data for EAP methods.
Definition: eap_tls_common.h:12
struct wpabuf * tls_in
Received TLS message buffer for re-assembly.
Definition: eap_tls_common.h:41
int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data)
Re-initialize shared TLS for session resumption.
Definition: eap_tls_common.c:738
const u8 * eap_peer_tls_process_init(struct eap_sm *sm, struct eap_ssl_data *data, EapType eap_type, struct eap_method_ret *ret, const struct wpabuf *reqData, size_t *len, u8 *flags)
Initial validation/processing of EAP requests.
Definition: eap_tls_common.c:805
int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data, char *buf, size_t buflen, int verbose)
Get TLS status.
Definition: eap_tls_common.c:755
struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type, int peap_version)
Build a TLS ACK frame.
Definition: eap_tls_common.c:717
void eap_peer_tls_reset_input(struct eap_ssl_data *data)
Reset input buffers.
Definition: eap_tls_common.c:900
u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm, struct eap_ssl_data *data, u8 eap_type, size_t *len)
Derive a Session-Id based on TLS data.
Definition: eap_tls_common.c:342
int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data, struct eap_peer_config *config, u8 eap_type)
Initialize shared TLS functionality.
Definition: eap_tls_common.c:240
Definition: eap_defs.h:14
size_t tls_in_total
Total number of bytes in the incoming TLS message.
Definition: eap_tls_common.h:53
int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data, const struct wpabuf *in_data, struct wpabuf **in_decrypted)
Decrypt received phase 2 TLS message.
Definition: eap_tls_common.c:931
void * ssl_ctx
TLS library context to use for the connection.
Definition: eap_tls_common.h:77
Definition: tls_gnutls.c:38
EAP state machine data.
Definition: eap_i.h:302
struct tls_connection * conn
TLS connection context data from tls_connection_init()
Definition: eap_tls_common.h:17
void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data)
Deinitialize shared TLS functionality.
Definition: eap_tls_common.c:288
EAP peer configuration/credentials.
Definition: eap_config.h:12