/* * TLS Handshake Hash * (C) 2004-2006,2011,2012 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include #include #include namespace Botan { namespace TLS { /** * Return a TLS Handshake Hash */ secure_vector Handshake_Hash::final(Protocol_Version version, const std::string& mac_algo) const { auto choose_hash = [=]() { if(!version.supports_ciphersuite_specific_prf()) return "Parallel(MD5,SHA-160)"; if(mac_algo == "MD5" || mac_algo == "SHA-1") return "SHA-256"; return mac_algo.c_str(); }; const std::string hash_algo = choose_hash(); std::unique_ptr hash(HashFunction::create(hash_algo)); if(!hash) { throw Algorithm_Not_Found(hash_algo); } hash->update(m_data); return hash->final(); } } }