Botan 1.10.17

tls_server.h
Go to the documentation of this file.
1 /*
2 * TLS Server
3 * (C) 2004-2010 Jack Lloyd
4 *
5 * Released under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_TLS_SERVER_H__
9 #define BOTAN_TLS_SERVER_H__
10
11 #include <botan/tls_connection.h>
12 #include <botan/tls_record.h>
13 #include <botan/tls_policy.h>
14 #include <vector>
15
16 namespace Botan {
17
18 /**
19 * TLS Server
20 */
21 class BOTAN_DLL TLS_Server : public TLS_Connection
22 {
23 public:
24 size_t read(byte buf[], size_t buf_len);
25 void write(const byte buf[], size_t buf_len);
26
27 std::vector<X509_Certificate> peer_cert_chain() const;
28
29 std::string requested_hostname() const
30 { return client_requested_hostname; }
31
32 void close();
33 bool is_closed() const;
34
35 /*
36 * FIXME: support cert chains (!)
37 * FIXME: support anonymous servers
38 */
39 TLS_Server(std::tr1::function<size_t (byte[], size_t)> input_fn,
40 std::tr1::function<void (const byte[], size_t)> output_fn,
41 const TLS_Policy& policy,
42 RandomNumberGenerator& rng,
43 const X509_Certificate& cert,
44 const Private_Key& cert_key);
45
46 ~TLS_Server();
47 private:
48 void close(Alert_Level, Alert_Type);
49
50 void do_handshake();
51 void state_machine();
52 void read_handshake(byte, const MemoryRegion<byte>&);
53
54 void process_handshake_msg(Handshake_Type, const MemoryRegion<byte>&);
55
56 std::tr1::function<size_t (byte[], size_t)> input_fn;
57
58 const TLS_Policy& policy;
59 RandomNumberGenerator& rng;
60
61 Record_Writer writer;
62 Record_Reader reader;
63
64 // FIXME: rename to match TLS_Client
65 std::vector<X509_Certificate> cert_chain, peer_certs;
66 Private_Key* private_key;
67
68 class Handshake_State* state;
69 SecureVector<byte> session_id;
70 SecureQueue read_buf;
71 std::string client_requested_hostname;
72 bool active;
73 };
74
75 }
76
77 #endif
Botan::SecureQueue
Definition: secqueue.h:19
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::Private_Key
Definition: pk_keys.h:86
Botan::TLS_Connection
Definition: tls_connection.h:19
Botan::TLS_Server::requested_hostname
std::string requested_hostname() const
Definition: tls_server.h:29
Botan::Handshake_Type
Handshake_Type
Definition: tls_magic.h:40
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Alert_Level
Alert_Level
Definition: tls_magic.h:57
Botan::X509_Certificate
Definition: x509cert.h:23
Botan::Record_Reader
Definition: tls_record.h:79
Botan::TLS_Server
Definition: tls_server.h:21
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::Record_Writer
Definition: tls_record.h:39
Botan::Alert_Type
Alert_Type
Definition: tls_magic.h:62
Botan::TLS_Policy
Definition: tls_policy.h:22
Botan::SecureVector< byte >
Botan::Handshake_State
Definition: tls_state.h:19