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
16namespace Botan {
17
18/**
19* TLS Server
20*/
21class 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,
43 const X509_Certificate& cert,
44 const Private_Key& cert_key);
45
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;
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
std::vector< X509_Certificate > peer_cert_chain() const
void write(const byte buf[], size_t buf_len)
TLS_Server(std::tr1::function< size_t(byte[], size_t)> input_fn, std::tr1::function< void(const byte[], size_t)> output_fn, const TLS_Policy &policy, RandomNumberGenerator &rng, const X509_Certificate &cert, const Private_Key &cert_key)
size_t read(byte buf[], size_t buf_len)
std::string requested_hostname() const
Definition tls_server.h:29
Alert_Type
Definition tls_magic.h:62
Handshake_Type
Definition tls_magic.h:40
Alert_Level
Definition tls_magic.h:57