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

#include <tls_messages.h>

Inheritance diagram for Botan::Server_Hello:
Botan::HandshakeMessage

Public Member Functions

u16bit ciphersuite () const
 
byte compression_algo () const
 
const SecureVector< byte > & random () const
 
void send (Record_Writer &, HandshakeHash &) const
 
 Server_Hello (RandomNumberGenerator &rng, Record_Writer &, const TLS_Policy &, const std::vector< X509_Certificate > &, const Client_Hello &, Version_Code, HandshakeHash &)
 
 Server_Hello (const MemoryRegion< byte > &buf)
 
const SecureVector< byte > & session_id () const
 
Handshake_Type type () const
 
Version_Code version ()
 

Detailed Description

Server Hello Message

Definition at line 226 of file tls_messages.h.

Constructor & Destructor Documentation

Botan::Server_Hello::Server_Hello ( RandomNumberGenerator rng,
Record_Writer writer,
const TLS_Policy policy,
const std::vector< X509_Certificate > &  certs,
const Client_Hello c_hello,
Version_Code  ver,
HandshakeHash hash 
)

Definition at line 223 of file hello.cpp.

References Botan::Public_Key::algo_name(), Botan::TLS_Policy::choose_compression(), Botan::TLS_Policy::choose_suite(), Botan::Client_Hello::ciphersuites(), Botan::Client_Hello::compression_algos(), Botan::PROTOCOL_VERSION, Botan::RandomNumberGenerator::random_vec(), and Botan::HandshakeMessage::send().

230  {
231  bool have_rsa = false, have_dsa = false;
232 
233  for(size_t i = 0; i != certs.size(); ++i)
234  {
235  Public_Key* key = certs[i].subject_public_key();
236  if(key->algo_name() == "RSA")
237  have_rsa = true;
238 
239  if(key->algo_name() == "DSA")
240  have_dsa = true;
241  }
242 
243  suite = policy.choose_suite(c_hello.ciphersuites(), have_rsa, have_dsa);
244 
245  if(suite == 0)
246  throw TLS_Exception(PROTOCOL_VERSION,
247  "Can't agree on a ciphersuite with client");
248 
249  comp_algo = policy.choose_compression(c_hello.compression_algos());
250 
251  s_version = ver;
252  s_random = rng.random_vec(32);
253 
254  send(writer, hash);
255  }
void send(Record_Writer &, HandshakeHash &) const
Definition: hello.cpp:16
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
Botan::Server_Hello::Server_Hello ( const MemoryRegion< byte > &  buf)
inline

Definition at line 242 of file tls_messages.h.

242 { deserialize(buf); }

Member Function Documentation

u16bit Botan::Server_Hello::ciphersuite ( ) const
inline

Definition at line 232 of file tls_messages.h.

232 { return suite; }
byte Botan::Server_Hello::compression_algo ( ) const
inline

Definition at line 233 of file tls_messages.h.

233 { return comp_algo; }
const SecureVector<byte>& Botan::Server_Hello::random ( ) const
inline

Definition at line 235 of file tls_messages.h.

235 { return s_random; }
void Botan::HandshakeMessage::send ( Record_Writer writer,
HandshakeHash hash 
) const
inherited

Definition at line 16 of file hello.cpp.

References Botan::Record_Writer::flush(), Botan::HANDSHAKE, Botan::Record_Writer::send(), Botan::MemoryRegion< T >::size(), Botan::HandshakeMessage::type(), and Botan::HandshakeHash::update().

Referenced by Botan::Certificate::Certificate(), Botan::Certificate_Req::Certificate_Req(), Botan::Certificate_Verify::Certificate_Verify(), Botan::Client_Hello::Client_Hello(), Botan::Client_Key_Exchange::Client_Key_Exchange(), Botan::Finished::Finished(), Botan::Hello_Request::Hello_Request(), Server_Hello(), Botan::Server_Hello_Done::Server_Hello_Done(), and Botan::Server_Key_Exchange::Server_Key_Exchange().

17  {
18  SecureVector<byte> buf = serialize();
19  SecureVector<byte> send_buf(4);
20 
21  const size_t buf_size = buf.size();
22 
23  send_buf[0] = type();
24 
25  for(size_t i = 1; i != 4; ++i)
26  send_buf[i] = get_byte<u32bit>(i, buf_size);
27 
28  send_buf += buf;
29 
30  hash.update(send_buf);
31 
32  writer.send(HANDSHAKE, &send_buf[0], send_buf.size());
33  writer.flush();
34  }
virtual Handshake_Type type() const =0
const SecureVector<byte>& Botan::Server_Hello::session_id ( ) const
inline

Definition at line 231 of file tls_messages.h.

231 { return sess_id; }
Handshake_Type Botan::Server_Hello::type ( ) const
inlinevirtual

Implements Botan::HandshakeMessage.

Definition at line 229 of file tls_messages.h.

References Botan::SERVER_HELLO.

229 { return SERVER_HELLO; }
Version_Code Botan::Server_Hello::version ( )
inline

Definition at line 230 of file tls_messages.h.

230 { return s_version; }

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