diff options
author | lloyd <[email protected]> | 2012-08-07 15:36:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-08-07 15:36:21 +0000 |
commit | 70d214d31fa35778fe37d4e56e349a5a5b178895 (patch) | |
tree | 47d8ced1744eec0c00e3e617ab132695cb4d2b6c /src | |
parent | 0749e12e2038a1f9eac8b94e6bc0914a75dce983 (diff) |
Remove Handshake_IO::have_full_record and Handshake_IO::empty
Have get_next_record return NONE+empty vector if no record
availabe. IO::empty was completely unused.
Diffstat (limited to 'src')
-rw-r--r-- | src/tls/tls_channel.cpp | 9 | ||||
-rw-r--r-- | src/tls/tls_handshake_io.cpp | 40 | ||||
-rw-r--r-- | src/tls/tls_handshake_io.h | 15 |
3 files changed, 14 insertions, 50 deletions
diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp index 060799826..ed1c5fc75 100644 --- a/src/tls/tls_channel.cpp +++ b/src/tls/tls_channel.cpp @@ -77,10 +77,13 @@ size_t Channel::received_data(const byte buf[], size_t buf_size) record.size(), record_number); - while(m_state && m_state->handshake_io().have_full_record()) + while(m_state) { - std::pair<Handshake_Type, std::vector<byte> > msg = - m_state->handshake_io().get_next_record(); + auto msg = m_state->handshake_io().get_next_record(); + + if(msg.first == HANDSHAKE_NONE) // no full handshake yet + break; + process_handshake_msg(msg.first, msg.second); } } diff --git a/src/tls/tls_handshake_io.cpp b/src/tls/tls_handshake_io.cpp index 5cb52caf2..f46fdb094 100644 --- a/src/tls/tls_handshake_io.cpp +++ b/src/tls/tls_handshake_io.cpp @@ -60,24 +60,7 @@ void Stream_Handshake_IO::add_input(const byte rec_type, throw Decoding_Error("Unknown message type in handshake processing"); } -bool Stream_Handshake_IO::empty() const - { - return m_queue.empty(); - } - -bool Stream_Handshake_IO::have_full_record() const - { - if(m_queue.size() >= 4) - { - const size_t length = load_be24(&m_queue[1]); - - return (m_queue.size() >= length + 4); - } - - return false; - } - -std::pair<Handshake_Type, std::vector<byte> > +std::pair<Handshake_Type, std::vector<byte>> Stream_Handshake_IO::get_next_record() { if(m_queue.size() >= 4) @@ -97,7 +80,7 @@ Stream_Handshake_IO::get_next_record() } } - throw Internal_Error("Stream_Handshake_IO::get_next_record called without a full record"); + return std::make_pair(HANDSHAKE_NONE, std::vector<byte>()); } std::vector<byte> @@ -163,26 +146,13 @@ void Datagram_Handshake_IO::add_input(const byte rec_type, msg_len); } -bool Datagram_Handshake_IO::empty() const - { - return m_messages.find(m_in_message_seq) == m_messages.end(); - } - -bool Datagram_Handshake_IO::have_full_record() const - { - auto i = m_messages.find(m_in_message_seq); - - const bool complete = (i != m_messages.end() && i->second.complete()); - - return complete; - } - -std::pair<Handshake_Type, std::vector<byte> > Datagram_Handshake_IO::get_next_record() +std::pair<Handshake_Type, std::vector<byte>> +Datagram_Handshake_IO::get_next_record() { auto i = m_messages.find(m_in_message_seq); if(i == m_messages.end() || !i->second.complete()) - throw Internal_Error("Datagram_Handshake_IO::get_next_record called without a full record"); + return std::make_pair(HANDSHAKE_NONE, std::vector<byte>()); auto m = i->second.message(); diff --git a/src/tls/tls_handshake_io.h b/src/tls/tls_handshake_io.h index cd79a0b72..7ed459049 100644 --- a/src/tls/tls_handshake_io.h +++ b/src/tls/tls_handshake_io.h @@ -43,10 +43,9 @@ class Handshake_IO size_t record_size, u64bit record_number) = 0; - virtual bool empty() const = 0; - - virtual bool have_full_record() const = 0; - + /** + * Returns (HANDSHAKE_NONE, std::vector<>()) if no message currently available + */ virtual std::pair<Handshake_Type, std::vector<byte> > get_next_record() = 0; Handshake_IO() {} @@ -79,10 +78,6 @@ class Stream_Handshake_IO : public Handshake_IO size_t record_size, u64bit record_number) override; - bool empty() const override; - - bool have_full_record() const override; - std::pair<Handshake_Type, std::vector<byte> > get_next_record() override; private: std::deque<byte> m_queue; @@ -110,10 +105,6 @@ class Datagram_Handshake_IO : public Handshake_IO size_t record_size, u64bit record_number) override; - bool empty() const override; - - bool have_full_record() const override; - std::pair<Handshake_Type, std::vector<byte>> get_next_record() override; private: class Handshake_Reassembly |