Botan: Botan::TLS_Client Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <tls_client.h>`

Inheritance diagram for Botan::TLS_Client:

## Public Member Functions
void | add_client_cert (const X509_Certificate &cert, Private_Key *cert_key)
void | close ()
bool | is_closed () const
std::vector< X509_Certificate > | peer_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 Botan::Record_Writer::alert(), close(), Botan::FATAL, Botan::HANDSHAKE_FAILURE, Botan::NO_ALERT_TYPE, Botan::TLS_Policy::pref_version(), Botan::Record_Writer::reset(), Botan::Record_Reader::reset(), Botan::Record_Writer::set_version(), and Botan::TLS_Exception::type().

106 {
107 close();
108 for(size_t i = 0; i != certs.size(); i++)
109 delete certs[i].second;
110 delete state;
111 }
Botan::TLS_Client::close
void close()
Definition: tls_client.cpp:204

## 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 is_closed(), and ~TLS_Client().

205 {
206 close(WARNING, CLOSE_NOTIFY);
207 }
Botan::WARNING
Definition: tls_magic.h:58
Botan::CLOSE_NOTIFY
Definition: tls_magic.h:63
Botan::TLS_Client::close
void close()
Definition: tls_client.cpp:204

bool Botan::TLS_Client::is_closed | ( |  | ) | const

Check connection status

Definition at line 212 of file tls_client.cpp.

References Botan::Record_Reader::add_input(), Botan::ALERT, Botan::Record_Writer::alert(), Botan::APPLICATION_DATA, Botan::BAD_CERTIFICATE, Botan::CERTIFICATE, Botan::CERTIFICATE_REQUEST, Botan::CHANGE_CIPHER_SPEC, Botan::TLS_Policy::check_cert(), Botan::CLIENT, Botan::Handshake_State::client_hello, close(), Botan::CLOSE_NOTIFY, Botan::CONNECTION_CLOSED, Botan::DECRYPT_ERROR, Botan::FINISHED, Botan::Record_Writer::flush(), Botan::Record_Reader::get_record(), Botan::HANDSHAKE, Botan::HANDSHAKE_CCS, Botan::HANDSHAKE_FAILURE, Botan::HANDSHAKE_NONE, Botan::HELLO_REQUEST, Botan::ILLEGAL_PARAMETER, Botan::Alert::is_fatal(), Botan::make_u32bit(), Botan::TLS_Policy::min_version(), Botan::PROTOCOL_VERSION, Botan::Record_Writer::reset(), Botan::Record_Reader::reset(), Botan::MemoryRegion< T >::resize(), Botan::Record_Writer::send(), Botan::SERVER, Botan::SERVER_HELLO, Botan::SERVER_HELLO_DONE, Botan::SERVER_KEX, Botan::Record_Writer::set_keys(), Botan::Record_Reader::set_keys(), Botan::Record_Writer::set_version(), Botan::Record_Reader::set_version(), Botan::MemoryRegion< T >::size(), Botan::TLS_ALGO_KEYEXCH_DH, Botan::TLS_ALGO_KEYEXCH_NOKEX, Botan::TLS_ALGO_KEYEXCH_RSA, Botan::TLS_ALGO_SIGNER_ANON, Botan::TLS_ALGO_SIGNER_DSA, Botan::TLS_ALGO_SIGNER_RSA, Botan::Alert::type(), Botan::UNSUPPORTED_CERTIFICATE, Botan::WARNING, and Botan::SecureQueue::write().

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); }
Botan::TLS_Connection::read
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 }
Botan::SecureQueue::read
size_t read(byte[], size_t)
Definition: secqueue.cpp:137
Botan::Record_Writer::flush
void flush()
Definition: rec_wri.cpp:162
Botan::SecureQueue::size
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); }
Botan::TLS_Connection::write
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 }
Botan::APPLICATION_DATA
Definition: tls_magic.h:37
Botan::INTERNAL_ERROR
Definition: tls_magic.h:83
Botan::Record_Writer::send
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:

- src/ssl/tls_client.h
- src/ssl/tls_client.cpp