Botan 2.19.5 Crypto and TLS for C&

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/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 {
21 std::string hash_algo = mac_algo;
22 if(!version.supports_ciphersuite_specific_prf())
23 hash_algo = "Parallel(MD5,SHA-160)";
24 else if(mac_algo == "MD5" || mac_algo == "SHA-1")
25 hash_algo = "SHA-256";
26
27 std::unique_ptr<HashFunction> hash(HashFunction::create_or_throw(hash_algo));
28 hash->update(m_data);
29 return hash->final();
30 }
31
32}
33
34}
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:329
Botan::TLS::Handshake_Hash::final
secure_vector< uint8_t > final(Protocol_Version version, const std::string &mac_algo) const
Definition: tls_handshake_hash.cpp:18
Botan::TLS::Protocol_Version
Definition: tls_version.h:22
Botan::TLS::Protocol_Version::supports_ciphersuite_specific_prf
bool supports_ciphersuite_specific_prf() const
Definition: tls_version.cpp:72
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
hash
MechanismType hash
Definition: p11_mechanism.cpp:64
hash_algo
AlgorithmIdentifier hash_algo
Definition: x509_obj.cpp:22