6703b341bb562d9dd78e1b6edf4b943c2a1c34df
[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 TLS negotiation complete
42 * - FAILED if a fatal TLS alert queued
43 * - NEED_MORE if more invocations to process/build needed
44 * - DESTROY_ME if a fatal TLS alert received
45 */
46 status_t (*process)(tls_handshake_t *this,
47 tls_handshake_type_t type, tls_reader_t *reader);
48
49 /**
50 * Build TLS handshake messages to send out.
51 *
52 * @param type type of created handshake message
53 * @param writer TLS data buffer to write to
54 * @return
55 * - SUCCESS if handshake complete
56 * - FAILED if handshake failed
57 * - NEED_MORE if more messages ready for delivery
58 * - INVALID_STATE if more input to process() required
59 */
60 status_t (*build)(tls_handshake_t *this,
61 tls_handshake_type_t *type, tls_writer_t *writer);
62
63 /**
64 * Check if the cipher spec for outgoing messages has changed.
65 *
66 * @return TRUE if cipher spec changed
67 */
68 bool (*cipherspec_changed)(tls_handshake_t *this);
69
70 /**
71 * Change the cipher spec for incoming messages.
72 *
73 * @return TRUE if cipher spec changed
74 */
75 bool (*change_cipherspec)(tls_handshake_t *this);
76
77 /**
78 * Check if the finished message was decoded successfully.
79 *
80 * @return TRUE if finished message was decoded successfully
81 */
82 bool (*finished)(tls_handshake_t *this);
83
84 /**
85 * Destroy a tls_handshake_t.
86 */
87 void (*destroy)(tls_handshake_t *this);
88 };
89
90 #endif /** TLS_HANDSHAKE_H_ @}*/