8#include <botan/internal/prf_tls.h>
10#include <botan/exceptn.h>
11#include <botan/internal/fmt.h>
20void P_hash(uint8_t out[],
22 MessageAuthenticationCode& mac,
23 const uint8_t secret[],
28 mac.set_key(secret, secret_len);
29 }
catch(Invalid_Key_Length&) {
30 throw Internal_Error(
fmt(
"The premaster secret of {} bytes is too long for TLS-PRF", secret_len));
38 while(offset != out_len) {
42 mac.update(salt, salt_len);
45 const size_t writing = std::min(h.size(), out_len - offset);
46 xor_buf(&out[offset], h.data(), writing);
54 return fmt(
"TLS-12-PRF({})", m_mac->name());
58 return std::make_unique<TLS_12_PRF>(m_mac->new_object());
63 const uint8_t secret[],
67 const uint8_t label[],
68 size_t label_len)
const {
71 msg.reserve(label_len + salt_len);
72 msg += std::make_pair(label, label_len);
73 msg += std::make_pair(salt, salt_len);
75 P_hash(key, key_len, *m_mac, secret, secret_len, msg.data(), msg.size());
std::unique_ptr< KDF > new_object() const override
void kdf(uint8_t key[], size_t key_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const override
std::string name() const override
std::string fmt(std::string_view format, const T &... args)
constexpr void xor_buf(ranges::contiguous_output_range< uint8_t > auto &&out, ranges::contiguous_range< uint8_t > auto &&in)
std::vector< T, secure_allocator< T > > secure_vector