eap_tls_common.h revision 189251
1189251Ssam/* 2189251Ssam * hostapd / EAP-TLS/PEAP/TTLS/FAST common functions 3189251Ssam * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi> 4189251Ssam * 5189251Ssam * This program is free software; you can redistribute it and/or modify 6189251Ssam * it under the terms of the GNU General Public License version 2 as 7189251Ssam * published by the Free Software Foundation. 8189251Ssam * 9189251Ssam * Alternatively, this software may be distributed under the terms of BSD 10189251Ssam * license. 11189251Ssam * 12189251Ssam * See README and COPYING for more details. 13189251Ssam */ 14189251Ssam 15189251Ssam#ifndef EAP_TLS_COMMON_H 16189251Ssam#define EAP_TLS_COMMON_H 17189251Ssam 18189251Ssamstruct eap_ssl_data { 19189251Ssam struct tls_connection *conn; 20189251Ssam 21189251Ssam size_t tls_out_limit; 22189251Ssam 23189251Ssam int phase2; 24189251Ssam 25189251Ssam struct eap_sm *eap; 26189251Ssam 27189251Ssam enum { MSG, FRAG_ACK, WAIT_FRAG_ACK } state; 28189251Ssam struct wpabuf *in_buf; 29189251Ssam struct wpabuf *out_buf; 30189251Ssam size_t out_used; 31189251Ssam struct wpabuf tmpbuf; 32189251Ssam}; 33189251Ssam 34189251Ssam 35189251Ssam/* EAP TLS Flags */ 36189251Ssam#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80 37189251Ssam#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40 38189251Ssam#define EAP_TLS_FLAGS_START 0x20 39189251Ssam#define EAP_TLS_VERSION_MASK 0x07 40189251Ssam 41189251Ssam /* could be up to 128 bytes, but only the first 64 bytes are used */ 42189251Ssam#define EAP_TLS_KEY_LEN 64 43189251Ssam 44189251Ssam 45189251Ssamint eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data, 46189251Ssam int verify_peer); 47189251Ssamvoid eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data); 48189251Ssamu8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data, 49189251Ssam char *label, size_t len); 50189251Ssamstruct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data, 51189251Ssam int eap_type, int version, u8 id); 52189251Ssamstruct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type, int version); 53189251Ssamint eap_server_tls_phase1(struct eap_sm *sm, struct eap_ssl_data *data); 54189251Ssamstruct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm, 55189251Ssam struct eap_ssl_data *data, 56189251Ssam const u8 *plain, size_t plain_len); 57189251Ssamint eap_server_tls_process(struct eap_sm *sm, struct eap_ssl_data *data, 58189251Ssam struct wpabuf *respData, void *priv, int eap_type, 59189251Ssam int (*proc_version)(struct eap_sm *sm, void *priv, 60189251Ssam int peer_version), 61189251Ssam void (*proc_msg)(struct eap_sm *sm, void *priv, 62189251Ssam const struct wpabuf *respData)); 63189251Ssam 64189251Ssam#endif /* EAP_TLS_COMMON_H */ 65