Botan 3.11.0
Crypto and TLS for C&
tls_handshake_transitions.h
Go to the documentation of this file.
1/*
2* TLS Handshake State Transitions
3* (C) 2004-2006,2011,2012 Jack Lloyd
4* 2017 Harry Reimann, Rohde & Schwarz Cybersecurity
5* 2022 René Meusel, Hannes Rantzsch - neXenio GmbH
6*
7* Botan is released under the Simplified BSD License (see license.txt)
8*/
9
10#ifndef BOTAN_TLS_HANDSHAKE_TRANSITIONS_H_
11#define BOTAN_TLS_HANDSHAKE_TRANSITIONS_H_
12
13#include <botan/tls_magic.h>
14#include <vector>
15
16namespace Botan::TLS {
17
18/**
19 * Manages the expectations for incoming handshake messages in both TLS 1.2 and 1.3.
20 * This does not bear any knowledge about the actual state machine but is a mere
21 * helper to implement state transition validation.
22 */
24 public:
25 /**
26 * Return true iff we have received a particular message already
27 * @param msg_type the message type
28 */
29 bool received_handshake_msg(Handshake_Type msg_type) const;
30
31 /**
32 * Confirm that we were expecting this message type
33 * @param msg_type the message type
34 */
36
37 /**
38 * Record that we are expecting a particular message type next
39 * @param msg_type the message type
40 */
41 void set_expected_next(Handshake_Type msg_type);
42
43 /**
44 * Record that we are expecting one of the enumerated message types next.
45 * Note that receiving any of the expected messages in `confirm_transition_to`
46 * resets _all_ the expectations.
47 *
48 * @param msg_types the message types
49 */
50 void set_expected_next(const std::vector<Handshake_Type>& msg_types);
51
52 /**
53 * Check whether a Change Cipher Spec must be expected
54 */
55 bool change_cipher_spec_expected() const;
56
57 private:
58 uint32_t m_hand_expecting_mask = 0;
59 uint32_t m_hand_received_mask = 0;
60};
61
62} // namespace Botan::TLS
63
64#endif
#define BOTAN_TEST_API
Definition api.h:41
void confirm_transition_to(Handshake_Type msg_type)
bool received_handshake_msg(Handshake_Type msg_type) const
void set_expected_next(Handshake_Type msg_type)