Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

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

Public Member Functions | Static Public Member Functions | List of all members
Botan::TLS::Server_Name_Indicator Class Referencefinal

`#include <tls_extensions.h>`

Inheritance diagram for Botan::TLS::Server_Name_Indicator:

## Public Member Functions
bool | empty () const override
std::string | host_name () const
std::vector< uint8_t > | serialize () const override
| Server_Name_Indicator (const std::string &host_name)
| Server_Name_Indicator (TLS_Data_Reader &reader, uint16_t extension_size)
Handshake_Extension_Type | type () const override

## Static Public Member Functions
static Handshake_Extension_Type | static_type ()

## Detailed Description

Server Name Indicator extension (RFC 3546)

Definition at line 74 of file tls_extensions.h.

## Constructor & Destructor Documentation

Botan::TLS::Server_Name_Indicator::Server_Name_Indicator | ( | const std::string & | host_name | ) |
| inline explicit

Definition at line 82 of file tls_extensions.h.

82 :
83 m_sni_host_name(host_name) {}
Botan::TLS::Server_Name_Indicator::host_name
std::string host_name() const
Definition: tls_extensions.h:88

Botan::TLS::Server_Name_Indicator::Server_Name_Indicator | ( | TLS_Data_Reader & | reader,
|  | uint16_t | extension_size
| ) |  |

Definition at line 135 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_uint16_t().

137 {
138 /*
139 * This is used by the server to confirm that it knew the name
140 */
141 if(extension_size == 0)
142 return;
143
144 uint16_t name_bytes = reader.get_uint16_t();
145
146 if(name_bytes + 2 != extension_size)
147 throw Decoding_Error("Bad encoding of SNI extension");
148
149 while(name_bytes)
150 {
151 uint8_t name_type = reader.get_byte();
152 name_bytes--;
153
154 if(name_type == 0) // DNS
155 {
156 m_sni_host_name = reader.get_string(2, 1, 65535);
157 name_bytes -= static_cast<uint16_t>(2 + m_sni_host_name.size());
158 }
159 else // some other unknown name type
160 {
161 reader.discard_next(name_bytes);
162 name_bytes = 0;
163 }
164 }
165 }

## Member Function Documentation

bool Botan::TLS::Server_Name_Indicator::empty | ( |  | ) | const
| inline override virtual

Returns
  if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 92 of file tls_extensions.h.

92 { return m_sni_host_name.empty(); }

std::string Botan::TLS::Server_Name_Indicator::host_name | ( |  | ) | const
| inline

Definition at line 88 of file tls_extensions.h.

88 { return m_sni_host_name; }

std::vector< uint8_t > Botan::TLS::Server_Name_Indicator::serialize | ( |  | ) | const
| override virtual

Returns
  serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 167 of file tls_extensions.cpp.

References Botan::get_byte().

168 {
169 std::vector<uint8_t> buf;
170
171 size_t name_len = m_sni_host_name.size();
172
173 buf.push_back(get_byte(0, static_cast<uint16_t>(name_len+3)));
174 buf.push_back(get_byte(1, static_cast<uint16_t>(name_len+3)));
175 buf.push_back(0); // DNS
176
177 buf.push_back(get_byte(0, static_cast<uint16_t>(name_len)));
178 buf.push_back(get_byte(1, static_cast<uint16_t>(name_len)));
179
180 buf += std::make_pair(
181 reinterpret_cast<const uint8_t*>(m_sni_host_name.data()),
182 m_sni_host_name.size());
183
184 return buf;
185 }
Botan::get_byte
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:47

static Handshake_Extension_Type Botan::TLS::Server_Name_Indicator::static_type | ( |  | ) |
| inline static

Definition at line 77 of file tls_extensions.h.

References Botan::TLS::TLSEXT_SERVER_NAME_INDICATION.

Referenced by type().

78 { return TLSEXT_SERVER_NAME_INDICATION; }
Botan::TLS::TLSEXT_SERVER_NAME_INDICATION
Definition: tls_extensions.h:28

Handshake_Extension_Type Botan::TLS::Server_Name_Indicator::type | ( |  | ) | const
| inline override virtual

Returns
  code number of the extension

Implements Botan::TLS::Extension.

Definition at line 80 of file tls_extensions.h.

References static_type().

80 { return static_type(); }
Botan::TLS::Server_Name_Indicator::static_type
static Handshake_Extension_Type static_type()
Definition: tls_extensions.h:77

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

- src/lib/tls/tls_extensions.h
- src/lib/tls/tls_extensions.cpp