@@ -113,9 +113,9 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
113113 const Policy& policy,
114114 Callbacks& cb,
115115 RandomNumberGenerator& rng,
116- const std::vector<uint8_t >& reneg_info,
116+ std::vector<uint8_t > reneg_info,
117117 const Client_Hello_12::Settings& client_settings,
118- const std::vector<std::string>& next_protocols) {
118+ std::vector<std::string> next_protocols) {
119119 m_data->m_legacy_version = client_settings.protocol_version ();
120120 m_data->m_random = make_hello_random (rng, cb, policy);
121121 m_data->m_suites = policy.ciphersuite_list (client_settings.protocol_version ());
@@ -142,7 +142,8 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
142142
143143 m_data->extensions ().add (new Session_Ticket_Extension ());
144144
145- m_data->extensions ().add (new Renegotiation_Extension (reneg_info));
145+ const bool has_reneg_info = !reneg_info.empty ();
146+ m_data->extensions ().add (new Renegotiation_Extension (std::move (reneg_info)));
146147
147148 m_data->extensions ().add (new Supported_Versions (m_data->legacy_version (), policy));
148149
@@ -165,8 +166,8 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
165166 m_data->extensions ().add (new Signature_Algorithms_Cert (std::move (cert_signing_prefs.value ())));
166167 }
167168
168- if (reneg_info. empty () && !next_protocols.empty ()) {
169- m_data->extensions ().add (new Application_Layer_Protocol_Notification (next_protocols));
169+ if (!has_reneg_info && !next_protocols.empty ()) {
170+ m_data->extensions ().add (new Application_Layer_Protocol_Notification (std::move ( next_protocols) ));
170171 }
171172
172173 if (m_data->legacy_version ().is_datagram_protocol ()) {
@@ -188,9 +189,9 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
188189 const Policy& policy,
189190 Callbacks& cb,
190191 RandomNumberGenerator& rng,
191- const std::vector<uint8_t >& reneg_info,
192+ std::vector<uint8_t > reneg_info,
192193 const Session_with_Handle& session,
193- const std::vector<std::string>& next_protocols) {
194+ std::vector<std::string> next_protocols) {
194195 m_data->m_legacy_version = session.session .version ();
195196 m_data->m_random = make_hello_random (rng, cb, policy);
196197
@@ -228,7 +229,8 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
228229 m_data->extensions ().add (new Session_Ticket_Extension (session.handle .ticket ().value ()));
229230 }
230231
231- m_data->extensions ().add (new Renegotiation_Extension (reneg_info));
232+ const bool has_reneg_info = !reneg_info.empty ();
233+ m_data->extensions ().add (new Renegotiation_Extension (std::move (reneg_info)));
232234
233235 const std::string hostname = session.session .server_info ().hostname ();
234236
@@ -251,8 +253,8 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
251253 m_data->extensions ().add (new Signature_Algorithms_Cert (std::move (cert_signing_prefs.value ())));
252254 }
253255
254- if (reneg_info. empty () && !next_protocols.empty ()) {
255- m_data->extensions ().add (new Application_Layer_Protocol_Notification (next_protocols));
256+ if (!has_reneg_info && !next_protocols.empty ()) {
257+ m_data->extensions ().add (new Application_Layer_Protocol_Notification (std::move ( next_protocols) ));
256258 }
257259
258260 // NOLINTEND(*-owning-memory)
@@ -262,7 +264,7 @@ Client_Hello_12::Client_Hello_12(Handshake_IO& io,
262264 hash.update (io.send (*this ));
263265}
264266
265- Client_Hello_12::Client_Hello_12 (const std::vector< uint8_t >& buf) :
267+ Client_Hello_12::Client_Hello_12 (std::span< const uint8_t > buf) :
266268 Client_Hello_12 (std::make_unique<Client_Hello_Internal>(buf)) {}
267269
268270Client_Hello_12::Client_Hello_12 (std::unique_ptr<Client_Hello_Internal> data) : Client_Hello_12_Shim(std::move(data)) {
@@ -284,7 +286,7 @@ Hello_Request::Hello_Request(Handshake_IO& io) {
284286 io.send (*this );
285287}
286288
287- Hello_Request::Hello_Request (const std::vector< uint8_t >& buf) {
289+ Hello_Request::Hello_Request (std::span< const uint8_t > buf) {
288290 if (!buf.empty ()) {
289291 throw Decoding_Error (" Bad Hello_Request, has non-zero size" );
290292 }
0 commit comments