aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_channel.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-07-10 15:21:38 +0000
committerlloyd <[email protected]>2013-07-10 15:21:38 +0000
commit4e8eb70640bb3768ab434add374bdf6f8455d2ec (patch)
treeba16494e3a9665c3d5eb7b8228fe4b15178ac785 /src/tls/tls_channel.cpp
parent2a9848fd18b1210a845d02efda38e398950bd76c (diff)
Change default policy to prohibit DTLS to minimize surprise.
Allow applications to send arbirary alert messages. Add a new optional parameter to Channel which specifies how large to make the IO buffers by default. Add Channel::reset_state, and reset the IO buffers and cipher specs after a fatal alert.
Diffstat (limited to 'src/tls/tls_channel.cpp')
-rw-r--r--src/tls/tls_channel.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp
index 51e0c11e5..20d882a40 100644
--- a/src/tls/tls_channel.cpp
+++ b/src/tls/tls_channel.cpp
@@ -23,15 +23,25 @@ Channel::Channel(std::function<void (const byte[], size_t)> output_fn,
std::function<void (const byte[], size_t, Alert)> proc_fn,
std::function<bool (const Session&)> handshake_complete,
Session_Manager& session_manager,
- RandomNumberGenerator& rng) :
+ RandomNumberGenerator& rng,
+ size_t reserved_io_buffer_size) :
m_handshake_fn(handshake_complete),
m_proc_fn(proc_fn),
m_output_fn(output_fn),
m_rng(rng),
m_session_manager(session_manager)
{
- m_writebuf.reserve(16*1024);
- m_readbuf.reserve(16*1024);
+ m_writebuf.reserve(reserved_io_buffer_size);
+ m_readbuf.reserve(reserved_io_buffer_size);
+ }
+
+void Channel::reset_state()
+ {
+ m_active_state.reset();
+ m_pending_state.reset();
+ m_readbuf.clear();
+ m_write_cipher_states.clear();
+ m_read_cipher_states.clear();
}
Channel::~Channel()
@@ -379,9 +389,7 @@ size_t Channel::received_data(const byte input[], size_t input_size)
if(alert_msg.type() == Alert::CLOSE_NOTIFY || alert_msg.is_fatal())
{
- m_active_state.reset();
- m_pending_state.reset();
-
+ reset_state();
return 0;
}
}
@@ -530,10 +538,7 @@ void Channel::send_alert(const Alert& alert)
m_session_manager.remove_entry(active->server_hello()->session_id());
if(alert.type() == Alert::CLOSE_NOTIFY || alert.is_fatal())
- {
- m_active_state.reset();
- m_pending_state.reset();
- }
+ reset_state();
}
void Channel::secure_renegotiation_check(const Client_Hello* client_hello)