From a3d1249709fa983829774bf5536aa114a43077bb Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 26 Oct 2015 10:45:47 -0400 Subject: Asan fix - referencing &vec[vec.size()] instead of vec.end() Convert to a const time algo --- src/lib/tls/msg_client_kex.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/lib/tls/msg_client_kex.cpp') diff --git a/src/lib/tls/msg_client_kex.cpp b/src/lib/tls/msg_client_kex.cpp index c8dc2aad8..c5b9305c7 100644 --- a/src/lib/tls/msg_client_kex.cpp +++ b/src/lib/tls/msg_client_kex.cpp @@ -17,31 +17,12 @@ #include #include #include +#include namespace Botan { namespace TLS { -namespace { - -secure_vector strip_leading_zeros(const secure_vector& input) - { - size_t leading_zeros = 0; - - for(size_t i = 0; i != input.size(); ++i) - { - if(input[i] != 0) - break; - ++leading_zeros; - } - - secure_vector output(&input[leading_zeros], - &input[input.size()]); - return output; - } - -} - /* * Create a new Client Key Exchange message */ @@ -134,7 +115,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io, PK_Key_Agreement ka(priv_key, "Raw"); - secure_vector dh_secret = strip_leading_zeros( + secure_vector dh_secret = CT::strip_leading_zeros( ka.derive_key(0, counterparty_key.public_value()).bits_of()); if(kex_algo == "DH") @@ -373,7 +354,7 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector& contents, secure_vector shared_secret = ka.derive_key(0, client_pubkey).bits_of(); if(ka_key->algo_name() == "DH") - shared_secret = strip_leading_zeros(shared_secret); + shared_secret = CT::strip_leading_zeros(shared_secret); if(kex_algo == "DHE_PSK" || kex_algo == "ECDHE_PSK") { -- cgit v1.2.3