Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | List of all members
Botan::TLS::Handshake_State Class Reference

`#include <tls_handshake_state.h>`

Inherited by Botan::TLS::Server_Handshake_State.

## Public Member Functions
Callbacks & | callbacks () const
const Certificate_Req * | cert_req () const
void | cert_req (Certificate_Req *cert_req)
std::pair< std::string, Signature_Format > | choose_sig_format (const Private_Key &key, Signature_Scheme &scheme, bool for_client_auth, const Policy &policy) const
const Ciphersuite & | ciphersuite () const
const Certificate * | client_certs () const
void | client_certs (Certificate *client_certs)
const Finished * | client_finished () const
void | client_finished (Finished *client_finished)
const Client_Hello * | client_hello () const
void | client_hello (Client_Hello *client_hello)
const Client_Key_Exchange * | client_kex () const
void | client_kex (Client_Key_Exchange *client_kex)
const Certificate_Verify * | client_verify () const
void | client_verify (Certificate_Verify *client_verify)
void | compute_session_keys ()
void | compute_session_keys (const secure_vector< uint8_t > &resume_master_secret)
void | confirm_transition_to (Handshake_Type msg_type)
std::pair< Handshake_Type, std::vector< uint8_t > > | get_next_handshake_msg ()
Handshake_IO & | handshake_io ()
| Handshake_State (const Handshake_State &)=delete
| Handshake_State (Handshake_IO *io, Callbacks &callbacks)
Handshake_Hash & | hash ()
const Handshake_Hash & | hash () const
void | hello_verify_request (const Hello_Verify_Request &hello_verify)
const New_Session_Ticket * | new_session_ticket () const
void | new_session_ticket (New_Session_Ticket *new_session_ticket)
void | note_message (const Handshake_Message &msg)
Handshake_State & | operator= (const Handshake_State &)=delete
std::pair< std::string, Signature_Format > | parse_sig_format (const Public_Key &key, Signature_Scheme scheme, bool for_client_auth, const Policy &policy) const
KDF * | protocol_specific_prf () const
bool | received_handshake_msg (Handshake_Type msg_type) const
const Certificate_Status * | server_cert_status () const
void | server_cert_status (Certificate_Status *server_cert_status)
const Certificate * | server_certs () const
void | server_certs (Certificate *server_certs)
const Finished * | server_finished () const
void | server_finished (Finished *server_finished)
const Server_Hello * | server_hello () const
void | server_hello (Server_Hello *server_hello)
const Server_Hello_Done * | server_hello_done () const
void | server_hello_done (Server_Hello_Done *server_hello_done)
const Server_Key_Exchange * | server_kex () const
void | server_kex (Server_Key_Exchange *server_kex)
const Session_Keys & | session_keys () const
std::vector< uint8_t > | session_ticket () const
void | set_expected_next (Handshake_Type msg_type)
void | set_version (const Protocol_Version &version)
std::string | srp_identifier () const
Protocol_Version | version () const
virtual | ~Handshake_State ()

## Detailed Description

SSL/TLS Handshake State

Definition at line 49 of file tls_handshake_state.h.

## Constructor & Destructor Documentation

## ◆ Handshake_State() [1/2]

Botan::TLS::Handshake_State::Handshake_State | ( | Handshake_IO * | io,
|  | Callbacks & | callbacks
| ) |  |

Definition at line 183 of file tls_handshake_state.cpp.

183 :
184 m_callbacks(cb),
185 m_handshake_io(io),
186 m_version(m_handshake_io->initial_record_version())
187 {
188 }

## ◆ ~Handshake_State()

virtual Botan::TLS::Handshake_State::~Handshake_State | ( |  | ) |
| inline virtual

Definition at line 54 of file tls_handshake_state.h.

54{}

## ◆ Handshake_State() [2/2]

Botan::TLS::Handshake_State::Handshake_State | ( | const Handshake_State & |  | ) |
| delete

## Member Function Documentation

## ◆ callbacks()

Callbacks & Botan::TLS::Handshake_State::callbacks | ( |  | ) | const
| inline

Definition at line 163 of file tls_handshake_state.h.

163{ return m_callbacks; }

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), Botan::TLS::Server_Key_Exchange::verify(), and Botan::TLS::Certificate_Verify::verify().

## ◆ cert_req() [1/2]

const Certificate_Req * Botan::TLS::Handshake_State::cert_req | ( |  | ) | const
| inline

