Botan  1.10.9
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,
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;
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
Handshake_Type
Definition: tls_magic.h:40
unsigned char byte
Definition: types.h:22
Alert_Level
Definition: tls_magic.h:57
RC4_KEY state
Definition: ossl_arc4.cpp:39
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
Alert_Type
Definition: tls_magic.h:62