6c9d69603ed0a74f6c097dbafa987eab49fc7fc8
[dragonfly.git] / contrib / hostapd-0.5.8 / eap_tls_common.h
1 /*
2  * hostapd / EAP-TLS/PEAP/TTLS common functions
3  * Copyright (c) 2004-2005, 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_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
47                      int verify_peer);
48 void eap_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
49 u8 * eap_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
50                         char *label, size_t len);
51 int eap_tls_data_reassemble(struct eap_sm *sm, struct eap_ssl_data *data,
52                             u8 **in_data, size_t *in_len);
53 int eap_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
54                            u8 *in_data, size_t in_len);
55 int eap_tls_buildReq_helper(struct eap_sm *sm, struct eap_ssl_data *data,
56                             int eap_type, int peap_version, u8 id,
57                             u8 **out_data, size_t *out_len);
58 u8 * eap_tls_build_ack(size_t *reqDataLen, u8 id, int eap_type,
59                        int peap_version);
60
61 #endif /* EAP_TLS_COMMON_H */