Botan  1.10.9
Public Member Functions | List of all members
Botan::TLS_Client Class Reference

#include <tls_client.h>

Inheritance diagram for Botan::TLS_Client:
Botan::TLS_Connection

Public Member Functions

void add_client_cert (const X509_Certificate &cert, Private_Key *cert_key)
 
void close ()
 
bool is_closed () const
 
std::vector< X509_Certificatepeer_cert_chain () const
 
size_t read (byte &in)
 
size_t read (byte buf[], size_t buf_len)
 
 TLS_Client (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)
 
void write (byte out)
 
void write (const byte buf[], size_t buf_len)
 
 ~TLS_Client ()
 

Detailed Description

SSL/TLS Client

Definition at line 22 of file tls_client.h.

Constructor & Destructor Documentation

Botan::TLS_Client::TLS_Client ( 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 
)

TLS Client Constructor

Definition at line 84 of file tls_client.cpp.

87  :
88  input_fn(input_fn),
89  policy(policy),
90  rng(rng),
91  writer(output_fn)
92  {
93  initialize();
94  }
Botan::TLS_Client::~TLS_Client ( )

TLS Client Destructor

Definition at line 105 of file tls_client.cpp.

References close().

106  {
107  close();
108  for(size_t i = 0; i != certs.size(); i++)
109  delete certs[i].second;
110  delete state;
111  }

Member Function Documentation

void Botan::TLS_Client::add_client_cert ( const X509_Certificate cert,
Private_Key cert_key 
)

Definition at line 96 of file tls_client.cpp.

98  {
99  certs.push_back(std::make_pair(cert, cert_key));
100  }
void Botan::TLS_Client::close ( )
virtual

Close a TLS connection

Implements Botan::TLS_Connection.

Definition at line 204 of file tls_client.cpp.

References Botan::CLOSE_NOTIFY, and Botan::WARNING.

Referenced by ~TLS_Client().

bool Botan::TLS_Client::is_closed ( ) const

Check connection status

Definition at line 212 of file tls_client.cpp.

213  {
214  if(!active)
215  return true;
216  return false;
217  }
std::vector< X509_Certificate > Botan::TLS_Client::peer_cert_chain ( ) const
virtual

Return the peer's certificate chain

Implements Botan::TLS_Connection.

Definition at line 162 of file tls_client.cpp.

163  {
164  return peer_certs;
165  }
size_t Botan::TLS_Connection::read ( byte in)
inlineinherited

Definition at line 24 of file tls_connection.h.

References Botan::TLS_Connection::read().

Referenced by Botan::TLS_Connection::read().

24 { return read(&in, 1); }
virtual size_t read(byte[], size_t)=0
size_t Botan::TLS_Client::read ( byte  out[],
size_t  length 
)
virtual

Read from a TLS connection

Implements Botan::TLS_Connection.

Definition at line 182 of file tls_client.cpp.

References Botan::Record_Writer::flush(), Botan::SecureQueue::read(), and Botan::SecureQueue::size().

183  {
184  if(!active)
185  return 0;
186 
187  writer.flush();
188 
189  while(read_buf.size() == 0)
190  {
191  state_machine();
192  if(active == false)
193  break;
194  }
195 
196  size_t got = std::min<size_t>(read_buf.size(), length);
197  read_buf.read(out, got);
198  return got;
199  }
size_t read(byte[], size_t)
Definition: secqueue.cpp:137
size_t size() const
Definition: secqueue.cpp:190
void Botan::TLS_Connection::write ( byte  out)
inlineinherited

Definition at line 25 of file tls_connection.h.

References Botan::TLS_Connection::write().

Referenced by Botan::TLS_Connection::write().

25 { write(&out, 1); }
virtual void write(const byte[], size_t)=0
void Botan::TLS_Client::write ( const byte  buf[],
size_t  length 
)
virtual

Write to a TLS connection

Implements Botan::TLS_Connection.

Definition at line 170 of file tls_client.cpp.

References Botan::APPLICATION_DATA, Botan::INTERNAL_ERROR, and Botan::Record_Writer::send().

171  {
172  if(!active)
173  throw TLS_Exception(INTERNAL_ERROR,
174  "TLS_Client::write called while closed");
175 
176  writer.send(APPLICATION_DATA, buf, length);
177  }
void send(byte type, const byte input[], size_t length)
Definition: rec_wri.cpp:131

The documentation for this class was generated from the following files: