diff options
author | Jack Lloyd <[email protected]> | 2017-11-28 18:40:01 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-28 18:40:01 -0500 |
commit | bf5b2f471eebf58ccc5eced12e5a5ea64810d679 (patch) | |
tree | fb6b43a77a9cffe5dc556220149bd8b10824c44a /src/lib/tls/msg_client_hello.cpp | |
parent | 0c399f264095baf9b225e26f5a56a8724d3e5b1e (diff) |
Run TLS hello random fields through SHA-256
Avoids exposing RNG output on the wire. Cheap precaution.
Diffstat (limited to 'src/lib/tls/msg_client_hello.cpp')
-rw-r--r-- | src/lib/tls/msg_client_hello.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/tls/msg_client_hello.cpp b/src/lib/tls/msg_client_hello.cpp index e0d3c8b65..3b13cf21d 100644 --- a/src/lib/tls/msg_client_hello.cpp +++ b/src/lib/tls/msg_client_hello.cpp @@ -10,6 +10,8 @@ #include <botan/tls_alert.h> #include <botan/tls_exceptn.h> #include <botan/rng.h> +#include <botan/hash.h> + #include <botan/internal/tls_reader.h> #include <botan/internal/tls_session_key.h> #include <botan/internal/tls_handshake_io.h> @@ -27,11 +29,15 @@ enum { }; std::vector<uint8_t> make_hello_random(RandomNumberGenerator& rng, - const Policy& policy) + const Policy& policy) { std::vector<uint8_t> buf(32); rng.randomize(buf.data(), buf.size()); + std::unique_ptr<HashFunction> sha256 = HashFunction::create_or_throw("SHA-256"); + sha256->update(buf); + sha256->final(buf); + if(policy.include_time_in_hello_random()) { const uint32_t time32 = static_cast<uint32_t>( |