aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/session_ticket.cpp
blob: 6aa05c577505ba10c48d62ae2cee6a00f6be1aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Session Tickets
* (C) 2012 Jack Lloyd
*
* Released under the terms of the Botan license
*/

#include <botan/internal/tls_messages.h>
#include <botan/internal/tls_extensions.h>
#include <botan/internal/tls_reader.h>
#include <botan/tls_record.h>
#include <botan/loadstor.h>

namespace Botan {

namespace TLS {

New_Session_Ticket::New_Session_Ticket(const MemoryRegion<byte>& buf) :
   m_ticket_lifetime_hint(0)
   {
   if(buf.size() >= 4)
      {
      TLS_Data_Reader reader(buf);

      m_ticket_lifetime_hint = reader.get_u32bit();
      m_ticket = reader.get_range<byte>(2, 0, 65535);
      }
   }

MemoryVector<byte> New_Session_Ticket::serialize() const
   {
   MemoryVector<byte> buf(4);
   store_be(m_ticket_lifetime_hint, &buf[0]);
   append_tls_length_value(buf, m_ticket, 2);
   return buf;
   }

}

}