aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/msg_client_hello.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-11-04 22:29:20 +0000
committerlloyd <[email protected]>2014-11-04 22:29:20 +0000
commitc05e81c5d12de651dee8b752a0bd709ffed45785 (patch)
treedce791a33091728314c72af77900768cae46dd8f /src/lib/tls/msg_client_hello.cpp
parent757a72a79b31e3a18e2d48f43c7436e0566c75a0 (diff)
Let TLS policy disable putting the timestamp in the hello random fields
Diffstat (limited to 'src/lib/tls/msg_client_hello.cpp')
-rw-r--r--src/lib/tls/msg_client_hello.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/tls/msg_client_hello.cpp b/src/lib/tls/msg_client_hello.cpp
index 2e0ef9cde..605e094c4 100644
--- a/src/lib/tls/msg_client_hello.cpp
+++ b/src/lib/tls/msg_client_hello.cpp
@@ -21,15 +21,20 @@ enum {
TLS_FALLBACK_SCSV = 0x5600
};
-std::vector<byte> make_hello_random(RandomNumberGenerator& rng)
+std::vector<byte> make_hello_random(RandomNumberGenerator& rng,
+ const Policy& policy)
{
std::vector<byte> buf(32);
+ rng.randomize(&buf[0], buf.size());
- const u32bit time32 = static_cast<u32bit>(
- std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
+ if(policy.include_time_in_hello_random())
+ {
+ const u32bit time32 = static_cast<u32bit>(
+ std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
+
+ store_be(time32, &buf[0]);
+ }
- store_be(time32, &buf[0]);
- rng.randomize(&buf[4], buf.size() - 4);
return buf;
}
@@ -71,7 +76,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
const std::string& hostname,
const std::string& srp_identifier) :
m_version(version),
- m_random(make_hello_random(rng)),
+ m_random(make_hello_random(rng, policy)),
m_suites(policy.ciphersuite_list(m_version, (srp_identifier != ""))),
m_comp_methods(policy.compression())
{
@@ -112,7 +117,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
bool next_protocol) :
m_version(session.version()),
m_session_id(session.session_id()),
- m_random(make_hello_random(rng)),
+ m_random(make_hello_random(rng, policy)),
m_suites(policy.ciphersuite_list(m_version, (session.srp_identifier() != ""))),
m_comp_methods(policy.compression())
{