2470faa1b07e1ead8370e1945d0279421f9dfab8
[mech_eap.git] / src / eap_server / eap_tls_common.h
1 /*
2  * hostapd / EAP-TLS/PEAP/TTLS/FAST common functions
3  * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef EAP_TLS_COMMON_H
16 #define EAP_TLS_COMMON_H
17
18 struct eap_ssl_data {
19         struct tls_connection *conn;
20
21         u8 *tls_out;
22         size_t tls_out_len;
23         size_t tls_out_pos;
24         size_t tls_out_limit;
25         u8 *tls_in;
26         size_t tls_in_len;
27         size_t tls_in_left;
28         size_t tls_in_total;
29
30         int phase2;
31
32         struct eap_sm *eap;
33 };
34
35
36 /* EAP TLS Flags */
37 #define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
38 #define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
39 #define EAP_TLS_FLAGS_START 0x20
40 #define EAP_PEAP_VERSION_MASK 0x07
41
42  /* could be up to 128 bytes, but only the first 64 bytes are used */
43 #define EAP_TLS_KEY_LEN 64
44
45
46 int eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
47                             int verify_peer);
48 void eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
49 u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
50                                char *label, size_t len);
51 int eap_server_tls_data_reassemble(struct eap_sm *sm,
52                                    struct eap_ssl_data *data,
53                                    u8 **in_data, size_t *in_len);
54 int eap_server_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
55                                   const u8 *in_data, size_t in_len);
56 int eap_server_tls_buildReq_helper(struct eap_sm *sm,
57                                    struct eap_ssl_data *data,
58                                    int eap_type, int peap_version, u8 id,
59                                    struct wpabuf **out_data);
60 struct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type,
61                                          int peap_version);
62
63 #endif /* EAP_TLS_COMMON_H */