2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
|
2012-04-07 19:57:02 +02:00
|
|
|
* Copyright (c) 2004-2009, 2012, 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
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct eap_ssl_data - TLS data for EAP methods
|
|
|
|
*/
|
|
|
|
struct eap_ssl_data {
|
|
|
|
/**
|
|
|
|
* conn - TLS connection context data from tls_connection_init()
|
|
|
|
*/
|
|
|
|
struct tls_connection *conn;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_out - TLS message to be sent out in fragments
|
|
|
|
*/
|
2009-12-20 17:17:55 +01:00
|
|
|
struct wpabuf *tls_out;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
size_t tls_out_limit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_in - Received TLS message buffer for re-assembly
|
|
|
|
*/
|
2009-12-20 17:17:55 +01:00
|
|
|
struct wpabuf *tls_in;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_in_left - Number of remaining bytes in the incoming TLS message
|
|
|
|
*/
|
|
|
|
size_t tls_in_left;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_in_total - Total number of bytes in the incoming TLS message
|
|
|
|
*/
|
|
|
|
size_t tls_in_total;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
|
|
|
|
*/
|
|
|
|
int phase2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* include_tls_length - Whether the TLS length field is included even
|
|
|
|
* if the TLS data is not fragmented
|
|
|
|
*/
|
|
|
|
int include_tls_length;
|
|
|
|
|
|
|
|
/**
|
2009-12-23 23:16:58 +01:00
|
|
|
* eap - EAP state machine allocated with eap_peer_sm_init()
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
struct eap_sm *eap;
|
2012-04-07 19:57:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ssl_ctx - TLS library context to use for the connection
|
|
|
|
*/
|
|
|
|
void *ssl_ctx;
|
2012-08-17 21:26:28 +02:00
|
|
|
|
|
|
|
/**
|
2019-07-09 15:56:02 +02:00
|
|
|
* eap_type - EAP method used in Phase 1
|
|
|
|
* (EAP_TYPE_TLS/PEAP/TTLS/FAST/TEAP)
|
2012-08-17 21:26:28 +02:00
|
|
|
*/
|
|
|
|
u8 eap_type;
|
2018-05-01 16:45:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* tls_v13 - Whether TLS v1.3 or newer is used
|
|
|
|
*/
|
|
|
|
int tls_v13;
|
2023-07-08 18:55:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* client_cert_conf: Whether client certificate has been configured
|
|
|
|
*/
|
|
|
|
bool client_cert_conf;
|
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
|
2019-07-09 15:56:02 +02:00
|
|
|
#define EAP_TEAP_FLAGS_OUTER_TLV_LEN 0x10
|
2009-12-23 23:16:58 +01: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
|
|
|
|
|
2021-09-19 08:24:29 +02:00
|
|
|
/* stub type used as a flag for UNAUTH-TLS */
|
2012-08-22 21:34:11 +02:00
|
|
|
#define EAP_UNAUTH_TLS_TYPE 255
|
2013-07-23 20:21:36 +02:00
|
|
|
#define EAP_WFA_UNAUTH_TLS_TYPE 254
|
2012-08-22 21:34:11 +02:00
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
|
2012-08-17 21:26:28 +02:00
|
|
|
struct eap_peer_config *config, u8 eap_type);
|
2008-02-28 02:34:43 +01:00
|
|
|
void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
|
|
|
|
u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
|
2019-03-11 12:21:36 +01:00
|
|
|
const char *label, const u8 *context,
|
|
|
|
size_t context_len, size_t len);
|
2013-02-06 17:52:33 +01:00
|
|
|
u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
|
|
|
|
struct eap_ssl_data *data, u8 eap_type,
|
|
|
|
size_t *len);
|
2008-02-28 02:34:43 +01:00
|
|
|
int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
|
2019-08-17 10:36:20 +02:00
|
|
|
enum eap_type eap_type, int peap_version,
|
2015-05-02 15:42:19 +02:00
|
|
|
u8 id, const struct wpabuf *in_data,
|
2008-02-28 02:34:43 +01:00
|
|
|
struct wpabuf **out_data);
|
2019-08-17 10:36:20 +02:00
|
|
|
struct wpabuf * eap_peer_tls_build_ack(u8 id, enum eap_type eap_type,
|
2008-02-28 02:34:43 +01:00
|
|
|
int peap_version);
|
|
|
|
int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data);
|
|
|
|
int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
|
|
|
|
char *buf, size_t buflen, int verbose);
|
|
|
|
const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
|
|
|
|
struct eap_ssl_data *data,
|
2019-08-17 10:36:20 +02:00
|
|
|
enum eap_type eap_type,
|
2008-02-28 02:34:43 +01:00
|
|
|
struct eap_method_ret *ret,
|
|
|
|
const struct wpabuf *reqData,
|
|
|
|
size_t *len, u8 *flags);
|
|
|
|
void eap_peer_tls_reset_input(struct eap_ssl_data *data);
|
|
|
|
void eap_peer_tls_reset_output(struct eap_ssl_data *data);
|
|
|
|
int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
|
|
|
const struct wpabuf *in_data,
|
|
|
|
struct wpabuf **in_decrypted);
|
|
|
|
int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
2019-08-17 10:36:20 +02:00
|
|
|
enum eap_type eap_type, int peap_version, u8 id,
|
2008-02-28 02:34:43 +01:00
|
|
|
const struct wpabuf *in_data,
|
|
|
|
struct wpabuf **out_data);
|
|
|
|
int eap_peer_select_phase2_methods(struct eap_peer_config *config,
|
|
|
|
const char *prefix,
|
|
|
|
struct eap_method_type **types,
|
2019-09-01 15:44:51 +02:00
|
|
|
size_t *num_types, int use_machine_cred);
|
2008-02-28 02:34:43 +01:00
|
|
|
int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
|
|
|
|
struct eap_hdr *hdr, struct wpabuf **resp);
|
|
|
|
|
|
|
|
#endif /* EAP_TLS_COMMON_H */
|