aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_handshake_hash.cpp
blob: 76766c5fcf2bf393ef590ce8c1af2d3e4d58053e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* TLS Handshake Hash
* (C) 2004-2006,2011,2012 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/internal/tls_handshake_hash.h>
#include <botan/tls_exceptn.h>
#include <botan/internal/algo_registry.h>
#include <botan/hash.h>

namespace Botan {

namespace TLS {

/**
* Return a TLS Handshake Hash
*/
secure_vector<byte> Handshake_Hash::final(Protocol_Version version,
                                          const std::string& mac_algo) const
   {
   std::unique_ptr<HashFunction> hash;

   if(version.supports_ciphersuite_specific_prf())
      {
      if(mac_algo == "MD5" || mac_algo == "SHA-1")
         hash.reset(make_a<HashFunction>("SHA-256"));
      else
         hash.reset(make_a<HashFunction>(mac_algo));
      }
   else
      hash.reset(make_a<HashFunction>("Parallel(MD5,SHA-160)"));

   hash->update(data);
   return hash->final();
   }

}

}