Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

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

Classes | Public Member Functions | List of all members
Botan::TLS::Server_Hello Class Referencefinal

`#include <tls_messages.h>`

Inheritance diagram for Botan::TLS::Server_Hello:

## Classes
class | Settings

## Public Member Functions
uint16_t | ciphersuite () const
uint8_t | compression_method () const
std::set< Handshake_Extension_Type > | extension_types () const
std::string | next_protocol () const
bool | prefers_compressed_ec_points () const
const std::vector< uint8_t > & | random () const
std::vector< uint8_t > | renegotiation_info () const
bool | secure_renegotiation () const
| Server_Hello (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, RandomNumberGenerator &rng, const std::vector< uint8_t > &secure_reneg_info, const Client_Hello &client_hello, const Server_Hello::Settings &settings, const std::string next_protocol)
| Server_Hello (Handshake_IO &io, Handshake_Hash &hash, const Policy &policy, RandomNumberGenerator &rng, const std::vector< uint8_t > &secure_reneg_info, const Client_Hello &client_hello, Session &resumed_session, bool offer_session_ticket, const std::string &next_protocol)
| Server_Hello (const std::vector< uint8_t > &buf)
const std::vector< uint8_t > & | session_id () const
uint16_t | srtp_profile () const
bool | supports_certificate_status_message () const
bool | supports_encrypt_then_mac () const
bool | supports_extended_master_secret () const
bool | supports_session_ticket () const
Handshake_Type | type () const override
std::string | type_string () const
Protocol_Version | version () const

## Detailed Description

Server Hello Message

Definition at line 255 of file tls_messages.h.

## Constructor & Destructor Documentation

Botan::TLS::Server_Hello::Server_Hello | ( | Handshake_IO & | io,
|  | Handshake_Hash & | hash,
|  | const Policy & | policy,
|  | RandomNumberGenerator & | rng,
|  | const std::vector< uint8_t > & | secure_reneg_info,
|  | const Client_Hello & | client_hello,
|  | const Server_Hello::Settings & | settings,
|  | const std::string | next_protocol
| ) |  |

Definition at line 22 of file msg_server_hello.cpp.

References Botan::TLS::Extensions::add(), Botan::TLS::Ciphersuite::by_id(), Botan::TLS::Ciphersuite::cbc_ciphersuite(), Botan::TLS::Ciphersuite::ecc_ciphersuite(), Botan::TLS::Protocol_Version::is_datagram_protocol(), Botan::TLS::Policy::negotiate_encrypt_then_mac(), Botan::TLS::Server_Hello::Settings::offer_session_ticket(), Botan::TLS::Client_Hello::secure_renegotiation(), Botan::TLS::Handshake_IO::send(), Botan::TLS::Client_Hello::srtp_profiles(), Botan::TLS::Policy::srtp_profiles(), Botan::TLS::Client_Hello::supports_alpn(), Botan::TLS::Client_Hello::supports_cert_status_message(), Botan::TLS::Client_Hello::supports_encrypt_then_mac(), Botan::TLS::Client_Hello::supports_extended_master_secret(), Botan::TLS::Client_Hello::supports_session_ticket(), Botan::TLS::Handshake_Hash::update(), and Botan::TLS::Policy::use_ecc_point_compression().

