/* * Session Tickets * (C) 2012 Jack Lloyd * * Released under the terms of the Botan license */ #include #include #include #include #include namespace Botan { namespace TLS { New_Session_Ticket::New_Session_Ticket(Record_Writer& writer, Handshake_Hash& hash, const MemoryRegion& ticket, u32bit lifetime) : m_ticket_lifetime_hint(lifetime), m_ticket(ticket) { hash.update(writer.send(*this)); } New_Session_Ticket::New_Session_Ticket(Record_Writer& writer, Handshake_Hash& hash) : m_ticket_lifetime_hint(0) { hash.update(writer.send(*this)); } New_Session_Ticket::New_Session_Ticket(const MemoryRegion& buf) : m_ticket_lifetime_hint(0) { if(buf.size() >= 6) { TLS_Data_Reader reader(buf); m_ticket_lifetime_hint = reader.get_u32bit(); m_ticket = reader.get_range(2, 0, 65535); } } MemoryVector New_Session_Ticket::serialize() const { MemoryVector buf(4); store_be(m_ticket_lifetime_hint, &buf[0]); append_tls_length_value(buf, m_ticket, 2); return buf; } } }