Botan  1.11.15
Public Member Functions
Botan::TLS::Client_Hello Class Reference

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Client_Hello:
Botan::TLS::Handshake_Message

List of all members.

Public Member Functions

std::vector< u16bitciphersuites () const
 Client_Hello (Handshake_IO &io, Handshake_Hash &hash, Protocol_Version version, const Policy &policy, RandomNumberGenerator &rng, const std::vector< byte > &reneg_info, bool next_protocol=false, const std::string &hostname="", const std::string &srp_identifier="")
 Client_Hello (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, RandomNumberGenerator &rng, const std::vector< byte > &reneg_info, const Session &resumed_session, bool next_protocol=false)
 Client_Hello (const std::vector< byte > &buf)
std::vector< bytecompression_methods () const
std::set
< Handshake_Extension_Type
extension_types () const
size_t fragment_size () const
bool next_protocol_notification () const
bool offered_suite (u16bit ciphersuite) const
bool peer_can_send_heartbeats () const
const std::vector< byte > & random () const
std::vector< byterenegotiation_info () const
bool secure_renegotiation () const
bool sent_fallback_scsv () const
const std::vector< byte > & session_id () const
std::vector< bytesession_ticket () const
std::string sni_hostname () const
std::string srp_identifier () const
std::vector< u16bitsrtp_profiles () const
std::vector< std::pair
< std::string, std::string > > 
supported_algos () const
std::vector< std::string > supported_ecc_curves () const
bool supports_heartbeats () const
bool supports_session_ticket () const
Handshake_Type type () const override
void update_hello_cookie (const Hello_Verify_Request &hello_verify)
Protocol_Version version () const

Detailed Description

Client Hello Message

Definition at line 59 of file tls_messages.h.


Constructor & Destructor Documentation

Botan::TLS::Client_Hello::Client_Hello ( Handshake_IO io,
Handshake_Hash hash,
Protocol_Version  version,
const Policy policy,
RandomNumberGenerator rng,
const std::vector< byte > &  reneg_info,
bool  next_protocol = false,
const std::string &  hostname = "",
const std::string &  srp_identifier = "" 
)

Definition at line 69 of file msg_client_hello.cpp.

References Botan::TLS::Policy::acceptable_protocol_version(), Botan::Extensions::add(), Botan::TLS::Policy::allowed_ecc_curves(), Botan::TLS::Policy::allowed_signature_hashes(), Botan::TLS::Policy::allowed_signature_methods(), BOTAN_ASSERT, Botan::TLS::Protocol_Version::is_datagram_protocol(), Botan::TLS::Policy::negotiate_heartbeat_support(), Botan::TLS::Handshake_IO::send(), Botan::TLS::Policy::send_fallback_scsv(), Botan::TLS::Policy::srtp_profiles(), Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms(), Botan::TLS::TLS_FALLBACK_SCSV, and Botan::TLS::Handshake_Hash::update().

                                                            :
   m_version(version),
   m_random(make_hello_random(rng, policy)),
   m_suites(policy.ciphersuite_list(m_version, (srp_identifier != ""))),
   m_comp_methods(policy.compression())
   {
   m_extensions.add(new Renegotiation_Extension(reneg_info));
   m_extensions.add(new SRP_Identifier(srp_identifier));
   m_extensions.add(new Server_Name_Indicator(hostname));
   m_extensions.add(new Session_Ticket());
   m_extensions.add(new Supported_Elliptic_Curves(policy.allowed_ecc_curves()));

   if(policy.negotiate_heartbeat_support())
      m_extensions.add(new Heartbeat_Support_Indicator(true));

   if(m_version.supports_negotiable_signature_algorithms())
      m_extensions.add(new Signature_Algorithms(policy.allowed_signature_hashes(),
                                                policy.allowed_signature_methods()));

   if(m_version.is_datagram_protocol())
     m_extensions.add(new SRTP_Protection_Profiles(policy.srtp_profiles()));

   if(reneg_info.empty() && next_protocol)
      m_extensions.add(new Next_Protocol_Notification());

   BOTAN_ASSERT(policy.acceptable_protocol_version(version),
                "Our policy accepts the version we are offering");

   if(policy.send_fallback_scsv(version))
      m_suites.push_back(TLS_FALLBACK_SCSV);

   hash.update(io.send(*this));
   }
Botan::TLS::Client_Hello::Client_Hello ( Handshake_IO io,
Handshake_Hash hash,
const Policy policy,
RandomNumberGenerator rng,
const std::vector< byte > &  reneg_info,
const Session resumed_session,
bool  next_protocol = false 
)

Definition at line 114 of file msg_client_hello.cpp.

