Botan  1.10.10
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/internal/kdf_utils.h>
9 #include <botan/kdf1.h>
10 
11 namespace Botan {
12 
13 BOTAN_REGISTER_KDF_1HASH(KDF1, "KDF1");
14 
15 size_t KDF1::kdf(byte key[], size_t key_len,
16  const byte secret[], size_t secret_len,
17  const byte salt[], size_t salt_len) const
18  {
19  m_hash->update(secret, secret_len);
20  m_hash->update(salt, salt_len);
21 
22  if(key_len < m_hash->output_length())
23  {
24  secure_vector<byte> v = m_hash->final();
25  copy_mem(key, v.data(), key_len);
26  return key_len;
27  }
28 
29  m_hash->final(key);
30  return m_hash->output_length();
31  }
32 
33 }
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:93
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:39
BOTAN_REGISTER_KDF_1HASH(KDF1,"KDF1")
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:15
std::uint8_t byte
Definition: types.h:31