Botan  1.11.15
Public Member Functions | Static Public Member Functions
Botan::TLS::Server_Name_Indicator Class Reference

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::Server_Name_Indicator:
Botan::TLS::Extension

List of all members.

Public Member Functions

bool empty () const
std::string host_name () const
std::vector< byteserialize () const
 Server_Name_Indicator (const std::string &host_name)
 Server_Name_Indicator (TLS_Data_Reader &reader, u16bit extension_size)
Handshake_Extension_Type type () const

Static Public Member Functions

static Handshake_Extension_Type static_type ()

Detailed Description

Server Name Indicator extension (RFC 3546)

Definition at line 73 of file tls_extensions.h.


Constructor & Destructor Documentation

Botan::TLS::Server_Name_Indicator::Server_Name_Indicator ( const std::string &  host_name) [inline]

Definition at line 81 of file tls_extensions.h.

                                                        :
         sni_host_name(host_name) {}

Definition at line 129 of file tls_extensions.cpp.

References Botan::TLS::TLS_Data_Reader::discard_next(), Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_string(), and Botan::TLS::TLS_Data_Reader::get_u16bit().

   {
   /*
   * This is used by the server to confirm that it knew the name
   */
   if(extension_size == 0)
      return;

   u16bit name_bytes = reader.get_u16bit();

   if(name_bytes + 2 != extension_size)
      throw Decoding_Error("Bad encoding of SNI extension");

   while(name_bytes)
      {
      byte name_type = reader.get_byte();
      name_bytes--;

      if(name_type == 0) // DNS
         {
         sni_host_name = reader.get_string(2, 1, 65535);
         name_bytes -= (2 + sni_host_name.size());
         }
      else // some other unknown name type
         {
         reader.discard_next(name_bytes);
         name_bytes = 0;
         }
      }
   }

Member Function Documentation

bool Botan::TLS::Server_Name_Indicator::empty ( ) const [inline, virtual]
Returns:
if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 91 of file tls_extensions.h.

{ return sni_host_name == ""; }
std::string Botan::TLS::Server_Name_Indicator::host_name ( ) const [inline]

Definition at line 87 of file tls_extensions.h.

{ return sni_host_name; }
std::vector< byte > Botan::TLS::Server_Name_Indicator::serialize ( ) const [virtual]
Returns:
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 161 of file tls_extensions.cpp.

   {
   std::vector<byte> buf;

   size_t name_len = sni_host_name.size();

   buf.push_back(get_byte<u16bit>(0, name_len+3));
   buf.push_back(get_byte<u16bit>(1, name_len+3));
   buf.push_back(0); // DNS

   buf.push_back(get_byte<u16bit>(0, name_len));
   buf.push_back(get_byte<u16bit>(1, name_len));

   buf += std::make_pair(
      reinterpret_cast<const byte*>(sni_host_name.data()),
      sni_host_name.size());

   return buf;
   }

Definition at line 76 of file tls_extensions.h.

References Botan::TLS::TLSEXT_SERVER_NAME_INDICATION.

Referenced by type().

Returns:
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 79 of file tls_extensions.h.

References static_type().

{ return static_type(); }

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