16 const std::string& passphrase,
17 const byte salt_buf[],
size_t salt_size,
18 size_t iterations)
const
22 size_t pass = 0, generated = 0,
23 total_size = passphrase.
size() + salt_size;
24 size_t to_hash = std::max(iterations, total_size);
27 while(key_len > generated)
29 for(
size_t j = 0; j != pass; ++j)
32 size_t left = to_hash;
33 while(left >= total_size)
35 hash->update(salt_buf, salt_size);
36 hash->update(passphrase);
40 hash->update(salt_buf, left);
43 hash->update(salt_buf, salt_size);
45 hash->update(
reinterpret_cast<const byte*
>(passphrase.data()), left);
48 hash_buf = hash->final();
49 key.
copy(generated, &hash_buf[0], hash->output_length());
50 generated += hash->output_length();