renamed tls_reader|writer to bio_* and moved to libstrongswan
[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
28 #include <bio/bio_reader.h>
29 #include <bio/bio_writer.h>
30
31 /**
32 * TLS handshake state machine interface.
33 */
34 struct tls_handshake_t {
35
36 /**
37 * Process received TLS handshake message.
38 *
39 * @param type TLS handshake message type
40 * @param reader TLS data buffer
41 * @return
42 * - SUCCESS if TLS negotiation complete
43 * - FAILED if a fatal TLS alert queued
44 * - NEED_MORE if more invocations to process/build needed
45 * - DESTROY_ME if a fatal TLS alert received
46 */
47 status_t (*process)(tls_handshake_t *this,
48 tls_handshake_type_t type, bio_reader_t *reader);
49
50 /**
51 * Build TLS handshake messages to send out.
52 *
53 * @param type type of created handshake message
54 * @param writer TLS data buffer to write to
55 * @return
56 * - SUCCESS if handshake complete
57 * - FAILED if handshake failed
58 * - NEED_MORE if more messages ready for delivery
59 * - INVALID_STATE if more input to process() required
60 */
61 status_t (*build)(tls_handshake_t *this,
62 tls_handshake_type_t *type, bio_writer_t *writer);
63
64 /**
65 * Check if the cipher spec for outgoing messages has changed.
66 *
67 * @return TRUE if cipher spec changed
68 */
69 bool (*cipherspec_changed)(tls_handshake_t *this);
70
71 /**
72 * Change the cipher spec for incoming messages.
73 *
74 * @return TRUE if cipher spec changed
75 */
76 bool (*change_cipherspec)(tls_handshake_t *this);
77
78 /**
79 * Check if the finished message was decoded successfully.
80 *
81 * @return TRUE if finished message was decoded successfully
82 */
83 bool (*finished)(tls_handshake_t *this);
84
85 /**
86 * Destroy a tls_handshake_t.
87 */
88 void (*destroy)(tls_handshake_t *this);
89 };
90
91 #endif /** TLS_HANDSHAKE_H_ @}*/