eap_tls_common.h revision 189261
11844Swollman/*
234087Sbde * hostapd / EAP-TLS/PEAP/TTLS/FAST common functions
31638Srgrimes * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
41844Swollman *
51638Srgrimes * This program is free software; you can redistribute it and/or modify
61638Srgrimes * it under the terms of the GNU General Public License version 2 as
71638Srgrimes * published by the Free Software Foundation.
829129Speter *
929129Speter * Alternatively, this software may be distributed under the terms of BSD
1029129Speter * license.
111844Swollman *
121638Srgrimes * See README and COPYING for more details.
132827Sjkh */
141844Swollman
151844Swollman#ifndef EAP_TLS_COMMON_H
1626051Sasami#define EAP_TLS_COMMON_H
171844Swollman
181638Srgrimesstruct eap_ssl_data {
192827Sjkh	struct tls_connection *conn;
201638Srgrimes
212827Sjkh	size_t tls_out_limit;
221638Srgrimes
2327028Spst	int phase2;
241844Swollman
251844Swollman	struct eap_sm *eap;
261638Srgrimes
271638Srgrimes	enum { MSG, FRAG_ACK, WAIT_FRAG_ACK } state;
281638Srgrimes	struct wpabuf *in_buf;
291638Srgrimes	struct wpabuf *out_buf;
301844Swollman	size_t out_used;
311638Srgrimes	struct wpabuf tmpbuf;
3234081Sbde};
331844Swollman
341844Swollman
358321Sbde/* EAP TLS Flags */
361844Swollman#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
3733624Seivind#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
382351Sbde#define EAP_TLS_FLAGS_START 0x20
391638Srgrimes#define EAP_TLS_VERSION_MASK 0x07
402351Sbde
412351Sbde /* could be up to 128 bytes, but only the first 64 bytes are used */
422351Sbde#define EAP_TLS_KEY_LEN 64
432351Sbde
442351Sbde
452351Sbdeint eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
4633624Seivind			    int verify_peer);
4734081Sbdevoid eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
482351Sbdeu8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
4933624Seivind			       char *label, size_t len);
501638Srgrimesstruct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data,
511638Srgrimes					 int eap_type, int version, u8 id);
521638Srgrimesstruct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type, int version);
531638Srgrimesint eap_server_tls_phase1(struct eap_sm *sm, struct eap_ssl_data *data);
541638Srgrimesstruct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm,
551638Srgrimes				       struct eap_ssl_data *data,
561844Swollman				       const u8 *plain, size_t plain_len);
571638Srgrimesint eap_server_tls_process(struct eap_sm *sm, struct eap_ssl_data *data,
581638Srgrimes			   struct wpabuf *respData, void *priv, int eap_type,
591638Srgrimes			   int (*proc_version)(struct eap_sm *sm, void *priv,
601638Srgrimes					       int peer_version),
6118340Sswallace			   void (*proc_msg)(struct eap_sm *sm, void *priv,
621638Srgrimes					    const struct wpabuf *respData));
6333816Sbde
641638Srgrimes#endif /* EAP_TLS_COMMON_H */
6527910Sasami