References Botan::Extensions::add(), Botan::TLS::Policy::allowed_ecc_curves(), Botan::TLS::Policy::allowed_signature_hashes(), Botan::TLS::Policy::allowed_signature_methods(), Botan::TLS::Session::ciphersuite_code(), Botan::TLS::Session::compression_method(), Botan::TLS::Session::fragment_size(), Botan::TLS::Server_Information::hostname(), Botan::TLS::Policy::negotiate_heartbeat_support(), Botan::TLS::Handshake_IO::send(), Botan::TLS::Session::server_info(), Botan::TLS::Session::session_ticket(), Botan::TLS::Session::srp_identifier(), Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms(), Botan::TLS::Handshake_Hash::update(), and Botan::value_exists().

                                               :
   m_version(session.version()),
   m_session_id(session.session_id()),
   m_random(make_hello_random(rng, policy)),
   m_suites(policy.ciphersuite_list(m_version, (session.srp_identifier() != ""))),
   m_comp_methods(policy.compression())
   {
   if(!value_exists(m_suites, session.ciphersuite_code()))
      m_suites.push_back(session.ciphersuite_code());

   if(!value_exists(m_comp_methods, session.compression_method()))
      m_comp_methods.push_back(session.compression_method());

   m_extensions.add(new Renegotiation_Extension(reneg_info));
   m_extensions.add(new SRP_Identifier(session.srp_identifier()));
   m_extensions.add(new Server_Name_Indicator(session.server_info().hostname()));
   m_extensions.add(new Session_Ticket(session.session_ticket()));
   m_extensions.add(new Supported_Elliptic_Curves(policy.allowed_ecc_curves()));

   if(policy.negotiate_heartbeat_support())
      m_extensions.add(new Heartbeat_Support_Indicator(true));

   if(session.fragment_size() != 0)
      m_extensions.add(new Maximum_Fragment_Length(session.fragment_size()));

   if(m_version.supports_negotiable_signature_algorithms())
      m_extensions.add(new Signature_Algorithms(policy.allowed_signature_hashes(),
                                                policy.allowed_signature_methods()));

   if(reneg_info.empty() && next_protocol)
      m_extensions.add(new Next_Protocol_Notification());

   hash.update(io.send(*this));
   }
Botan::TLS::Client_Hello::Client_Hello ( const std::vector< byte > &  buf)

Definition at line 196 of file msg_client_hello.cpp.

References Botan::Extensions::add(), Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_fixed(), Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::TLS_Data_Reader::get_range_vector(), Botan::TLS::Alert::HANDSHAKE_FAILURE, Botan::TLS::Protocol_Version::is_datagram_protocol(), offered_suite(), and Botan::TLS::TLS_EMPTY_RENEGOTIATION_INFO_SCSV.

   {
   if(buf.size() == 0)
      throw Decoding_Error("Client_Hello: Packet corrupted");

   if(buf.size() < 41)
      throw Decoding_Error("Client_Hello: Packet corrupted");

   TLS_Data_Reader reader("ClientHello", buf);

   const byte major_version = reader.get_byte();
   const byte minor_version = reader.get_byte();

   m_version = Protocol_Version(major_version, minor_version);

   m_random = reader.get_fixed<byte>(32);

   if(m_version.is_datagram_protocol())
      m_hello_cookie = reader.get_range<byte>(1, 0, 255);

   m_session_id = reader.get_range<byte>(1, 0, 32);

   m_suites = reader.get_range_vector<u16bit>(2, 1, 32767);

   m_comp_methods = reader.get_range_vector<byte>(1, 1, 255);

   m_extensions.deserialize(reader);

   if(offered_suite(static_cast<u16bit>(TLS_EMPTY_RENEGOTIATION_INFO_SCSV)))
      {
      if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
         {
         if(!reneg->renegotiation_info().empty())
            throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
                                "Client sent renegotiation SCSV and non-empty extension");
         }
      else
         {
         // add fake extension
         m_extensions.add(new Renegotiation_Extension());
         }
      }
   }

Member Function Documentation

std::vector<u16bit> Botan::TLS::Client_Hello::ciphersuites ( ) const [inline]

Definition at line 70 of file tls_messages.h.

{ return m_suites; }
std::vector<byte> Botan::TLS::Client_Hello::compression_methods ( ) const [inline]

Definition at line 72 of file tls_messages.h.

{ return m_comp_methods; }

Definition at line 163 of file tls_messages.h.

         { return m_extensions.extension_types(); }
size_t Botan::TLS::Client_Hello::fragment_size ( ) const [inline]

Definition at line 123 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         if(Maximum_Fragment_Length* frag = m_extensions.get<Maximum_Fragment_Length>())
            return frag->fragment_size();
         return 0;
         }