Definition at line 132 of file tls_handshake_state.h.

133 { return m_cert_req.get(); }

Referenced by cert_req(), choose_sig_format(), and parse_sig_format().

## ◆ cert_req() [2/2]

void Botan::TLS::Handshake_State::cert_req | ( | Certificate_Req * | cert_req | ) |

Definition at line 244 of file tls_handshake_state.cpp.

245 {
246 m_cert_req.reset(cert_req);
247 note_message(*m_cert_req);
248 }
Botan::TLS::Handshake_State::note_message
void note_message(const Handshake_Message &msg)
Definition: tls_handshake_state.cpp:190
Botan::TLS::Handshake_State::cert_req
const Certificate_Req * cert_req() const
Definition: tls_handshake_state.h:132

References cert_req(), and note_message().

## ◆ choose_sig_format()

std::pair< std::string, Signature_Format > Botan::TLS::Handshake_State::choose_sig_format | ( | const Private_Key & | key,
|  | Signature_Scheme & | scheme,
|  | bool | for_client_auth,
|  | const Policy & | policy
| ) |  | const

Definition at line 399 of file tls_handshake_state.cpp.

403 {
404 const std::string sig_algo = key.algo_name();
405
406 if(this->version().supports_negotiable_signature_algorithms())
407 {
408 const std::vector<Signature_Scheme> allowed = policy.allowed_signature_schemes();
409
410 std::vector<Signature_Scheme> requested =
411 (for_client_auth) ? cert_req()->signature_schemes() : client_hello()->signature_schemes();
412
413 if(requested.empty())
414 {
415 // Implicit SHA-1
416 requested.push_back(Signature_Scheme::RSA_PKCS1_SHA1);
417 requested.push_back(Signature_Scheme::ECDSA_SHA1);
418 requested.push_back(Signature_Scheme::DSA_SHA1);
419 }
420
421 for(Signature_Scheme scheme : allowed)
422 {
423 if(signature_scheme_is_known(scheme) == false)
424 {
425 continue;
426 }
427
428 if(signature_algorithm_of_scheme(scheme) == sig_algo)
429 {
430 if(std::find(requested.begin(), requested.end(), scheme) != requested.end())
431 {
432 chosen_scheme = scheme;
433 break;
434 }
435 }
436 }
437
438 const std::string hash = hash_function_of_scheme(chosen_scheme);
439
440 if(!policy.allowed_signature_hash(hash))
441 {
442 throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
443 "Policy refuses to accept signing with any hash supported by peer");
444 }
445
446 if(sig_algo == "RSA")
447 {
448 return std::make_pair(padding_string_for_scheme(chosen_scheme), IEEE_1363);
449 }
450 else if(sig_algo == "DSA" || sig_algo == "ECDSA")
451 {
452 return std::make_pair(padding_string_for_scheme(chosen_scheme), DER_SEQUENCE);
453 }
454 }
455 else
456 {
457 if(sig_algo == "RSA")
458 {
459 const std::string padding = "PKCS1v15(Parallel(MD5,SHA-160))";
460 return std::make_pair(padding, IEEE_1363);
461 }
462 else if(sig_algo == "DSA" || sig_algo == "ECDSA")
463 {
464 const std::string padding = "EMSA1(SHA-1)";
465 return std::make_pair(padding, DER_SEQUENCE);
466 }
467 }
468
469 throw Invalid_Argument(sig_algo + " is invalid/unknown for TLS signatures");
470 }
Botan::TLS::Alert::HANDSHAKE_FAILURE
@ HANDSHAKE_FAILURE
Definition: tls_alert.h:34
Botan::TLS::Certificate_Req::signature_schemes
const std::vector< Signature_Scheme > & signature_schemes() const
Definition: tls_messages.h:435
Botan::TLS::Client_Hello::signature_schemes
std::vector< Signature_Scheme > signature_schemes() const
Definition: msg_client_hello.cpp:341
Botan::TLS::Handshake_State::client_hello
const Client_Hello * client_hello() const
Definition: tls_handshake_state.h:120
Botan::TLS::Handshake_State::hash
Handshake_Hash & hash()
Definition: tls_handshake_state.h:169
Botan::TLS::Handshake_State::version
Protocol_Version version() const
Definition: tls_handshake_state.h:100
Botan::TLS::signature_scheme_is_known
bool signature_scheme_is_known(Signature_Scheme scheme)
Definition: tls_algos.cpp:262
Botan::TLS::Signature_Scheme
Signature_Scheme
Definition: tls_algos.h:86
Botan::TLS::Signature_Scheme::DSA_SHA1
@ DSA_SHA1
Botan::TLS::Signature_Scheme::RSA_PKCS1_SHA1
@ RSA_PKCS1_SHA1
Botan::TLS::Signature_Scheme::ECDSA_SHA1
@ ECDSA_SHA1
Botan::TLS::hash_function_of_scheme
std::string hash_function_of_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:191
Botan::TLS::padding_string_for_scheme
std::string padding_string_for_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:379
Botan::TLS::signature_algorithm_of_scheme
std::string signature_algorithm_of_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:291
Botan::DER_SEQUENCE
@ DER_SEQUENCE
Definition: pk_keys.h:23
Botan::IEEE_1363
@ IEEE_1363
Definition: pk_keys.h:23

