aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-08-05 14:25:28 +0000
committerlloyd <[email protected]>2012-08-05 14:25:28 +0000
commitde2d1a699748c4cbd6f8bc8aaa67e02826108125 (patch)
tree9c9fe35db7b742a6d0e608d2639f53aaf464a4c5
parent1811a8ab7fd607d69d7881055a5c74cb48e362fd (diff)
Remove Channel::read_handshake. Have the server set expected next msg
in new_handshake_state.
-rw-r--r--src/tls/tls_channel.cpp31
-rw-r--r--src/tls/tls_channel.h3
-rw-r--r--src/tls/tls_server.cpp22
-rw-r--r--src/tls/tls_server.h2
4 files changed, 15 insertions, 43 deletions
diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp
index 0c1f9fd09..2951bbeb0 100644
--- a/src/tls/tls_channel.cpp
+++ b/src/tls/tls_channel.cpp
@@ -65,7 +65,17 @@ size_t Channel::received_data(const byte buf[], size_t buf_size)
if(rec_type == HANDSHAKE || rec_type == CHANGE_CIPHER_SPEC)
{
- read_handshake(rec_type, record);
+ if(!m_state)
+ m_state.reset(new_handshake_state());
+
+ m_state->handshake_io().add_input(rec_type, &record[0], record.size());
+
+ while(m_state && m_state->handshake_io().have_full_record())
+ {
+ std::pair<Handshake_Type, std::vector<byte> > msg =
+ m_state->handshake_io().get_next_record();
+ process_handshake_msg(msg.first, msg.second);
+ }
}
else if(rec_type == HEARTBEAT && m_peer_supports_heartbeats)
{
@@ -165,25 +175,6 @@ size_t Channel::received_data(const byte buf[], size_t buf_size)
}
}
-/*
-* Split up and process handshake messages
-*/
-void Channel::read_handshake(byte rec_type,
- const std::vector<byte>& rec_buf)
- {
- if(!m_state)
- m_state.reset(new_handshake_state());
-
- m_state->handshake_io().add_input(rec_type, &rec_buf[0], rec_buf.size());
-
- while(m_state && m_state->handshake_io().have_full_record())
- {
- std::pair<Handshake_Type, std::vector<byte> > msg =
- m_state->handshake_io().get_next_record();
- process_handshake_msg(msg.first, msg.second);
- }
- }
-
void Channel::heartbeat(const byte payload[], size_t payload_size)
{
if(!is_active())
diff --git a/src/tls/tls_channel.h b/src/tls/tls_channel.h
index c75d7723e..7a538fb9d 100644
--- a/src/tls/tls_channel.h
+++ b/src/tls/tls_channel.h
@@ -104,9 +104,6 @@ class BOTAN_DLL Channel
*/
void send_alert(const Alert& alert);
- virtual void read_handshake(byte rec_type,
- const std::vector<byte>& rec_buf);
-
virtual void process_handshake_msg(Handshake_Type type,
const std::vector<byte>& contents) = 0;
diff --git a/src/tls/tls_server.cpp b/src/tls/tls_server.cpp
index 9c6250273..25716c144 100644
--- a/src/tls/tls_server.cpp
+++ b/src/tls/tls_server.cpp
@@ -207,7 +207,9 @@ Server::Server(std::function<void (const byte[], size_t)> output_fn,
Handshake_State* Server::new_handshake_state()
{
- return new Handshake_State(new Stream_Handshake_IO(m_writer));
+ Handshake_State* state = new Handshake_State(new Stream_Handshake_IO(m_writer));
+ state->set_expected_next(CLIENT_HELLO);
+ return state;
}
/*
@@ -219,9 +221,8 @@ void Server::renegotiate(bool force_full_renegotiation)
return; // currently in handshake
m_state.reset(new_handshake_state());
-
m_state->allow_session_resumption = !force_full_renegotiation;
- m_state->set_expected_next(CLIENT_HELLO);
+
Hello_Request hello_req(m_state->handshake_io());
}
@@ -235,21 +236,6 @@ void Server::alert_notify(const Alert& alert)
}
/*
-* Split up and process handshake messages
-*/
-void Server::read_handshake(byte rec_type,
- const std::vector<byte>& rec_buf)
- {
- if(rec_type == HANDSHAKE && !m_state)
- {
- m_state.reset(new_handshake_state());
- m_state->set_expected_next(CLIENT_HELLO);
- }
-
- Channel::read_handshake(rec_type, rec_buf);
- }
-
-/*
* Process a handshake message
*/
void Server::process_handshake_msg(Handshake_Type type,
diff --git a/src/tls/tls_server.h b/src/tls/tls_server.h
index c0e687604..4b9cc7d28 100644
--- a/src/tls/tls_server.h
+++ b/src/tls/tls_server.h
@@ -50,8 +50,6 @@ class BOTAN_DLL Server : public Channel
{ return m_next_protocol; }
private:
- void read_handshake(byte, const std::vector<byte>&) override;
-
void process_handshake_msg(Handshake_Type, const std::vector<byte>&) override;
void alert_notify(const Alert& alert) override;