diff options
author | lloyd <[email protected]> | 2012-03-23 18:26:28 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-03-23 18:26:28 +0000 |
commit | ff7706d833cdcf754392bf1f7efe5de8190b7990 (patch) | |
tree | 69e8209140ce89622098dbb76e594199f6e3ad26 /src/tls/rec_wri.cpp | |
parent | 9c67e7a9b20c87e6709346d75edaf951aa4c2eb5 (diff) |
For unencrypted initial handshake records, copy them to the writebuf
anyway so we can output them with a single message. For some network
approaches this won't make any difference but it might help with
something doing direct writes on each callback. Additionally it seems
important for DTLS, where each record must be contained in a single
packet.
Diffstat (limited to 'src/tls/rec_wri.cpp')
-rw-r--r-- | src/tls/rec_wri.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/tls/rec_wri.cpp b/src/tls/rec_wri.cpp index cc7c6f79a..85f178ffe 100644 --- a/src/tls/rec_wri.cpp +++ b/src/tls/rec_wri.cpp @@ -23,9 +23,10 @@ namespace TLS { * Record_Writer Constructor */ Record_Writer::Record_Writer(std::tr1::function<void (const byte[], size_t)> out) : - m_output_fn(out), m_writebuf(TLS_HEADER_SIZE + MAX_CIPHERTEXT_SIZE) + m_output_fn(out), + m_writebuf(TLS_HEADER_SIZE + MAX_CIPHERTEXT_SIZE), + m_mac(0) { - m_mac = 0; reset(); set_maximum_fragment_size(0); } @@ -210,16 +211,15 @@ void Record_Writer::send_record(byte type, const byte input[], size_t length) if(m_mac_size == 0) // initial unencrypted handshake records { - const byte header[TLS_HEADER_SIZE] = { - type, - m_version.major_version(), - m_version.minor_version(), - get_byte<u16bit>(0, length), - get_byte<u16bit>(1, length) - }; - - m_output_fn(header, TLS_HEADER_SIZE); - m_output_fn(input, length); + m_writebuf[0] = type; + m_writebuf[1] = m_version.major_version(); + m_writebuf[2] = m_version.minor_version(); + m_writebuf[3] = get_byte<u16bit>(0, length); + m_writebuf[4] = get_byte<u16bit>(1, length); + + copy_mem(&m_writebuf[TLS_HEADER_SIZE], input, length); + + m_output_fn(&m_writebuf[0], TLS_HEADER_SIZE + length); return; } |