Botan 3.4.0
Crypto and TLS for C&
sp800_56c.cpp
Go to the documentation of this file.
1/*
2* KDF defined in NIST SP 800-56c
3* (C) 2016 Kai Michaelis
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#include <botan/internal/sp800_56c.h>
9
10#include <botan/internal/fmt.h>
11
12namespace Botan {
13
14std::string SP800_56C::name() const {
15 return fmt("SP800-56C({})", m_prf->name());
16}
17
18std::unique_ptr<KDF> SP800_56C::new_object() const {
19 return std::make_unique<SP800_56C>(m_prf->new_object(), m_exp->new_object());
20}
21
22void SP800_56C::kdf(uint8_t key[],
23 size_t key_len,
24 const uint8_t secret[],
25 size_t secret_len,
26 const uint8_t salt[],
27 size_t salt_len,
28 const uint8_t label[],
29 size_t label_len) const {
30 // Randomness Extraction
32
33 m_prf->set_key(salt, salt_len);
34 m_prf->update(secret, secret_len);
35 m_prf->final(k_dk);
36
37 // Key Expansion
38 m_exp->kdf(key, key_len, k_dk.data(), k_dk.size(), nullptr, 0, label, label_len);
39}
40
41} // namespace Botan
std::unique_ptr< KDF > new_object() const override
Definition sp800_56c.cpp:18
std::string name() const override
Definition sp800_56c.cpp:14
void 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 sp800_56c.cpp:22
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61