Botan 3.11.0
Crypto and TLS for C&
msg_session_ticket_12.cpp
Go to the documentation of this file.
1/*
2* Session Tickets
3* (C) 2012 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#include <botan/tls_messages_12.h>
9
10#include <botan/internal/tls_handshake_hash.h>
11#include <botan/internal/tls_handshake_io.h>
12#include <botan/internal/tls_reader.h>
13
14namespace Botan::TLS {
15
17 Handshake_Hash& hash,
19 uint32_t lifetime) :
20 m_ticket_lifetime_hint(lifetime), m_ticket(std::move(ticket)) {
21 hash.update(io.send(*this));
22}
23
27
28New_Session_Ticket_12::New_Session_Ticket_12(const std::vector<uint8_t>& buf) {
29 if(buf.size() < 6) {
30 throw Decoding_Error("Session ticket message too short to be valid");
31 }
32
33 TLS_Data_Reader reader("SessionTicket", buf);
34
35 m_ticket_lifetime_hint = reader.get_uint32_t();
36 m_ticket = Session_Ticket(reader.get_range<uint8_t>(2, 0, 65535));
37 reader.assert_done();
38}
39
40std::vector<uint8_t> New_Session_Ticket_12::serialize() const {
41 auto buf = store_be<std::vector<uint8_t>>(m_ticket_lifetime_hint);
42 append_tls_length_value(buf, m_ticket.get(), 2);
43 return buf;
44}
45
46} // namespace Botan::TLS
void update(const uint8_t in[], size_t length)
virtual std::vector< uint8_t > send(const Handshake_Message &msg)=0
New_Session_Ticket_12(Handshake_IO &io, Handshake_Hash &hash, Session_Ticket ticket, uint32_t lifetime_in_seconds)
std::vector< uint8_t > serialize() const override
const Session_Ticket & ticket() const
std::vector< T > get_range(size_t len_bytes, size_t min_elems, size_t max_elems)
Definition tls_reader.h:110
void append_tls_length_value(std::vector< uint8_t, Alloc > &buf, const T *vals, size_t vals_size, size_t tag_size)
Definition tls_reader.h:177
Strong< std::vector< uint8_t >, struct Session_Ticket_ > Session_Ticket
holds a TLS 1.2 session ticket for stateless resumption
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745