|
Botan
1.11.15
|
#include <tls_extensions.h>
Public Member Functions | |
| bool | empty () const |
| std::string | host_name () const |
| std::vector< byte > | serialize () 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 () |
Server Name Indicator extension (RFC 3546)
Definition at line 73 of file tls_extensions.h.
| 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) {}
| Botan::TLS::Server_Name_Indicator::Server_Name_Indicator | ( | TLS_Data_Reader & | reader, |
| u16bit | extension_size | ||
| ) |
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;
}
}
}
| bool Botan::TLS::Server_Name_Indicator::empty | ( | ) | const [inline, virtual] |
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] |
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;
}
| static Handshake_Extension_Type Botan::TLS::Server_Name_Indicator::static_type | ( | ) | [inline, static] |
Definition at line 76 of file tls_extensions.h.
References Botan::TLS::TLSEXT_SERVER_NAME_INDICATION.
Referenced by type().
{ return TLSEXT_SERVER_NAME_INDICATION; }
| Handshake_Extension_Type Botan::TLS::Server_Name_Indicator::type | ( | ) | const [inline, virtual] |
Implements Botan::TLS::Extension.
Definition at line 79 of file tls_extensions.h.
References static_type().
{ return static_type(); }
1.7.6.1