References Botan::Public_Key::algo_name(), Botan::TLS::Policy::allowed_signature_hash(), Botan::TLS::Policy::allowed_signature_schemes(), cert_req(), client_hello(), Botan::DER_SEQUENCE, Botan::TLS::DSA_SHA1, Botan::TLS::ECDSA_SHA1, Botan::TLS::Alert::HANDSHAKE_FAILURE, hash(), Botan::TLS::hash_function_of_scheme(), Botan::IEEE_1363, Botan::TLS::padding_string_for_scheme(), Botan::TLS::RSA_PKCS1_SHA1, Botan::TLS::signature_algorithm_of_scheme(), Botan::TLS::signature_scheme_is_known(), Botan::TLS::Client_Hello::signature_schemes(), Botan::TLS::Certificate_Req::signature_schemes(), and version().

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().

## ◆ ciphersuite()

const Ciphersuite & Botan::TLS::Handshake_State::ciphersuite | ( |  | ) | const
| inline

Definition at line 159 of file tls_handshake_state.h.

159{ return m_ciphersuite; }

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), protocol_specific_prf(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), Botan::TLS::Session_Keys::Session_Keys(), and srp_identifier().

## ◆ client_certs() [1/2]

const Certificate * Botan::TLS::Handshake_State::client_certs | ( |  | ) | const
| inline

Definition at line 138 of file tls_handshake_state.h.

139 { return m_client_certs.get(); }

Referenced by client_certs().

## ◆ client_certs() [2/2]

void Botan::TLS::Handshake_State::client_certs | ( | Certificate * | client_certs | ) |

Definition at line 256 of file tls_handshake_state.cpp.

257 {
258 m_client_certs.reset(client_certs);
259 note_message(*m_client_certs);
260 }
Botan::TLS::Handshake_State::client_certs
const Certificate * client_certs() const
Definition: tls_handshake_state.h:138

References client_certs(), and note_message().

## ◆ client_finished() [1/2]

const Finished * Botan::TLS::Handshake_State::client_finished | ( |  | ) | const
| inline

Definition at line 156 of file tls_handshake_state.h.

157 { return m_client_finished.get(); }

Referenced by client_finished().

## ◆ client_finished() [2/2]

void Botan::TLS::Handshake_State::client_finished | ( | Finished * | client_finished | ) |

Definition at line 286 of file tls_handshake_state.cpp.

287 {
288 m_client_finished.reset(client_finished);
289 note_message(*m_client_finished);
290 }
Botan::TLS::Handshake_State::client_finished
const Finished * client_finished() const
Definition: tls_handshake_state.h:156

References client_finished(), and note_message().

## ◆ client_hello() [1/2]

const Client_Hello * Botan::TLS::Handshake_State::client_hello | ( |  | ) | const
| inline

Definition at line 120 of file tls_handshake_state.h.

121 { return m_client_hello.get(); }

Referenced by choose_sig_format(), client_hello(), parse_sig_format(), session_ticket(), and srp_identifier().

## ◆ client_hello() [2/2]

void Botan::TLS::Handshake_State::client_hello | ( | Client_Hello * | client_hello | ) |

Definition at line 205 of file tls_handshake_state.cpp.

206 {
207 if(client_hello == nullptr)
208 {
209 m_client_hello.reset();
210 hash().reset();
211 }
212 else
213 {
214 m_client_hello.reset(client_hello);
215 note_message(*m_client_hello);
216 }
217 }
Botan::TLS::Handshake_Hash::reset
void reset()
Definition: tls_handshake_hash.h:35

