Botan  1.11.26
kdf1.cpp
Go to the documentation of this file.
1 /*
2 * KDF1
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #include <botan/kdf1.h>
9 
10 namespace Botan {
11 
12 size_t KDF1::kdf(byte key[], size_t key_len,
13  const byte secret[], size_t secret_len,
14  const byte salt[], size_t salt_len) const
15  {
16  m_hash->update(secret, secret_len);
17  m_hash->update(salt, salt_len);
18 
19  if(key_len < m_hash->output_length())
20  {
21  secure_vector<byte> v = m_hash->final();
22  copy_mem(key, v.data(), key_len);
23  return key_len;
24  }
25 
26  m_hash->final(key);
27  return m_hash->output_length();
28  }
29 
30 }
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:96
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:43
Definition: alg_id.cpp:13
size_t kdf(byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const override
Definition: kdf1.cpp:12
std::uint8_t byte
Definition: types.h:31