From 5ace2aa4cf7182a5879fa4d9788a6806e86871f9 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 27 May 2019 21:59:25 -0400 Subject: 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. --- src/lib/tls/msg_hello_verify.cpp | 4 ++-- 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& client_he std::unique_ptr hmac(MessageAuthenticationCode::create("HMAC(SHA-256)")); hmac->set_key(secret_key); - hmac->update_be(client_hello_bits.size()); + hmac->update_be(static_cast(client_hello_bits.size())); hmac->update(client_hello_bits); - hmac->update_be(client_identity.size()); + hmac->update_be(static_cast(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 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 test = unlock(hmac->final()); result.test_eq("Cookie comparison", hfr.cookie(), test); -- cgit v1.2.3