/* * Next Protocol Negotation * (C) 2012 Jack Lloyd * * Released under the terms of the Botan license */ #include #include #include namespace Botan { Next_Protocol::Next_Protocol(Record_Writer& writer, TLS_Handshake_Hash& hash, const std::string& protocol) : m_protocol(protocol) { send(writer, hash); } MemoryVector Next_Protocol::serialize() const { MemoryVector buf; append_tls_length_value(buf, reinterpret_cast(m_protocol.data()), m_protocol.size(), 1); const byte padding_len = 32 - ((m_protocol.size() + 2) % 32); buf.push_back(padding_len); for(size_t i = 0; i != padding_len; ++i) buf.push_back(0); return buf; } void Next_Protocol::deserialize(const MemoryRegion& buf) { TLS_Data_Reader reader(buf); m_protocol = reader.get_string(1, 0, 255); reader.get_range_vector(1, 0, 255); // padding, ignored } }