References client_hello(), hash(), note_message(), and Botan::TLS::Handshake_Hash::reset().

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), Botan::TLS::Session_Keys::Session_Keys(), and Botan::TLS::Server_Key_Exchange::verify().

## ◆ client_kex() [1/2]

const Client_Key_Exchange * Botan::TLS::Handshake_State::client_kex | ( |  | ) | const
| inline

Definition at line 141 of file tls_handshake_state.h.

142 { return m_client_kex.get(); }

Referenced by client_kex(), and compute_session_keys().

## ◆ client_kex() [2/2]

void Botan::TLS::Handshake_State::client_kex | ( | Client_Key_Exchange * | client_kex | ) |

Definition at line 262 of file tls_handshake_state.cpp.

263 {
264 m_client_kex.reset(client_kex);
265 note_message(*m_client_kex);
266 }
Botan::TLS::Handshake_State::client_kex
const Client_Key_Exchange * client_kex() const
Definition: tls_handshake_state.h:141

References client_kex(), and note_message().

## ◆ client_verify() [1/2]

const Certificate_Verify * Botan::TLS::Handshake_State::client_verify | ( |  | ) | const
| inline

Definition at line 144 of file tls_handshake_state.h.

145 { return m_client_verify.get(); }

Referenced by client_verify().

## ◆ client_verify() [2/2]

void Botan::TLS::Handshake_State::client_verify | ( | Certificate_Verify * | client_verify | ) |

Definition at line 268 of file tls_handshake_state.cpp.

269 {
270 m_client_verify.reset(client_verify);
271 note_message(*m_client_verify);
272 }
Botan::TLS::Handshake_State::client_verify
const Certificate_Verify * client_verify() const
Definition: tls_handshake_state.h:144

References client_verify(), and note_message().

## ◆ compute_session_keys() [1/2]

void Botan::TLS::Handshake_State::compute_session_keys | ( |  | ) |

Definition at line 297 of file tls_handshake_state.cpp.

298 {
299 m_session_keys = Session_Keys(this, client_kex()->pre_master_secret(), false);
300 }

References client_kex().

## ◆ compute_session_keys() [2/2]

void Botan::TLS::Handshake_State::compute_session_keys | ( | const secure_vector< uint8_t > & | resume_master_secret | ) |

Definition at line 302 of file tls_handshake_state.cpp.

303 {
304 m_session_keys = Session_Keys(this, resume_master_secret, true);
305 }

## ◆ confirm_transition_to()

void Botan::TLS::Handshake_State::confirm_transition_to | ( | Handshake_Type | msg_type | ) |

Confirm that we were expecting this message type

Parameters

  msg_type | the message type

Definition at line 307 of file tls_handshake_state.cpp.

308 {
309 const uint32_t mask = bitmask_for_handshake_type(handshake_msg);
310
311 m_hand_received_mask |= mask;
312
313 const bool ok = (m_hand_expecting_mask & mask) != 0; // overlap?
314
315 if(!ok)
316 {
317 const uint32_t seen_so_far = m_hand_received_mask & ~mask;
318
319 std::ostringstream msg;
320
321 msg << "Unexpected state transition in handshake got a " << handshake_type_to_string(handshake_msg);
322
323 if(m_hand_expecting_mask == 0)
324 msg << " not expecting messages";
325 else
326 msg << " expected " << handshake_mask_to_string(m_hand_expecting_mask, '|');
327
328 if(seen_so_far != 0)
329 msg << " seen " << handshake_mask_to_string(seen_so_far, '+');
330
331 throw Unexpected_Message(msg.str());
332 }
333
334 /* We don't know what to expect next, so force a call to
335 set_expected_next; if it doesn't happen, the next transition
336 check will always fail which is what we want.
337 */
338 m_hand_expecting_mask = 0;
339 }
Botan::TLS::handshake_type_to_string
const char * handshake_type_to_string(Handshake_Type type)
Definition: tls_handshake_state.cpp:24

References Botan::TLS::handshake_type_to_string().

## ◆ get_next_handshake_msg()

std::pair< Handshake_Type, std::vector< uint8_t > > Botan::TLS::Handshake_State::get_next_handshake_msg | ( |  | ) |

Definition at line 354 of file tls_handshake_state.cpp.

