Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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(uint8_t key[], size_t key_len,
13 const uint8_t secret[], size_t secret_len,
14 const uint8_t salt[], size_t salt_len,
15 const uint8_t 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<uint8_t> 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 }
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::KDF1::kdf
size_t kdf(uint8_t key[], size_t key_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const override
Definition: kdf1.cpp:12
Botan::copy_mem
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:68
Botan
Definition: alg_id.cpp:13