Botan 3.6.1
Crypto and TLS for C&
msg_key_update.cpp
Go to the documentation of this file.
1/*
2* Key Update message
3* (C) 2022 Jack Lloyd
4* 2022 René Meusel, Hannes Rantzsch - neXenio GmbH
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/tls_messages.h>
10
11#include <botan/tls_exceptn.h>
12
13namespace Botan::TLS {
14
15Key_Update::Key_Update(const bool request_peer_update) : m_update_requested(request_peer_update) {}
16
17Key_Update::Key_Update(const std::vector<uint8_t>& buf) {
18 if(buf.size() != 1) {
19 throw TLS_Exception(Alert::DecodeError, "malformed key_update");
20 }
21
22 // RFC 8446 4.6.3
23 // If an implementation receives any other value [than 0 or 1], it MUST
24 // terminate the connection with an "illegal_parameter" alert.
25 const uint8_t update_requested = buf.at(0);
26 if(update_requested > 1) {
27 throw TLS_Exception(Alert::IllegalParameter, "unexpected key_update parameter");
28 }
29
30 m_update_requested = update_requested == 1;
31}
32
33std::vector<uint8_t> Key_Update::serialize() const {
34 return std::vector<uint8_t>(1, (m_update_requested ? 1 : 0));
35}
36
37} // namespace Botan::TLS
Key_Update(bool request_peer_update)
std::vector< uint8_t > serialize() const override