355 {
356 const bool expecting_ccs =
357 (bitmask_for_handshake_type(HANDSHAKE_CCS) & m_hand_expecting_mask) != 0;
358
359 return m_handshake_io->get_next_record(expecting_ccs);
360 }
Botan::TLS::HANDSHAKE_CCS
@ HANDSHAKE_CCS
Definition: tls_magic.h:62

References Botan::TLS::HANDSHAKE_CCS.

## ◆ handshake_io()

Handshake_IO & Botan::TLS::Handshake_State::handshake_io | ( |  | ) |
| inline

Definition at line 59 of file tls_handshake_state.h.

59{ return *m_handshake_io; }

Referenced by hello_verify_request().

## ◆ hash() [1/2]

Handshake_Hash & Botan::TLS::Handshake_State::hash | ( |  | ) |
| inline

Definition at line 169 of file tls_handshake_state.h.

169{ return m_handshake_hash; }

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), choose_sig_format(), client_hello(), Botan::TLS::Finished::Finished(), hello_verify_request(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), Botan::TLS::Session_Keys::Session_Keys(), and Botan::TLS::Certificate_Verify::verify().

## ◆ hash() [2/2]

const Handshake_Hash & Botan::TLS::Handshake_State::hash | ( |  | ) | const
| inline

Definition at line 171 of file tls_handshake_state.h.

171{ return m_handshake_hash; }

## ◆ hello_verify_request()

void Botan::TLS::Handshake_State::hello_verify_request | ( | const Hello_Verify_Request & | hello_verify | ) |

Definition at line 195 of file tls_handshake_state.cpp.

196 {
197 note_message(hello_verify);
198
199 m_client_hello->update_hello_cookie(hello_verify);
200 hash().reset();
201 hash().update(handshake_io().send(*m_client_hello));
202 note_message(*m_client_hello);
203 }
Botan::TLS::Handshake_Hash::update
void update(const uint8_t in[], size_t length)
Definition: tls_handshake_hash.h:24
Botan::TLS::Handshake_State::handshake_io
Handshake_IO & handshake_io()
Definition: tls_handshake_state.h:59

References handshake_io(), hash(), note_message(), Botan::TLS::Handshake_Hash::reset(), and Botan::TLS::Handshake_Hash::update().

## ◆ new_session_ticket() [1/2]

const New_Session_Ticket * Botan::TLS::Handshake_State::new_session_ticket | ( |  | ) | const
| inline

Definition at line 150 of file tls_handshake_state.h.

151 { return m_new_session_ticket.get(); }

Referenced by new_session_ticket(), and session_ticket().

## ◆ new_session_ticket() [2/2]

void Botan::TLS::Handshake_State::new_session_ticket | ( | New_Session_Ticket * | new_session_ticket | ) |

Definition at line 274 of file tls_handshake_state.cpp.

275 {
276 m_new_session_ticket.reset(new_session_ticket);
277 note_message(*m_new_session_ticket);
278 }
Botan::TLS::Handshake_State::new_session_ticket
const New_Session_Ticket * new_session_ticket() const
Definition: tls_handshake_state.h:150

References new_session_ticket(), and note_message().

## ◆ note_message()

void Botan::TLS::Handshake_State::note_message | ( | const Handshake_Message & | msg | ) |

Definition at line 190 of file tls_handshake_state.cpp.

191 {
192 m_callbacks.tls_inspect_handshake_msg(msg);
193 }
Botan::TLS::Callbacks::tls_inspect_handshake_msg
virtual void tls_inspect_handshake_msg(const Handshake_Message &message)
Definition: tls_callbacks.cpp:25

References Botan::TLS::Callbacks::tls_inspect_handshake_msg().

Referenced by cert_req(), client_certs(), client_finished(), client_hello(), client_kex(), client_verify(), hello_verify_request(), new_session_ticket(), server_cert_status(), server_certs(), server_finished(), server_hello(), server_hello_done(), and server_kex().

## ◆ operator=()

Handshake_State & Botan::TLS::Handshake_State::operator= | ( | const Handshake_State & |  | ) |
| delete

## ◆ parse_sig_format()

std::pair< std::string, Signature_Format > Botan::TLS::Handshake_State::parse_sig_format | ( | const Public_Key & | key,
|  | Signature_Scheme | scheme,
|  | bool | for_client_auth,
|  | const Policy & | policy
| ) |  | const

Definition at line 495 of file tls_handshake_state.cpp.

