Botan  1.11.15
src/lib/tls/tls_handshake_hash.cpp
Go to the documentation of this file.
00001 /*
00002 * TLS Handshake Hash
00003 * (C) 2004-2006,2011,2012 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #include <botan/internal/tls_handshake_hash.h>
00009 #include <botan/tls_exceptn.h>
00010 #include <botan/internal/algo_registry.h>
00011 #include <botan/hash.h>
00012 
00013 namespace Botan {
00014 
00015 namespace TLS {
00016 
00017 /**
00018 * Return a TLS Handshake Hash
00019 */
00020 secure_vector<byte> Handshake_Hash::final(Protocol_Version version,
00021                                           const std::string& mac_algo) const
00022    {
00023    std::unique_ptr<HashFunction> hash;
00024 
00025    if(version.supports_ciphersuite_specific_prf())
00026       {
00027       if(mac_algo == "MD5" || mac_algo == "SHA-1")
00028          hash.reset(make_a<HashFunction>("SHA-256"));
00029       else
00030          hash.reset(make_a<HashFunction>(mac_algo));
00031       }
00032    else
00033       hash.reset(make_a<HashFunction>("Parallel(MD5,SHA-160)"));
00034 
00035    hash->update(data);
00036    return hash->final();
00037    }
00038 
00039 }
00040 
00041 }