29 :
30 m_version(server_settings.protocol_version()),
31 m_session_id(server_settings.session_id()),
32 m_random(make_hello_random(rng, policy)),
33 m_ciphersuite(server_settings.ciphersuite()),
34 m_comp_method(server_settings.compression())
35 {
36 if(client_hello.supports_extended_master_secret())
37 m_extensions.add(new Extended_Master_Secret);
38
39 // Sending the extension back does not commit us to sending a stapled response
40 if(client_hello.supports_cert_status_message())
41 m_extensions.add(new Certificate_Status_Request);
42
43 Ciphersuite c = Ciphersuite::by_id(m_ciphersuite);
44
45 if(c.cbc_ciphersuite() && client_hello.supports_encrypt_then_mac() && policy.negotiate_encrypt_then_mac())
46 {
47 m_extensions.add(new Encrypt_then_MAC);
48 }
49
50 if(c.ecc_ciphersuite())
51 {
52 m_extensions.add(new Supported_Point_Formats(policy.use_ecc_point_compression()));
53 }
54
55 if(client_hello.secure_renegotiation())
56 m_extensions.add(new Renegotiation_Extension(reneg_info));
57
58 if(client_hello.supports_session_ticket() && server_settings.offer_session_ticket())
59 m_extensions.add(new Session_Ticket());
60
61 if(!next_protocol.empty() && client_hello.supports_alpn())
62 m_extensions.add(new Application_Layer_Protocol_Notification(next_protocol));
63
64 if(m_version.is_datagram_protocol())
65 {
66 const std::vector<uint16_t> server_srtp = policy.srtp_profiles();
67 const std::vector<uint16_t> client_srtp = client_hello.srtp_profiles();
68
69 if(!server_srtp.empty() && !client_srtp.empty())
70 {
71 uint16_t shared = 0;
72 // always using server preferences for now
73 for(auto s_srtp : server_srtp)
74 for(auto c_srtp : client_srtp)
75 {
76 if(shared == 0 && s_srtp == c_srtp)
77 shared = s_srtp;
78 }
79
80 if(shared)
81 m_extensions.add(new SRTP_Protection_Profiles(shared));
82 }
83 }
84
85 hash.update(io.send(*this));
86 }
Botan::TLS::Server_Hello::next_protocol
std::string next_protocol() const
Definition: tls_messages.h:344
Botan::TLS::Extensions::add
void add(Extension *extn)
Definition: tls_extensions.h:453
Botan::TLS::make_hello_random
std::vector< uint8_t > make_hello_random(RandomNumberGenerator &rng, const Policy &policy)
Definition: msg_client_hello.cpp:28
Botan::TLS::Ciphersuite::by_id
static Ciphersuite by_id(uint16_t suite)
Definition: tls_ciphersuite.cpp:43
Botan::TLS::Protocol_Version::is_datagram_protocol
bool is_datagram_protocol() const
Definition: tls_version.cpp:34
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

Botan::TLS::Server_Hello::Server_Hello | ( | Handshake_IO & | io,
|  | Handshake_Hash & | hash,
|  | const Policy & | policy,
|  | RandomNumberGenerator & | rng,
|  | const std::vector< uint8_t > & | secure_reneg_info,
|  | const Client_Hello & | client_hello,
|  | Session & | resumed_session,
|  | bool | offer_session_ticket,
|  | const std::string & | next_protocol
| ) |  |

Definition at line 89 of file msg_server_hello.cpp.

References Botan::TLS::Extensions::add(), Botan::TLS::Ciphersuite::cbc_ciphersuite(), Botan::TLS::Session::ciphersuite(), Botan::TLS::Ciphersuite::ecc_ciphersuite(), Botan::TLS::Policy::negotiate_encrypt_then_mac(), Botan::TLS::Client_Hello::secure_renegotiation(), Botan::TLS::Handshake_IO::send(), Botan::TLS::Client_Hello::supports_alpn(), Botan::TLS::Client_Hello::supports_cert_status_message(), Botan::TLS::Client_Hello::supports_encrypt_then_mac(), Botan::TLS::Client_Hello::supports_extended_master_secret(), Botan::TLS::Client_Hello::supports_session_ticket(), Botan::TLS::Handshake_Hash::update(), and Botan::TLS::Policy::use_ecc_point_compression().