499 {
500 const std::string key_type = key.algo_name();
501
502 if(!policy.allowed_signature_method(key_type))
503 {
504 throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
505 "Rejecting " + key_type + " signature");
506 }
507
508 if(this->version().supports_negotiable_signature_algorithms() == false)
509 {
510 if(scheme != Signature_Scheme::NONE)
511 throw Decoding_Error("Counterparty sent hash/sig IDs with old version");
512
513 /*
514 There is no check on the acceptability of a v1.0/v1.1 hash type,
515 since it's implicit with use of the protocol
516 */
517
518 if(key_type == "RSA")
519 {
520 const std::string padding = "PKCS1v15(Parallel(MD5,SHA-160))";
521 return std::make_pair(padding, IEEE_1363);
522 }
523 else if(key_type == "DSA" || key_type == "ECDSA")
524 {
525 const std::string padding = "EMSA1(SHA-1)";
526 return std::make_pair(padding, DER_SEQUENCE);
527 }
528 else
529 throw Invalid_Argument(key_type + " is invalid/unknown for TLS signatures");
530 }
531
532 if(scheme == Signature_Scheme::NONE)
533 throw Decoding_Error("Counterparty did not send hash/sig IDS");
534
535 if(key_type != signature_algorithm_of_scheme(scheme))
536 throw Decoding_Error("Counterparty sent inconsistent key and sig types");
537
538 if(for_client_auth && !cert_req())
539 {
540 throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
541 "No certificate verify set");
542 }
543
544 /*
545 Confirm the signature type we just received against the
546 supported_algos list that we sent; it better be there.
547 */
548
549 const std::vector<Signature_Scheme> supported_algos =
550 for_client_auth ? cert_req()->signature_schemes() :
551 client_hello()->signature_schemes();
552
553 if(!signature_scheme_is_known(scheme))
554 throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
555 "Peer sent unknown signature scheme");
556
557 const std::string hash_algo = hash_function_of_scheme(scheme);
558
559 if(!supported_algos_include(supported_algos, key_type, hash_algo))
560 {
561 throw TLS_Exception(Alert::ILLEGAL_PARAMETER,
562 "TLS signature extension did not allow for " +
563 key_type + "/" + hash_algo + " signature");
564 }
565
566 if(key_type == "RSA")
567 {
568 return std::make_pair(padding_string_for_scheme(scheme), IEEE_1363);
569 }
570 else if(key_type == "DSA" || key_type == "ECDSA")
571 {
572 return std::make_pair(padding_string_for_scheme(scheme), DER_SEQUENCE);
573 }
574
575 throw Invalid_Argument(key_type + " is invalid/unknown for TLS signatures");
576 }
Botan::TLS::Alert::ILLEGAL_PARAMETER
@ ILLEGAL_PARAMETER
Definition: tls_alert.h:41
Botan::TLS::Signature_Scheme::NONE
@ NONE
hash_algo
AlgorithmIdentifier hash_algo
Definition: x509_obj.cpp:22

References Botan::Public_Key::algo_name(), Botan::TLS::Policy::allowed_signature_method(), cert_req(), client_hello(), Botan::DER_SEQUENCE, Botan::TLS::Alert::HANDSHAKE_FAILURE, hash_algo, Botan::TLS::hash_function_of_scheme(), Botan::IEEE_1363, Botan::TLS::Alert::ILLEGAL_PARAMETER, Botan::TLS::NONE, Botan::TLS::padding_string_for_scheme(), Botan::TLS::signature_algorithm_of_scheme(), Botan::TLS::signature_scheme_is_known(), Botan::TLS::Client_Hello::signature_schemes(), Botan::TLS::Certificate_Req::signature_schemes(), and version().

Referenced by Botan::TLS::Server_Key_Exchange::verify(), and Botan::TLS::Certificate_Verify::verify().

## ◆ protocol_specific_prf()

KDF * Botan::TLS::Handshake_State::protocol_specific_prf | ( |  | ) | const

Definition at line 382 of file tls_handshake_state.cpp.

