Botan 1.10.17

tls_client.h
Go to the documentation of this file.
1 /*
2 * TLS Client
3 * (C) 2004-2010 Jack Lloyd
4 *
5 * Released under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_TLS_CLIENT_H__
9 #define BOTAN_TLS_CLIENT_H__
10
11 #include <botan/tls_connection.h>
12 #include <botan/tls_policy.h>
13 #include <botan/tls_record.h>
14 #include <vector>
15 #include <string>
16
17 namespace Botan {
18
19 /**
20 * SSL/TLS Client
21 */
22 class BOTAN_DLL TLS_Client : public TLS_Connection
23 {
24 public:
25 size_t read(byte buf[], size_t buf_len);
26 void write(const byte buf[], size_t buf_len);
27
28 void close();
29 bool is_closed() const;
30
31 std::vector<X509_Certificate> peer_cert_chain() const;
32
33 void add_client_cert(const X509_Certificate& cert,
34 Private_Key* cert_key);
35
36 TLS_Client(std::tr1::function<size_t (byte[], size_t)> input_fn,
37 std::tr1::function<void (const byte[], size_t)> output_fn,
38 const TLS_Policy& policy,
39 RandomNumberGenerator& rng);
40
41 ~TLS_Client();
42 private:
43 void close(Alert_Level, Alert_Type);
44
45 size_t get_pending_socket_input(byte output[], size_t length);
46
47 void initialize();
48 void do_handshake();
49
50 void state_machine();
51 void read_handshake(byte, const MemoryRegion<byte>&);
52 void process_handshake_msg(Handshake_Type, const MemoryRegion<byte>&);
53
54 std::tr1::function<size_t (byte[], size_t)> input_fn;
55
56 const TLS_Policy& policy;
57 RandomNumberGenerator& rng;
58
59 Record_Writer writer;
60 Record_Reader reader;
61
62 std::vector<X509_Certificate> peer_certs;
63 std::vector<std::pair<X509_Certificate, Private_Key*> > certs;
64
65 class Handshake_State* state;
66 SecureVector<byte> session_id;
67 SecureQueue read_buf;
68 bool active;
69 };
70
71 }
72
73 #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::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_Client
Definition: tls_client.h:22
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