97 :
98 m_version(resumed_session.version()),
99 m_session_id(client_hello.session_id()),
100 m_random(make_hello_random(rng, policy)),
101 m_ciphersuite(resumed_session.ciphersuite_code()),
102 m_comp_method(resumed_session.compression_method())
103 {
104 if(client_hello.supports_extended_master_secret())
105 m_extensions.add(new Extended_Master_Secret);
106
107 // Sending the extension back does not commit us to sending a stapled response
108 if(client_hello.supports_cert_status_message())
109 m_extensions.add(new Certificate_Status_Request);
110
111 if(client_hello.supports_encrypt_then_mac() && policy.negotiate_encrypt_then_mac())
112 {
113 Ciphersuite c = resumed_session.ciphersuite();
114 if(c.cbc_ciphersuite())
115 m_extensions.add(new Encrypt_then_MAC);
116 }
117
118 if(client_hello.supports_cert_status_message())
119 {
120 m_extensions.add(new Certificate_Status_Request);
121 }
122
123 if(resumed_session.ciphersuite().ecc_ciphersuite())
124 {
125 m_extensions.add(new Supported_Point_Formats(policy.use_ecc_point_compression()));
126 }
127
128 if(client_hello.secure_renegotiation())
129 m_extensions.add(new Renegotiation_Extension(reneg_info));
130
131 if(client_hello.supports_session_ticket() && offer_session_ticket)
132 m_extensions.add(new Session_Ticket());
133
134 if(!next_protocol.empty() && client_hello.supports_alpn())
135 m_extensions.add(new Application_Layer_Protocol_Notification(next_protocol));
136
137 hash.update(io.send(*this));
138 }
Botan::TLS::Server_Hello::next_protocol
std::string next_protocol() const
Definition: tls_messages.h:344
Botan::TLS::Extensions::add
void add(Extension *extn)
Definition: tls_extensions.h:453
Botan::TLS::make_hello_random
std::vector< uint8_t > make_hello_random(RandomNumberGenerator &rng, const Policy &policy)
Definition: msg_client_hello.cpp:28
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

Botan::TLS::Server_Hello::Server_Hello | ( | const std::vector< uint8_t > & | buf | ) |
| explicit

Definition at line 143 of file msg_server_hello.cpp.

References Botan::TLS::Extensions::deserialize(), Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_fixed(), Botan::TLS::TLS_Data_Reader::get_range(), and Botan::TLS::TLS_Data_Reader::get_uint16_t().

144 {
145 if(buf.size() < 38)
146 throw Decoding_Error("Server_Hello: Packet corrupted");
147
148 TLS_Data_Reader reader("ServerHello", buf);
149
150 const uint8_t major_version = reader.get_byte();
151 const uint8_t minor_version = reader.get_byte();
152
153 m_version = Protocol_Version(major_version, minor_version);
154
155 m_random = reader.get_fixed<uint8_t>(32);
156
157 m_session_id = reader.get_range<uint8_t>(1, 0, 32);
158
159 m_ciphersuite = reader.get_uint16_t();
160
161 m_comp_method = reader.get_byte();
162
163 m_extensions.deserialize(reader);
164 }
Botan::TLS::Extensions::deserialize
void deserialize(TLS_Data_Reader &reader)
Definition: tls_extensions.cpp:67

## Member Function Documentation

uint16_t Botan::TLS::Server_Hello::ciphersuite | ( |  | ) | const
| inline

Definition at line 295 of file tls_messages.h.

295 { return m_ciphersuite; }

uint8_t Botan::TLS::Server_Hello::compression_method | ( |  | ) | const
| inline

Definition at line 297 of file tls_messages.h.

297 { return m_comp_method; }

std::set<Handshake_Extension_Type> Botan::TLS::Server_Hello::extension_types | ( |  | ) | const
| inline

Definition at line 351 of file tls_messages.h.

352 { return m_extensions.extension_types(); }
Botan::TLS::Extensions::extension_types
std::set< Handshake_Extension_Type > extension_types() const
Definition: tls_extensions.cpp:127

std::string Botan::TLS::Server_Hello::next_protocol | ( |  | ) | const
| inline

Definition at line 344 of file tls_messages.h.

345 {
346 if(auto alpn = m_extensions.get<Application_Layer_Protocol_Notification>())
347 return alpn->single_protocol();
348 return "";
349 }
Botan::TLS::Extensions::get
T * get() const
Definition: tls_extensions.h:436

bool Botan::TLS::Server_Hello::prefers_compressed_ec_points | ( |  | ) | const
| inline

Definition at line 354 of file tls_messages.h.

355 {
356 if(auto ecc_formats = m_extensions.get<Supported_Point_Formats>())
357 {
358 return ecc_formats->prefers_compressed();
359 }
360 return false;
361 }
Botan::TLS::Extensions::get
T * get() const
Definition: tls_extensions.h:436

const std::vector<uint8_t>& Botan::TLS::Server_Hello::random | ( |  | ) | const
| inline