383 {
384 if(version().supports_ciphersuite_specific_prf())
385 {
386 const std::string prf_algo = ciphersuite().prf_algo();
387
388 if(prf_algo == "MD5" || prf_algo == "SHA-1")
389 return get_kdf("TLS-12-PRF(SHA-256)");
390
391 return get_kdf("TLS-12-PRF(" + prf_algo + ")");
392 }
393
394 // Old PRF used in TLS v1.0, v1.1 and DTLS v1.0
395 return get_kdf("TLS-PRF");
396 }
Botan::TLS::Ciphersuite::prf_algo
std::string prf_algo() const
Definition: tls_ciphersuite.h:105
Botan::TLS::Handshake_State::ciphersuite
const Ciphersuite & ciphersuite() const
Definition: tls_handshake_state.h:159
Botan::get_kdf
KDF * get_kdf(const std::string &algo_spec)
Definition: kdf.cpp:241

References ciphersuite(), Botan::get_kdf(), Botan::TLS::Ciphersuite::prf_algo(), and version().

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

## ◆ received_handshake_msg()

bool Botan::TLS::Handshake_State::received_handshake_msg | ( | Handshake_Type | msg_type | ) | const

Return true iff we have received a particular message already

Parameters

  msg_type | the message type

Definition at line 346 of file tls_handshake_state.cpp.

347 {
348 const uint32_t mask = bitmask_for_handshake_type(handshake_msg);
349
350 return (m_hand_received_mask & mask) != 0;
351 }

## ◆ server_cert_status() [1/2]

const Certificate_Status * Botan::TLS::Handshake_State::server_cert_status | ( |  | ) | const
| inline

Definition at line 147 of file tls_handshake_state.h.

148 { return m_server_cert_status.get(); }

Referenced by server_cert_status().

## ◆ server_cert_status() [2/2]

void Botan::TLS::Handshake_State::server_cert_status | ( | Certificate_Status * | server_cert_status | ) |

Definition at line 232 of file tls_handshake_state.cpp.

233 {
234 m_server_cert_status.reset(server_cert_status);
235 note_message(*m_server_cert_status);
236 }
Botan::TLS::Handshake_State::server_cert_status
const Certificate_Status * server_cert_status() const
Definition: tls_handshake_state.h:147

References note_message(), and server_cert_status().

## ◆ server_certs() [1/2]

const Certificate * Botan::TLS::Handshake_State::server_certs | ( |  | ) | const
| inline

Definition at line 126 of file tls_handshake_state.h.

127 { return m_server_certs.get(); }

Referenced by server_certs().

## ◆ server_certs() [2/2]

void Botan::TLS::Handshake_State::server_certs | ( | Certificate * | server_certs | ) |

Definition at line 226 of file tls_handshake_state.cpp.

227 {
228 m_server_certs.reset(server_certs);
229 note_message(*m_server_certs);
230 }
Botan::TLS::Handshake_State::server_certs
const Certificate * server_certs() const
Definition: tls_handshake_state.h:126

References note_message(), and server_certs().

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

## ◆ server_finished() [1/2]

const Finished * Botan::TLS::Handshake_State::server_finished | ( |  | ) | const
| inline

Definition at line 153 of file tls_handshake_state.h.

154 { return m_server_finished.get(); }

Referenced by server_finished().

## ◆ server_finished() [2/2]

void Botan::TLS::Handshake_State::server_finished | ( | Finished * | server_finished | ) |

Definition at line 280 of file tls_handshake_state.cpp.

281 {
282 m_server_finished.reset(server_finished);
283 note_message(*m_server_finished);
284 }
Botan::TLS::Handshake_State::server_finished
const Finished * server_finished() const
Definition: tls_handshake_state.h:153

References note_message(), and server_finished().

## ◆ server_hello() [1/2]

const Server_Hello * Botan::TLS::Handshake_State::server_hello | ( |  | ) | const
| inline

Definition at line 123 of file tls_handshake_state.h.

124 { return m_server_hello.get(); }

Referenced by server_hello().

## ◆ server_hello() [2/2]

void Botan::TLS::Handshake_State::server_hello | ( | Server_Hello * | server_hello | ) |

Definition at line 219 of file tls_handshake_state.cpp.

220 {
221 m_server_hello.reset(server_hello);
222 m_ciphersuite = Ciphersuite::by_id(m_server_hello->ciphersuite());
223 note_message(*m_server_hello);
224 }
Botan::TLS::Ciphersuite::by_id
static Ciphersuite by_id(uint16_t suite)
Definition: tls_ciphersuite.cpp:107
Botan::TLS::Handshake_State::server_hello
const Server_Hello * server_hello() const
Definition: tls_handshake_state.h:123

