From 47804d48d8634869f059132fd9112206aa534cee Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 28 Jul 2012 22:32:11 +0000 Subject: Helper func for loading 24 bit value --- src/tls/tls_handshake_reader.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/tls/tls_handshake_reader.cpp b/src/tls/tls_handshake_reader.cpp index b61f301dc..1f271d70a 100644 --- a/src/tls/tls_handshake_reader.cpp +++ b/src/tls/tls_handshake_reader.cpp @@ -12,6 +12,19 @@ namespace Botan { namespace TLS { +namespace { + +inline size_t load_be24(const byte q[3]) + { + return make_u32bit(0, + q[0], + q[1], + q[2]); + } + +} + + void Stream_Handshake_Reader::add_input(const byte record[], size_t record_size) { @@ -27,10 +40,7 @@ bool Stream_Handshake_Reader::have_full_record() const { if(m_queue.size() >= 4) { - const size_t length = make_u32bit(0, - m_queue[1], - m_queue[2], - m_queue[3]); + const size_t length = load_be24(&m_queue[1]); return (m_queue.size() >= length + 4); } @@ -42,10 +52,7 @@ std::pair > Stream_Handshake_Reader::get_next_ { if(m_queue.size() >= 4) { - const size_t length = make_u32bit(0, - m_queue[1], - m_queue[2], - m_queue[3]); + const size_t length = load_be24(&m_queue[1]); if(m_queue.size() >= length + 4) { -- cgit v1.2.3