aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_handshake_io.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-08-10 12:38:00 +0000
committerlloyd <[email protected]>2012-08-10 12:38:00 +0000
commit52de604c02536ef2724aa99632bf50efa9d09294 (patch)
treee48c58145787cabb1c202f2d0c4311cab86de2e4 /src/tls/tls_handshake_io.cpp
parent7afc5cac372093e211edc90bfe6533270275d8f9 (diff)
Make the CCS message a Handshake_Msg and send it through the handshake
IO layer. Needed for DTLS which needs to be able to track and retransmit the CCS if needed.
Diffstat (limited to 'src/tls/tls_handshake_io.cpp')
-rw-r--r--src/tls/tls_handshake_io.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/tls/tls_handshake_io.cpp b/src/tls/tls_handshake_io.cpp
index aa644571d..6ff8f71e0 100644
--- a/src/tls/tls_handshake_io.cpp
+++ b/src/tls/tls_handshake_io.cpp
@@ -102,10 +102,16 @@ Stream_Handshake_IO::format(const std::vector<byte>& msg,
std::vector<byte> Stream_Handshake_IO::send(const Handshake_Message& msg)
{
- const std::vector<byte> buf = format(msg.serialize(), msg.type());
+ const std::vector<byte> msg_bits = msg.serialize();
- m_writer.send(HANDSHAKE, &buf[0], buf.size());
+ if(msg.type() == HANDSHAKE_CCS)
+ {
+ m_writer.send(CHANGE_CIPHER_SPEC, msg_bits);
+ return std::vector<byte>(); // not included in handshake hashes
+ }
+ const std::vector<byte> buf = format(msg_bits, msg.type());
+ m_writer.send(HANDSHAKE, buf);
return buf;
}
@@ -282,15 +288,21 @@ Datagram_Handshake_IO::format(const std::vector<byte>& msg,
}
std::vector<byte>
-Datagram_Handshake_IO::send(const Handshake_Message& handshake_msg)
+Datagram_Handshake_IO::send(const Handshake_Message& msg)
{
- const std::vector<byte> msg = handshake_msg.serialize();
+ const std::vector<byte> msg_bits = msg.serialize();
+
+ if(msg.type() == HANDSHAKE_CCS)
+ {
+ m_writer.send(CHANGE_CIPHER_SPEC, msg_bits);
+ return std::vector<byte>(); // not included in handshake hashes
+ }
const std::vector<byte> no_fragment =
- format_w_seq(msg, handshake_msg.type(), m_out_message_seq);
+ format_w_seq(msg_bits, msg.type(), m_out_message_seq);
// FIXME: fragment to mtu size if needed
- m_writer.send(HANDSHAKE, &no_fragment[0], no_fragment.size());
+ m_writer.send(HANDSHAKE, no_fragment);
m_out_message_seq += 1;