Disconnect hostapd from building in base
[dragonfly.git] / contrib / hostapd / src / eap_peer / eap_tls_common.h
CommitLineData
a875087d
JL
1/*
2 * EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
4781064b 3 * Copyright (c) 2004-2009, 2012, Jouni Malinen <j@w1.fi>
a875087d 4 *
4781064b
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
a875087d
JL
7 */
8
9#ifndef EAP_TLS_COMMON_H
10#define EAP_TLS_COMMON_H
11
12/**
13 * struct eap_ssl_data - TLS data for EAP methods
14 */
15struct eap_ssl_data {
16 /**
17 * conn - TLS connection context data from tls_connection_init()
18 */
19 struct tls_connection *conn;
20
21 /**
22 * tls_out - TLS message to be sent out in fragments
23 */
4781064b 24 struct wpabuf *tls_out;
a875087d
JL
25
26 /**
27 * tls_out_pos - The current position in the outgoing TLS message
28 */
29 size_t tls_out_pos;
30
31 /**
32 * tls_out_limit - Maximum fragment size for outgoing TLS messages
33 */
34 size_t tls_out_limit;
35
36 /**
37 * tls_in - Received TLS message buffer for re-assembly
38 */
4781064b 39 struct wpabuf *tls_in;
a875087d
JL
40
41 /**
42 * tls_in_left - Number of remaining bytes in the incoming TLS message
43 */
44 size_t tls_in_left;
45
46 /**
47 * tls_in_total - Total number of bytes in the incoming TLS message
48 */
49 size_t tls_in_total;
50
51 /**
52 * phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
53 */
54 int phase2;
55
56 /**
57 * include_tls_length - Whether the TLS length field is included even
58 * if the TLS data is not fragmented
59 */
60 int include_tls_length;
61
62 /**
4781064b 63 * eap - EAP state machine allocated with eap_peer_sm_init()
a875087d 64 */
4781064b 65 struct eap_sm *eap;
a875087d
JL
66
67 /**
4781064b 68 * ssl_ctx - TLS library context to use for the connection
a875087d 69 */
4781064b
JM
70 void *ssl_ctx;
71
72 /**
73 * eap_type - EAP method used in Phase 1 (EAP_TYPE_TLS/PEAP/TTLS/FAST)
74 */
75 u8 eap_type;
a875087d
JL
76};
77
78
79/* EAP TLS Flags */
80#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
81#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
82#define EAP_TLS_FLAGS_START 0x20
4781064b 83#define EAP_TLS_VERSION_MASK 0x07
a875087d
JL
84
85 /* could be up to 128 bytes, but only the first 64 bytes are used */
86#define EAP_TLS_KEY_LEN 64
87
4781064b
JM
88/* dummy type used as a flag for UNAUTH-TLS */
89#define EAP_UNAUTH_TLS_TYPE 255
90
a875087d
JL
91
92int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
4781064b 93 struct eap_peer_config *config, u8 eap_type);
a875087d
JL
94void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
95u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
96 const char *label, size_t len);
4781064b
JM
97u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
98 struct eap_ssl_data *data, u8 eap_type,
99 size_t *len);
a875087d
JL
100int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
101 EapType eap_type, int peap_version,
102 u8 id, const u8 *in_data, size_t in_len,
103 struct wpabuf **out_data);
104struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type,
105 int peap_version);
106int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data);
107int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
108 char *buf, size_t buflen, int verbose);
109const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
110 struct eap_ssl_data *data,
111 EapType eap_type,
112 struct eap_method_ret *ret,
113 const struct wpabuf *reqData,
114 size_t *len, u8 *flags);
115void eap_peer_tls_reset_input(struct eap_ssl_data *data);
116void eap_peer_tls_reset_output(struct eap_ssl_data *data);
117int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
118 const struct wpabuf *in_data,
119 struct wpabuf **in_decrypted);
120int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
121 EapType eap_type, int peap_version, u8 id,
122 const struct wpabuf *in_data,
123 struct wpabuf **out_data);
124int eap_peer_select_phase2_methods(struct eap_peer_config *config,
125 const char *prefix,
126 struct eap_method_type **types,
127 size_t *num_types);
128int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
129 struct eap_hdr *hdr, struct wpabuf **resp);
130
131#endif /* EAP_TLS_COMMON_H */