Definition at line 118 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         return m_extensions.has<Next_Protocol_Notification>();
         }
bool Botan::TLS::Client_Hello::offered_suite ( u16bit  ciphersuite) const

Definition at line 248 of file msg_client_hello.cpp.

Referenced by Client_Hello(), and sent_fallback_scsv().

   {
   for(size_t i = 0; i != m_suites.size(); ++i)
      if(m_suites[i] == ciphersuite)
         return true;
   return false;
   }

Definition at line 147 of file tls_messages.h.

         {
         if(Heartbeat_Support_Indicator* hb = m_extensions.get<Heartbeat_Support_Indicator>())
            return hb->peer_allowed_to_send();
         return false;
         }
const std::vector<byte>& Botan::TLS::Client_Hello::random ( ) const [inline]

Definition at line 66 of file tls_messages.h.

{ return m_random; }
std::vector<byte> Botan::TLS::Client_Hello::renegotiation_info ( ) const [inline]

Definition at line 111 of file tls_messages.h.

         {
         if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
            return reneg->renegotiation_info();
         return std::vector<byte>();
         }

Definition at line 106 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         return m_extensions.has<Renegotiation_Extension>();
         }

Definition at line 240 of file msg_client_hello.cpp.

References offered_suite(), and Botan::TLS::TLS_FALLBACK_SCSV.

   {
   return offered_suite(static_cast<u16bit>(TLS_FALLBACK_SCSV));
   }
const std::vector<byte>& Botan::TLS::Client_Hello::session_id ( ) const [inline]

Definition at line 68 of file tls_messages.h.

{ return m_session_id; }
std::vector<byte> Botan::TLS::Client_Hello::session_ticket ( ) const [inline]

Definition at line 135 of file tls_messages.h.

Referenced by Botan::TLS::Handshake_State::session_ticket().

         {
         if(Session_Ticket* ticket = m_extensions.get<Session_Ticket>())
            return ticket->contents();
         return std::vector<byte>();
         }
std::string Botan::TLS::Client_Hello::sni_hostname ( ) const [inline]

Definition at line 92 of file tls_messages.h.

         {
         if(Server_Name_Indicator* sni = m_extensions.get<Server_Name_Indicator>())
            return sni->host_name();
         return "";
         }
std::string Botan::TLS::Client_Hello::srp_identifier ( ) const [inline]

Definition at line 99 of file tls_messages.h.

Referenced by Botan::TLS::Handshake_State::srp_identifier().

         {
         if(SRP_Identifier* srp = m_extensions.get<SRP_Identifier>())
            return srp->identifier();
         return "";
         }
std::vector<u16bit> Botan::TLS::Client_Hello::srtp_profiles ( ) const [inline]

Definition at line 154 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         if(SRTP_Protection_Profiles* srtp = m_extensions.get<SRTP_Protection_Profiles>())
            return srtp->profiles();
         return std::vector<u16bit>();
         }
std::vector<std::pair<std::string, std::string> > Botan::TLS::Client_Hello::supported_algos ( ) const [inline]

Definition at line 78 of file tls_messages.h.

         {
         if(Signature_Algorithms* sigs = m_extensions.get<Signature_Algorithms>())
            return sigs->supported_signature_algorthms();
         return std::vector<std::pair<std::string, std::string>>();
         }
std::vector<std::string> Botan::TLS::Client_Hello::supported_ecc_curves ( ) const [inline]

Definition at line 85 of file tls_messages.h.

         {
         if(Supported_Elliptic_Curves* ecc = m_extensions.get<Supported_Elliptic_Curves>())
            return ecc->curves();
         return std::vector<std::string>();
         }

Definition at line 142 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         return m_extensions.has<Heartbeat_Support_Indicator>();
         }

Definition at line 130 of file tls_messages.h.

Referenced by Botan::TLS::Server_Hello::Server_Hello().

         {
         return m_extensions.has<Session_Ticket>();
         }
Handshake_Type Botan::TLS::Client_Hello::type ( ) const [inline, override, virtual]

Implements Botan::TLS::Handshake_Message.

Definition at line 62 of file tls_messages.h.

References Botan::TLS::CLIENT_HELLO.

{ return CLIENT_HELLO; }

Definition at line 155 of file msg_client_hello.cpp.

References Botan::TLS::Hello_Verify_Request::cookie(), and Botan::TLS::Protocol_Version::is_datagram_protocol().

   {
   if(!m_version.is_datagram_protocol())
      throw std::runtime_error("Cannot use hello cookie with stream protocol");

   m_hello_cookie = hello_verify.cookie();
   }

Definition at line 64 of file tls_messages.h.

{ return m_version; }

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