aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-16 16:59:59 +0000
committerlloyd <[email protected]>2012-07-16 16:59:59 +0000
commit45599ab2192863a2361c2dcca4a932419a7945cf (patch)
treeff705df18f0a8dae3c78c33113a0ae2d294a2280
parent848639860716273e29eb66b0a181d036a534fdae (diff)
Add helper for writing 24-bit integer
-rw-r--r--src/tls/tls_handshake_writer.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tls/tls_handshake_writer.cpp b/src/tls/tls_handshake_writer.cpp
index b237e8f3a..f3bb30965 100644
--- a/src/tls/tls_handshake_writer.cpp
+++ b/src/tls/tls_handshake_writer.cpp
@@ -14,6 +14,17 @@ namespace Botan {
namespace TLS {
+namespace {
+
+void store_be24(byte* out, size_t val)
+ {
+ out[0] = get_byte<u32bit>(1, val);
+ out[1] = get_byte<u32bit>(2, val);
+ out[2] = get_byte<u32bit>(3, val);
+ }
+
+}
+
std::vector<byte> Stream_Handshake_Writer::send(Handshake_Message& msg)
{
const std::vector<byte> buf = msg.serialize();
@@ -23,8 +34,7 @@ std::vector<byte> Stream_Handshake_Writer::send(Handshake_Message& msg)
send_buf[0] = msg.type();
- for(size_t i = 1; i != 4; ++i)
- send_buf[i] = get_byte<u32bit>(i, buf_size);
+ store_be24(&send_buf[1], buf_size);
send_buf += buf;