Botan  1.11.34
Crypto and TLS for C++11
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,
15  const byte label[], size_t label_len) const
16  {
17  m_hash->update(secret, secret_len);
18  m_hash->update(label, label_len);
19  m_hash->update(salt, salt_len);
20 
21  if(key_len < m_hash->output_length())
22  {
23  secure_vector<byte> v = m_hash->final();
24  copy_mem(key, v.data(), key_len);
25  return key_len;
26  }
27 
28  m_hash->final(key);
29  return m_hash->output_length();
30  }
31 
32 }
size_t kdf(byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len, const byte label[], size_t label_len) const override
Definition: kdf1.cpp:12
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:113
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:68
Definition: alg_id.cpp:13
std::uint8_t byte
Definition: types.h:31