diff options
author | lloyd <[email protected]> | 2012-05-26 15:24:37 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-26 15:24:37 +0000 |
commit | 6c163bfd61ffa9a2c04efab01a94aced0716dc18 (patch) | |
tree | 7d2c123a4d0541a63783695b8b8c8d5eb1396ebe | |
parent | c13a1a1a961f508c06ea9e1f04cb0652b169e32e (diff) |
Use std::deque instead of SecureQueue in TLS::Stream_Handshake_Reader
as after all we are reading things that we received over a network
connection so there certainly is no reason to try to mlock them.
Also remove unneeded include in tls_record.h
-rw-r--r-- | src/tls/tls_handshake_reader.cpp | 28 | ||||
-rw-r--r-- | src/tls/tls_handshake_reader.h | 5 | ||||
-rw-r--r-- | src/tls/tls_record.h | 1 |
3 files changed, 18 insertions, 16 deletions
diff --git a/src/tls/tls_handshake_reader.cpp b/src/tls/tls_handshake_reader.cpp index a3fe48f71..b61f301dc 100644 --- a/src/tls/tls_handshake_reader.cpp +++ b/src/tls/tls_handshake_reader.cpp @@ -15,7 +15,7 @@ namespace TLS { void Stream_Handshake_Reader::add_input(const byte record[], size_t record_size) { - m_queue.write(record, record_size); + m_queue.insert(m_queue.end(), record, record + record_size); } bool Stream_Handshake_Reader::empty() const @@ -27,10 +27,10 @@ bool Stream_Handshake_Reader::have_full_record() const { if(m_queue.size() >= 4) { - byte head[4] = { 0 }; - m_queue.peek(head, 4); - - const size_t length = make_u32bit(0, head[1], head[2], head[3]); + const size_t length = make_u32bit(0, + m_queue[1], + m_queue[2], + m_queue[3]); return (m_queue.size() >= length + 4); } @@ -42,17 +42,19 @@ std::pair<Handshake_Type, std::vector<byte> > Stream_Handshake_Reader::get_next_ { if(m_queue.size() >= 4) { - byte head[4] = { 0 }; - m_queue.peek(head, 4); - - const size_t length = make_u32bit(0, head[1], head[2], head[3]); + const size_t length = make_u32bit(0, + m_queue[1], + m_queue[2], + m_queue[3]); if(m_queue.size() >= length + 4) { - Handshake_Type type = static_cast<Handshake_Type>(head[0]); - std::vector<byte> contents(length); - m_queue.read(head, 4); // discard - m_queue.read(&contents[0], contents.size()); + Handshake_Type type = static_cast<Handshake_Type>(m_queue[0]); + + std::vector<byte> contents(m_queue.begin() + 4, + m_queue.begin() + 4 + length); + + m_queue.erase(m_queue.begin(), m_queue.begin() + 4 + length); return std::make_pair(type, contents); } diff --git a/src/tls/tls_handshake_reader.h b/src/tls/tls_handshake_reader.h index 618e1878a..13c270d87 100644 --- a/src/tls/tls_handshake_reader.h +++ b/src/tls/tls_handshake_reader.h @@ -9,8 +9,9 @@ #define BOTAN_TLS_HANDSHAKE_READER_H__ #include <botan/tls_magic.h> -#include <botan/secqueue.h> #include <botan/loadstor.h> +#include <vector> +#include <deque> #include <utility> namespace Botan { @@ -48,7 +49,7 @@ class Stream_Handshake_Reader : public Handshake_Reader std::pair<Handshake_Type, std::vector<byte> > get_next_record(); private: - SecureQueue m_queue; + std::deque<byte> m_queue; }; } diff --git a/src/tls/tls_record.h b/src/tls/tls_record.h index a92dcbe9d..72d5e276d 100644 --- a/src/tls/tls_record.h +++ b/src/tls/tls_record.h @@ -14,7 +14,6 @@ #include <botan/tls_version.h> #include <botan/pipe.h> #include <botan/mac.h> -#include <botan/secqueue.h> #include <vector> #include <functional> |