2008-02-28 02:34:43 +01:00
|
|
|
/*
|
2009-12-20 17:17:55 +01:00
|
|
|
* EAP-TLS/PEAP/TTLS/FAST server common functions
|
|
|
|
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
|
2008-02-28 02:34:43 +01:00
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EAP_TLS_COMMON_H
|
|
|
|
#define EAP_TLS_COMMON_H
|
|
|
|
|
2009-12-23 23:16:58 +01:00
|
|
|
/**
|
|
|
|
* struct eap_ssl_data - TLS data for EAP methods
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
struct eap_ssl_data {
|
2009-12-23 23:16:58 +01:00
|
|
|
/**
|
|
|
|
* conn - TLS connection context data from tls_connection_init()
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
struct tls_connection *conn;
|
|
|
|
|
2009-12-23 23:16:58 +01:00
|
|
|
/**
|
|
|
|
* tls_out - TLS message to be sent out in fragments
|
|
|
|
*/
|
|
|
|
struct wpabuf *tls_out;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_out_pos - The current position in the outgoing TLS message
|
|
|
|
*/
|
|
|
|
size_t tls_out_pos;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_out_limit - Maximum fragment size for outgoing TLS messages
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
size_t tls_out_limit;
|
|
|
|
|
2009-12-23 23:16:58 +01:00
|
|
|
/**
|
|
|
|
* tls_in - Received TLS message buffer for re-assembly
|
|
|
|
*/
|
|
|
|
struct wpabuf *tls_in;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
int phase2;
|
|
|
|
|
2009-12-23 23:16:58 +01:00
|
|
|
/**
|
|
|
|
* eap - EAP state machine allocated with eap_server_sm_init()
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
struct eap_sm *eap;
|
2008-05-28 08:57:17 +02:00
|
|
|
|
|
|
|
enum { MSG, FRAG_ACK, WAIT_FRAG_ACK } state;
|
|
|
|
struct wpabuf tmpbuf;
|
2008-02-28 02:34:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* EAP TLS Flags */
|
|
|
|
#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
|
|
|
|
#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
|
|
|
|
#define EAP_TLS_FLAGS_START 0x20
|
2008-05-28 08:59:55 +02:00
|
|
|
#define EAP_TLS_VERSION_MASK 0x07
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
/* could be up to 128 bytes, but only the first 64 bytes are used */
|
|
|
|
#define EAP_TLS_KEY_LEN 64
|
|
|
|
|
2012-08-22 21:34:11 +02:00
|
|
|
/* dummy type used as a flag for UNAUTH-TLS */
|
|
|
|
#define EAP_UNAUTH_TLS_TYPE 255
|
2013-07-23 20:22:38 +02:00
|
|
|
#define EAP_WFA_UNAUTH_TLS_TYPE 254
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-08-22 21:34:11 +02:00
|
|
|
|
|
|
|
struct wpabuf * eap_tls_msg_alloc(EapType type, size_t payload_len,
|
|
|
|
u8 code, u8 identifier);
|
2008-02-28 02:34:43 +01:00
|
|
|
int eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
|
2015-08-23 20:22:22 +02:00
|
|
|
int verify_peer, int eap_type);
|
2008-02-28 02:34:43 +01:00
|
|
|
void eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
|
|
|
|
u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
|
2018-05-01 16:42:33 +02:00
|
|
|
const char *label, size_t len);
|
2014-11-29 22:46:45 +01:00
|
|
|
u8 * eap_server_tls_derive_session_id(struct eap_sm *sm,
|
|
|
|
struct eap_ssl_data *data, u8 eap_type,
|
|
|
|
size_t *len);
|
2008-05-28 08:57:17 +02:00
|
|
|
struct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data,
|
2008-05-28 08:59:55 +02:00
|
|
|
int eap_type, int version, u8 id);
|
|
|
|
struct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type, int version);
|
2008-05-28 08:57:17 +02:00
|
|
|
int eap_server_tls_phase1(struct eap_sm *sm, struct eap_ssl_data *data);
|
|
|
|
struct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm,
|
|
|
|
struct eap_ssl_data *data,
|
2009-12-20 17:17:55 +01:00
|
|
|
const struct wpabuf *plain);
|
2008-05-28 16:15:17 +02:00
|
|
|
int eap_server_tls_process(struct eap_sm *sm, struct eap_ssl_data *data,
|
|
|
|
struct wpabuf *respData, void *priv, int eap_type,
|
|
|
|
int (*proc_version)(struct eap_sm *sm, void *priv,
|
|
|
|
int peer_version),
|
|
|
|
void (*proc_msg)(struct eap_sm *sm, void *priv,
|
|
|
|
const struct wpabuf *respData));
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
#endif /* EAP_TLS_COMMON_H */
|