aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-20 14:18:46 +0000
committerlloyd <[email protected]>2012-01-20 14:18:46 +0000
commit8756066f0e4319a0d4560202569ef3a8dad65006 (patch)
tree4881137249ca5f25a90dc514c1dc447ece6cb489
parentf7f94a9ade8869caca24aed9bde92bce117991f7 (diff)
Initialize values once in constructor instead of in each branch
-rw-r--r--src/tls/c_hello.cpp19
-rw-r--r--src/tls/tls_messages.h8
2 files changed, 13 insertions, 14 deletions
diff --git a/src/tls/c_hello.cpp b/src/tls/c_hello.cpp
index 71c0c3de9..f59420a53 100644
--- a/src/tls/c_hello.cpp
+++ b/src/tls/c_hello.cpp
@@ -120,6 +120,18 @@ Client_Hello::Client_Hello(Record_Writer& writer,
send(writer, hash);
}
+Client_Hello::Client_Hello(const MemoryRegion<byte>& buf, Handshake_Type type)
+ {
+ m_next_protocol = false;
+ m_secure_renegotiation = false;
+ m_fragment_size = 0;
+
+ if(type == CLIENT_HELLO)
+ deserialize(buf);
+ else
+ deserialize_sslv2(buf);
+ }
+
/*
* Serialize a Client Hello message
*/
@@ -204,9 +216,6 @@ void Client_Hello::deserialize_sslv2(const MemoryRegion<byte>& buf)
m_secure_renegotiation =
value_exists(m_suites, static_cast<u16bit>(TLS_EMPTY_RENEGOTIATION_INFO_SCSV));
-
- m_fragment_size = 0;
- m_next_protocol = false;
}
/*
@@ -231,10 +240,6 @@ void Client_Hello::deserialize(const MemoryRegion<byte>& buf)
m_comp_methods = reader.get_range_vector<byte>(1, 1, 255);
- m_next_protocol = false;
- m_secure_renegotiation = false;
- m_fragment_size = 0;
-
TLS_Extensions extensions(reader);
if(Server_Name_Indicator* sni = extensions.get<Server_Name_Indicator>())
diff --git a/src/tls/tls_messages.h b/src/tls/tls_messages.h
index 95c1ba0a0..d29e85f95 100644
--- a/src/tls/tls_messages.h
+++ b/src/tls/tls_messages.h
@@ -94,13 +94,7 @@ class Client_Hello : public Handshake_Message
bool next_protocol = false);
Client_Hello(const MemoryRegion<byte>& buf,
- Handshake_Type type)
- {
- if(type == CLIENT_HELLO)
- deserialize(buf);
- else
- deserialize_sslv2(buf);
- }
+ Handshake_Type type);
private:
MemoryVector<byte> serialize() const;