Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

tls_handshake_hash.cpp
Go to the documentation of this file.
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/tls_exceptn.h>
10 #include <botan/hash.h>
11
12 namespace Botan {
13
14 namespace TLS {
15
16 /**
17 * Return a TLS Handshake Hash
18 */
19 secure_vector<uint8_t> Handshake_Hash::final(Protocol_Version version,
20 const std::string& mac_algo) const
21 {
22 std::string hash_algo = mac_algo;
23 if(!version.supports_ciphersuite_specific_prf())
24 hash_algo = "Parallel(MD5,SHA-160)";
25 else if(mac_algo == "MD5" || mac_algo == "SHA-1")
26 hash_algo = "SHA-256";
27
28 std::unique_ptr<HashFunction> hash(HashFunction::create_or_throw(hash_algo));
29 hash->update(m_data);
30 return hash->final();
31 }
32
33 }
34
35 }
Botan::HashFunction::create_or_throw
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:303
Botan::TLS::Protocol_Version
Definition: tls_version.h:21
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13
Botan::TLS::Handshake_Hash::final
secure_vector< uint8_t > final(Protocol_Version version, const std::string &mac_algo) const
Definition: tls_handshake_hash.cpp:19
Botan::TLS::Protocol_Version::supports_ciphersuite_specific_prf
bool supports_ciphersuite_specific_prf() const
Definition: tls_version.cpp:75
hash
MechanismType hash
Definition: p11_mechanism.cpp:63