Definition at line 291 of file tls_messages.h.

291 { return m_random; }

std::vector<uint8_t> Botan::TLS::Server_Hello::renegotiation_info | ( |  | ) | const
| inline

Definition at line 304 of file tls_messages.h.

Referenced by Botan::TLS::Channel::secure_renegotiation_check().

305 {
306 if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
307 return reneg->renegotiation_info();
308 return std::vector<uint8_t>();
309 }
Botan::TLS::Extensions::get
T * get() const
Definition: tls_extensions.h:436

bool Botan::TLS::Server_Hello::secure_renegotiation | ( |  | ) | const
| inline

Definition at line 299 of file tls_messages.h.

Referenced by Botan::TLS::Channel::secure_renegotiation_check().

300 {
301 return m_extensions.has<Renegotiation_Extension>();
302 }
Botan::TLS::Extensions::has
bool has() const
Definition: tls_extensions.h:448

const std::vector<uint8_t>& Botan::TLS::Server_Hello::session_id | ( |  | ) | const
| inline

Definition at line 293 of file tls_messages.h.

293 { return m_session_id; }

uint16_t Botan::TLS::Server_Hello::srtp_profile | ( |  | ) | const
| inline

Definition at line 331 of file tls_messages.h.

332 {
333 if(auto srtp = m_extensions.get<SRTP_Protection_Profiles>())
334 {
335 auto prof = srtp->profiles();
336 if(prof.size() != 1 || prof[0] == 0)
337 throw Decoding_Error("Server sent malformed DTLS-SRTP extension");
338 return prof[0];
339 }
340
341 return 0;
342 }
Botan::TLS::Extensions::get
T * get() const
Definition: tls_extensions.h:436

bool Botan::TLS::Server_Hello::supports_certificate_status_message | ( |  | ) | const
| inline

Definition at line 321 of file tls_messages.h.

322 {
323 return m_extensions.has<Certificate_Status_Request>();
324 }
Botan::TLS::Extensions::has
bool has() const
Definition: tls_extensions.h:448

bool Botan::TLS::Server_Hello::supports_encrypt_then_mac | ( |  | ) | const
| inline

Definition at line 316 of file tls_messages.h.

317 {
318 return m_extensions.has<Encrypt_then_MAC>();
319 }
Botan::TLS::Extensions::has
bool has() const
Definition: tls_extensions.h:448

bool Botan::TLS::Server_Hello::supports_extended_master_secret | ( |  | ) | const
| inline

Definition at line 311 of file tls_messages.h.

312 {
313 return m_extensions.has<Extended_Master_Secret>();
314 }
Botan::TLS::Extensions::has
bool has() const
Definition: tls_extensions.h:448

bool Botan::TLS::Server_Hello::supports_session_ticket | ( |  | ) | const
| inline

Definition at line 326 of file tls_messages.h.

327 {
328 return m_extensions.has<Session_Ticket>();
329 }
Botan::TLS::Extensions::has
bool has() const
Definition: tls_extensions.h:448

Handshake_Type Botan::TLS::Server_Hello::type | ( |  | ) | const
| inline override virtual

Returns
  the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 287 of file tls_messages.h.

References Botan::TLS::SERVER_HELLO.

287 { return SERVER_HELLO; }
Botan::TLS::SERVER_HELLO
Definition: tls_magic.h:41

std::string Botan::TLS::Handshake_Message::type_string | ( |  | ) | const
| inherited

Returns
  string representation of this message type

Definition at line 17 of file tls_handshake_state.cpp.

References Botan::TLS::handshake_type_to_string(), and Botan::TLS::Handshake_Message::type().

18 {
19 return handshake_type_to_string(type());
20 }
Botan::TLS::Handshake_Message::type
virtual Handshake_Type type() const =0
Botan::TLS::handshake_type_to_string
const char * handshake_type_to_string(Handshake_Type type)
Definition: tls_handshake_state.cpp:22

Protocol_Version Botan::TLS::Server_Hello::version | ( |  | ) | const
| inline

Definition at line 289 of file tls_messages.h.

289 { return m_version; }

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

- src/lib/tls/tls_messages.h
- src/lib/tls/msg_server_hello.cpp