Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

kdf1_iso18033.cpp
Go to the documentation of this file.
1 /*
2 * KDF1 from ISO 18033-2
3 * (C) 2016 Philipp Weber
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #include <botan/kdf1_iso18033.h>
9
10 namespace Botan {
11
12 size_t KDF1_18033::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 uint32_t counter = 0;
18 secure_vector<uint8_t> h;
19
20 size_t offset = 0;
21 while(offset != key_len && counter != 0xFFFFFFFF)
22 {
23 m_hash->update(secret, secret_len);
24 m_hash->update_be(counter++);
25 m_hash->update(label, label_len);
26 m_hash->update(salt, salt_len);
27 m_hash->final(h);
28
29 const size_t added = std::min(h.size(), key_len - offset);
30 copy_mem(&key[offset], h.data(), added);
31 offset += added;
32 }
33
34 return offset;
35 }
36
37 }
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::KDF1_18033::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_iso18033.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
Botan::CT::min
T min(T a, T b)
Definition: ct_utils.h:180