Botan 3.4.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 <vector>
14
15#include <botan/tls_magic.h>
16
17namespace Botan::TLS {
18
19/**
20 * Manages the expectations for incoming handshake messages in both TLS 1.2 and 1.3.
21 * This does not bear any knowledge about the actual state machine but is a mere
22 * helper to implement state transition validation.
23 */
25 public:
26 /**
27 * Return true iff we have received a particular message already
28 * @param msg_type the message type
29 */
30 bool received_handshake_msg(Handshake_Type msg_type) const;
31
32 /**
33 * Confirm that we were expecting this message type
34 * @param msg_type the message type
35 */
36 void confirm_transition_to(Handshake_Type msg_type);
37
38 /**
39 * Record that we are expecting a particular message type next
40 * @param msg_type the message type
41 */
42 void set_expected_next(Handshake_Type msg_type);
43
44 /**
45 * Record that we are expecting one of the enumerated message types next.
46 * Note that receiving any of the expected messages in `confirm_transition_to`
47 * resets _all_ the expectations.
48 *
49 * @param msg_types the message types
50 */
51 void set_expected_next(const std::vector<Handshake_Type>& msg_types);
52
53 /**
54 * Check whether a Change Cipher Spec must be expected
55 */
56 bool change_cipher_spec_expected() const;
57
58 private:
59 uint32_t m_hand_expecting_mask = 0;
60 uint32_t m_hand_received_mask = 0;
61};
62
63} // namespace Botan::TLS
64
65#endif
#define BOTAN_TEST_API
Definition compiler.h:51