References Botan::TLS::Ciphersuite::by_id(), note_message(), and server_hello().

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), Botan::TLS::Session_Keys::Session_Keys(), and Botan::TLS::Server_Key_Exchange::verify().

## ◆ server_hello_done() [1/2]

const Server_Hello_Done * Botan::TLS::Handshake_State::server_hello_done | ( |  | ) | const
| inline

Definition at line 135 of file tls_handshake_state.h.

136 { return m_server_hello_done.get(); }

Referenced by server_hello_done().

## ◆ server_hello_done() [2/2]

void Botan::TLS::Handshake_State::server_hello_done | ( | Server_Hello_Done * | server_hello_done | ) |

Definition at line 250 of file tls_handshake_state.cpp.

251 {
252 m_server_hello_done.reset(server_hello_done);
253 note_message(*m_server_hello_done);
254 }
Botan::TLS::Handshake_State::server_hello_done
const Server_Hello_Done * server_hello_done() const
Definition: tls_handshake_state.h:135

References note_message(), and server_hello_done().

## ◆ server_kex() [1/2]

const Server_Key_Exchange * Botan::TLS::Handshake_State::server_kex | ( |  | ) | const
| inline

Definition at line 129 of file tls_handshake_state.h.

130 { return m_server_kex.get(); }

Referenced by server_kex().

## ◆ server_kex() [2/2]

void Botan::TLS::Handshake_State::server_kex | ( | Server_Key_Exchange * | server_kex | ) |

Definition at line 238 of file tls_handshake_state.cpp.

239 {
240 m_server_kex.reset(server_kex);
241 note_message(*m_server_kex);
242 }
Botan::TLS::Handshake_State::server_kex
const Server_Key_Exchange * server_kex() const
Definition: tls_handshake_state.h:129

References note_message(), and server_kex().

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

## ◆ session_keys()

const Session_Keys & Botan::TLS::Handshake_State::session_keys | ( |  | ) | const
| inline

Definition at line 161 of file tls_handshake_state.h.

161{ return m_session_keys; }

## ◆ session_ticket()

std::vector< uint8_t > Botan::TLS::Handshake_State::session_ticket | ( |  | ) | const

Definition at line 374 of file tls_handshake_state.cpp.

375 {
376 if(new_session_ticket() && !new_session_ticket()->ticket().empty())
377 return new_session_ticket()->ticket();
378
379 return client_hello()->session_ticket();
380 }
Botan::TLS::Client_Hello::session_ticket
std::vector< uint8_t > session_ticket() const
Definition: msg_client_hello.cpp:416
Botan::TLS::New_Session_Ticket::ticket
const std::vector< uint8_t > & ticket() const
Definition: tls_messages.h:619

References client_hello(), new_session_ticket(), Botan::TLS::Client_Hello::session_ticket(), and Botan::TLS::New_Session_Ticket::ticket().

## ◆ set_expected_next()

void Botan::TLS::Handshake_State::set_expected_next | ( | Handshake_Type | msg_type | ) |

Record that we are expecting a particular message type next

Parameters

  msg_type | the message type

Definition at line 341 of file tls_handshake_state.cpp.

342 {
343 m_hand_expecting_mask |= bitmask_for_handshake_type(handshake_msg);
344 }

## ◆ set_version()

void Botan::TLS::Handshake_State::set_version | ( | const Protocol_Version & | version | ) |

Definition at line 292 of file tls_handshake_state.cpp.

293 {
294 m_version = version;
295 }

References version().

## ◆ srp_identifier()

std::string Botan::TLS::Handshake_State::srp_identifier | ( |  | ) | const

Definition at line 362 of file tls_handshake_state.cpp.

363 {
364#if defined(BOTAN_HAS_SRP6)
365 // Authenticated via the successful key exchange
366 if(ciphersuite().valid() && ciphersuite().kex_method() == Kex_Algo::SRP_SHA)
367 return client_hello()->srp_identifier();
368#endif
369
370 return "";
371 }
Botan::TLS::Kex_Algo::SRP_SHA
@ SRP_SHA

References ciphersuite(), client_hello(), and Botan::TLS::SRP_SHA.

## ◆ version()

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

Definition at line 100 of file tls_handshake_state.h.

100{ return m_version; }

Referenced by choose_sig_format(), parse_sig_format(), protocol_specific_prf(), Botan::TLS::Session_Keys::Session_Keys(), and set_version().

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

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