8 #include <botan/prf_ssl3.h>
9 #include <botan/symkey.h>
10 #include <botan/exceptn.h>
11 #include <botan/sha160.h>
12 #include <botan/md5.h>
13 #include <botan/internal/assert.h>
23 OctetString next_hash(
size_t where,
size_t want,
24 HashFunction& md5, HashFunction& sha1,
25 const byte secret[],
size_t secret_len,
26 const byte seed[],
size_t seed_len)
28 BOTAN_ASSERT(want <= md5.output_length(),
"Desired output too large");
30 const byte ASCII_A_CHAR = 0x41;
32 for(
size_t j = 0; j != where + 1; j++)
33 sha1.update(static_cast<byte>(ASCII_A_CHAR + where));
34 sha1.update(secret, secret_len);
35 sha1.update(seed, seed_len);
36 SecureVector<byte> sha1_hash = sha1.final();
38 md5.update(secret, secret_len);
39 md5.update(sha1_hash);
40 SecureVector<byte> md5_hash = md5.final();
42 return OctetString(&md5_hash[0], want);
51 const byte secret[],
size_t secret_len,
52 const byte seed[],
size_t seed_len)
const
65 const size_t produce = std::min<size_t>(key_len, md5.
output_length());
67 output = output + next_hash(counter++, produce, md5, sha1,
68 secret, secret_len, seed, seed_len);
std::invalid_argument Invalid_Argument
#define BOTAN_ASSERT(expr, msg)
SecureVector< byte > bits_of() const
SecureVector< byte > derive(size_t, const byte[], size_t, const byte[], size_t) const
size_t output_length() const