aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls
diff options
context:
space:
mode:
Diffstat (limited to 'src/tls')
-rw-r--r--src/tls/c_hello.cpp14
-rw-r--r--src/tls/s_hello.cpp4
-rw-r--r--src/tls/tls_messages.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/src/tls/c_hello.cpp b/src/tls/c_hello.cpp
index 3164f30ee..fa187dbf1 100644
--- a/src/tls/c_hello.cpp
+++ b/src/tls/c_hello.cpp
@@ -11,9 +11,19 @@
#include <botan/internal/tls_extensions.h>
#include <botan/tls_record.h>
#include <botan/internal/stl_util.h>
+#include <botan/time.h>
namespace Botan {
+MemoryVector<byte> make_hello_random(RandomNumberGenerator& rng)
+ {
+ MemoryVector<byte> buf(32);
+ const u32bit time32 = system_time();
+ store_be(time32, buf);
+ rng.randomize(&buf[4], buf.size() - 4);
+ return buf;
+ }
+
/*
* Encode and send a Handshake message
*/
@@ -74,7 +84,7 @@ Client_Hello::Client_Hello(Record_Writer& writer,
const std::string& hostname,
const std::string& srp_identifier) :
m_version(policy.pref_version()),
- m_random(rng.random_vec(32)),
+ m_random(make_hello_random(rng)),
m_suites(policy.ciphersuites(srp_identifier != "")),
m_comp_methods(policy.compression()),
m_hostname(hostname),
@@ -97,7 +107,7 @@ Client_Hello::Client_Hello(Record_Writer& writer,
bool next_protocol) :
m_version(session.version()),
m_session_id(session.session_id()),
- m_random(rng.random_vec(32)),
+ m_random(make_hello_random(rng)),
m_hostname(session.sni_hostname()),
m_srp_identifier(session.srp_identifier()),
m_next_protocol(next_protocol),
diff --git a/src/tls/s_hello.cpp b/src/tls/s_hello.cpp
index 5ffb1e7d4..4fa67ca53 100644
--- a/src/tls/s_hello.cpp
+++ b/src/tls/s_hello.cpp
@@ -30,7 +30,7 @@ Server_Hello::Server_Hello(Record_Writer& writer,
RandomNumberGenerator& rng) :
s_version(version),
m_session_id(rng.random_vec(32)),
- s_random(rng.random_vec(32)),
+ s_random(make_hello_random(rng)),
m_fragment_size(c_hello.fragment_size()),
m_secure_renegotiation(client_has_secure_renegotiation),
m_renegotiation_info(reneg_info),
@@ -77,7 +77,7 @@ Server_Hello::Server_Hello(Record_Writer& writer,
RandomNumberGenerator& rng) :
s_version(ver),
m_session_id(session_id),
- s_random(rng.random_vec(32)),
+ s_random(make_hello_random(rng)),
suite(ciphersuite),
comp_method(compression),
m_fragment_size(max_fragment_size),
diff --git a/src/tls/tls_messages.h b/src/tls/tls_messages.h
index 67647d5a3..3da9b1076 100644
--- a/src/tls/tls_messages.h
+++ b/src/tls/tls_messages.h
@@ -40,6 +40,8 @@ class Handshake_Message
virtual void deserialize(const MemoryRegion<byte>&) = 0;
};
+MemoryVector<byte> make_hello_random(RandomNumberGenerator& rng);
+
/**
* Client Hello Message
*/