Botan 3.11.0
Crypto and TLS for C&
tls_extensions_12.h
Go to the documentation of this file.
1/*
2* TLS 1.2 Specific Extensions
3* (C) 2011,2012,2016,2018,2019 Jack Lloyd
4* (C) 2016 Juraj Somorovsky
5* (C) 2016 Matthias Gierlings
6* (C) 2021 Elektrobit Automotive GmbH
7* (C) 2022 René Meusel, Hannes Rantzsch - neXenio GmbH
8* (C) 2023 Fabian Albert, René Meusel - Rohde & Schwarz Cybersecurity
9* (C) 2026 René Meusel - Rohde & Schwarz Cybersecurity
10*
11* Botan is released under the Simplified BSD License (see license.txt)
12*/
13
14#ifndef BOTAN_TLS_EXTENSIONS_12_H_
15#define BOTAN_TLS_EXTENSIONS_12_H_
16
17#include <botan/tls_extensions.h>
18#include <botan/tls_session.h>
19
20#include <vector>
21
22namespace Botan::TLS {
23
24class TLS_Data_Reader;
25
26/**
27* Renegotiation Indication Extension (RFC 5746)
28*/
30 public:
32
33 Extension_Code type() const override { return static_type(); }
34
36
37 explicit Renegotiation_Extension(const std::vector<uint8_t>& bits) : m_reneg_data(bits) {}
38
39 Renegotiation_Extension(TLS_Data_Reader& reader, uint16_t extension_size);
40
41 const std::vector<uint8_t>& renegotiation_info() const { return m_reneg_data; }
42
43 std::vector<uint8_t> serialize(Connection_Side whoami) const override;
44
45 bool empty() const override { return false; } // always send this
46
47 private:
48 std::vector<uint8_t> m_reneg_data;
49};
50
51/**
52* Session Ticket Extension (RFC 5077)
53*/
55 public:
57
58 Extension_Code type() const override { return static_type(); }
59
60 /**
61 * @return contents of the session ticket
62 */
63 const Session_Ticket& contents() const { return m_ticket; }
64
65 /**
66 * Create empty extension, used by both client and server
67 */
69
70 /**
71 * Extension with ticket, used by client
72 */
73 explicit Session_Ticket_Extension(Session_Ticket session_ticket) : m_ticket(std::move(session_ticket)) {}
74
75 /**
76 * Deserialize a session ticket
77 */
78 Session_Ticket_Extension(TLS_Data_Reader& reader, uint16_t extension_size);
79
80 std::vector<uint8_t> serialize(Connection_Side /*whoami*/) const override { return m_ticket.get(); }
81
82 bool empty() const override { return false; }
83
84 private:
85 Session_Ticket m_ticket;
86};
87
88/**
89* Supported Point Formats Extension (RFC 4492)
90*/
92 public:
93 enum ECPointFormat : uint8_t /* NOLINT(*-use-enum-class) */ {
96 ANSIX962_COMPRESSED_CHAR2 = 2, // don't support these curves
97 };
98
100
101 Extension_Code type() const override { return static_type(); }
102
103 std::vector<uint8_t> serialize(Connection_Side whoami) const override;
104
105 explicit Supported_Point_Formats(bool prefer_compressed) : m_prefers_compressed(prefer_compressed) {}
106
107 Supported_Point_Formats(TLS_Data_Reader& reader, uint16_t extension_size);
108
109 bool empty() const override { return false; }
110
111 bool prefers_compressed() const { return m_prefers_compressed; }
112
113 private:
114 bool m_prefers_compressed = false;
115};
116
117/**
118* Extended Master Secret Extension (RFC 7627)
119*/
121 public:
123
124 Extension_Code type() const override { return static_type(); }
125
126 std::vector<uint8_t> serialize(Connection_Side whoami) const override;
127
128 bool empty() const override { return false; }
129
131
132 Extended_Master_Secret(TLS_Data_Reader& reader, uint16_t extension_size);
133};
134
135/**
136* Encrypt-then-MAC Extension (RFC 7366)
137*/
139 public:
141
142 Extension_Code type() const override { return static_type(); }
143
144 std::vector<uint8_t> serialize(Connection_Side whoami) const override;
145
146 bool empty() const override { return false; }
147
148 Encrypt_then_MAC() = default;
149
150 Encrypt_then_MAC(TLS_Data_Reader& reader, uint16_t extension_size);
151};
152
153} // namespace Botan::TLS
154
155#endif
#define BOTAN_UNSTABLE_API
Definition api.h:34
Extension_Code type() const override
static Extension_Code static_type()
Extension_Code type() const override
Renegotiation_Extension(const std::vector< uint8_t > &bits)
Extension_Code type() const override
const std::vector< uint8_t > & renegotiation_info() const
Extension_Code type() const override
Session_Ticket_Extension(Session_Ticket session_ticket)
std::vector< uint8_t > serialize(Connection_Side) const override
const Session_Ticket & contents() const
Supported_Point_Formats(bool prefer_compressed)
Extension_Code type() const override
Strong< std::vector< uint8_t >, struct Session_Ticket_ > Session_Ticket
holds a TLS 1.2 session ticket for stateless resumption