/src/botan/src/lib/tls/tls_handshake_hash.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * TLS Handshake Hash |
3 | | * (C) 2004-2006,2011,2012 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #include <botan/internal/tls_handshake_hash.h> |
9 | | #include <botan/hash.h> |
10 | | |
11 | | namespace Botan { |
12 | | |
13 | | namespace TLS { |
14 | | |
15 | | /** |
16 | | * Return a TLS Handshake Hash |
17 | | */ |
18 | | secure_vector<uint8_t> Handshake_Hash::final(Protocol_Version version, |
19 | | const std::string& mac_algo) const |
20 | 4.20k | { |
21 | 4.20k | std::string hash_algo = mac_algo; |
22 | 4.20k | if(!version.supports_ciphersuite_specific_prf()) |
23 | 0 | hash_algo = "Parallel(MD5,SHA-160)"; |
24 | 4.20k | else if(mac_algo == "MD5" || mac_algo == "SHA-1") |
25 | 2.11k | hash_algo = "SHA-256"; |
26 | 4.20k | |
27 | 4.20k | std::unique_ptr<HashFunction> hash(HashFunction::create_or_throw(hash_algo)); |
28 | 4.20k | hash->update(m_data); |
29 | 4.20k | return hash->final(); |
30 | 4.20k | } |
31 | | |
32 | | } |
33 | | |
34 | | } |