Botan 2.19.3
Crypto and TLS for C&
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
10namespace Botan {
11
12size_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 // FIXME: returns truncated output
30 return m_hash->output_length();
31 }
32
33}
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
void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:133
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:65
size_t salt_len
Definition x509_obj.cpp:25