8 #include <botan/prf_tls.h>
9 #include <botan/internal/xor_buf.h>
10 #include <botan/hmac.h>
11 #include <botan/md5.h>
12 #include <botan/sha160.h>
21 void P_hash(MemoryRegion<byte>& output,
22 MessageAuthenticationCode*
mac,
23 const byte secret[],
size_t secret_len,
24 const byte seed[],
size_t seed_len)
26 mac->set_key(secret, secret_len);
28 SecureVector<byte> A(seed, seed_len);
32 while(offset != output.size())
34 const size_t this_block_len =
35 std::min<size_t>(mac->output_length(), output.size() - offset);
40 mac->update(seed, seed_len);
41 SecureVector<byte> block = mac->final();
43 xor_buf(&output[offset], &block[0], this_block_len);
44 offset += this_block_len;
69 const byte secret[],
size_t secret_len,
70 const byte seed[],
size_t seed_len)
const
74 size_t S1_len = (secret_len + 1) / 2,
75 S2_len = (secret_len + 1) / 2;
76 const byte* S1 = secret;
77 const byte* S2 = secret + (secret_len - S2_len);
79 P_hash(output, hmac_md5, S1, S1_len, seed, seed_len);
80 P_hash(output, hmac_sha1, S2, S2_len, seed, seed_len);
98 const byte secret[],
size_t secret_len,
99 const byte seed[],
size_t seed_len)
const
103 P_hash(output, hmac, secret, secret_len, seed, seed_len);
SecureVector< byte > derive(size_t key_len, const byte secret[], size_t secret_len, const byte seed[], size_t seed_len) const
MessageAuthenticationCode * mac
TLS_12_PRF(MessageAuthenticationCode *hmac)
SecureVector< byte > derive(size_t key_len, const byte secret[], size_t secret_len, const byte seed[], size_t seed_len) const
void xor_buf(byte out[], const byte in[], size_t length)