added generic TLS application data handler and specific EAP-TTLS instantiation
[strongswan.git] / src / libtls / tls_handshake.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tls_handshake tls_handshake
18 * @{ @ingroup libtls
19 */
20
21 #ifndef TLS_HANDSHAKE_H_
22 #define TLS_HANDSHAKE_H_
23
24 typedef struct tls_handshake_t tls_handshake_t;
25
26 #include "tls.h"
27 #include "tls_reader.h"
28 #include "tls_writer.h"
29
30 /**
31 * TLS handshake state machine interface.
32 */
33 struct tls_handshake_t {
34
35 /**
36 * Process received TLS handshake message.
37 *
38 * @param type TLS handshake message type
39 * @param reader TLS data buffer
40 * @return
41 * - SUCCESS if handshake complete
42 * - FAILED if handshake failed
43 * - NEED_MORE if another invocation of process/build needed
44 */
45 status_t (*process)(tls_handshake_t *this,
46 tls_handshake_type_t type, tls_reader_t *reader);
47
48 /**
49 * Build TLS handshake messages to send out.
50 *
51 * @param type type of created handshake message
52 * @param writer TLS data buffer to write to
53 * @return
54 * - SUCCESS if handshake complete
55 * - FAILED if handshake failed
56 * - NEED_MORE if more messages ready for delivery
57 * - INVALID_STATE if more input to process() required
58 */
59 status_t (*build)(tls_handshake_t *this,
60 tls_handshake_type_t *type, tls_writer_t *writer);
61
62 /**
63 * Check if the cipher spec for outgoing messages has changed.
64 *
65 * @return TRUE if cipher spec changed
66 */
67 bool (*cipherspec_changed)(tls_handshake_t *this);
68
69 /**
70 * Change the cipher spec for incoming messages.
71 *
72 * @return TRUE if cipher spec changed
73 */
74 bool (*change_cipherspec)(tls_handshake_t *this);
75
76 /**
77 * Check if the finished message was decoded successfully.
78 *
79 * @return TRUE if finished message was decoded successfully
80 */
81 bool (*finished)(tls_handshake_t *this);
82
83 /**
84 * Destroy a tls_handshake_t.
85 */
86 void (*destroy)(tls_handshake_t *this);
87 };
88
89 #endif /** TLS_HANDSHAKE_H_ @}*/