diff options
author | Jack Lloyd <[email protected]> | 2019-05-27 21:59:25 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-05-27 23:48:13 -0400 |
commit | 5ace2aa4cf7182a5879fa4d9788a6806e86871f9 (patch) | |
tree | 9e607388462985e32c6941c7d5b65290e2c745e7 /src | |
parent | 1d283a6f9e995d750b6d1801b5b64186d8b56f7b (diff) |
Fix problem in TLS message parsing tests
This started failing due to use of store_be in
Buffered_Computation::update_be in this PR. The hello request cookie
generation depended on the size of size_t, however the lib code and
test had the same bug so it was missed. Force the lengths to be 64 bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/tls/msg_hello_verify.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_tls_messages.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/tls/msg_hello_verify.cpp b/src/lib/tls/msg_hello_verify.cpp index af5349c1c..648ca1a4e 100644 --- a/src/lib/tls/msg_hello_verify.cpp +++ b/src/lib/tls/msg_hello_verify.cpp @@ -38,9 +38,9 @@ Hello_Verify_Request::Hello_Verify_Request(const std::vector<uint8_t>& client_he std::unique_ptr<MessageAuthenticationCode> hmac(MessageAuthenticationCode::create("HMAC(SHA-256)")); hmac->set_key(secret_key); - hmac->update_be(client_hello_bits.size()); + hmac->update_be(static_cast<uint64_t>(client_hello_bits.size())); hmac->update(client_hello_bits); - hmac->update_be(client_identity.size()); + hmac->update_be(static_cast<uint64_t>(client_identity.size())); hmac->update(client_identity); m_cookie = unlock(hmac->final()); diff --git a/src/tests/test_tls_messages.cpp b/src/tests/test_tls_messages.cpp index a79f5b42e..f176839db 100644 --- a/src/tests/test_tls_messages.cpp +++ b/src/tests/test_tls_messages.cpp @@ -35,8 +35,8 @@ Test::Result test_hello_verify_request() // Compute HMAC std::unique_ptr<Botan::MessageAuthenticationCode> hmac(Botan::MessageAuthenticationCode::create("HMAC(SHA-256)")); hmac->set_key(sk); - hmac->update_be(size_t(0)); - hmac->update_be(size_t(0)); + hmac->update_be(uint64_t(0)); // length of client hello + hmac->update_be(uint64_t(0)); // length of client identity std::vector<uint8_t> test = unlock(hmac->final()); result.test_eq("Cookie comparison", hfr.cookie(), test); |