summaryrefslogtreecommitdiff
path: root/src/libtls/tls_eap.h
blob: c7da832cbbb1f392ab123167f81867782336ade7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright (C) 2010 Martin Willi
 * Copyright (C) 2010 revosec AG
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

/**
 * @defgroup tls_eap tls_eap
 * @{ @ingroup libtls
 */

#ifndef TLS_EAP_H_
#define TLS_EAP_H_

typedef struct tls_eap_t tls_eap_t;

#include <eap/eap.h>

#include "tls.h"

/**
 * TLS over EAP helper, as used by EAP-TLS and EAP-TTLS.
 */
struct tls_eap_t {

	/**
	 * Initiate TLS/TTLS/TNC over EAP exchange (as client).
	 *
	 * @param out			allocated EAP packet data to send
	 * @return
	 *						- NEED_MORE if more exchanges required
	 *						- FAILED if initiation failed
	 */
	status_t (*initiate)(tls_eap_t *this, chunk_t *out);

	/**
	 * Process a received EAP-TLS/TTLS/TNC packet, create response.
	 *
	 * @param in			EAP packet data to process
	 * @param out			allocated EAP packet data to send
	 * @return
	 *						- SUCCESS if TLS negotiation completed
	 *						- FAILED if TLS negotiation failed
	 *						- NEED_MORE if more exchanges required
	 */
	status_t (*process)(tls_eap_t *this, chunk_t in, chunk_t *out);

	/**
	 * Get the EAP-MSK.
	 *
	 * @return				MSK
	 */
	chunk_t (*get_msk)(tls_eap_t *this);

	/**
	 * Get the current EAP identifier.
	 *
	 * @return				identifier
	 */
	u_int8_t (*get_identifier)(tls_eap_t *this);

	/**
	 * Set the EAP identifier to a deterministic value, overwriting
	 * the randomly initialized default value.
	 *
	 * @param identifier	EAP identifier
	 */
	void (*set_identifier) (tls_eap_t *this, u_int8_t identifier);

	/**
	 * Destroy a tls_eap_t.
	 */
	void (*destroy)(tls_eap_t *this);
};

/**
 * Create a tls_eap instance.
 *
 * @param type				EAP type, EAP-TLS or EAP-TTLS
 * @param tls				TLS implementation
 * @param frag_size			maximum size of a TLS fragment we send
 * @param max_msg_count		maximum number of processed messages
 * @param include_length	if TRUE include length in non-fragmented packets
 */
tls_eap_t *tls_eap_create(eap_type_t type, tls_t *tls, size_t frag_size,
						  int max_msg_count, bool include_length);

#endif /** TLS_EAP_H_ @}*/