Botan 3.6.1
Crypto and TLS for C&
sp800_56c_two_step.cpp
Go to the documentation of this file.
1/*
2* Two-Step KDF defined in NIST SP 800-56Cr2 (Section 5)
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_two_step.h>
9
10#include <botan/internal/fmt.h>
11
12namespace Botan {
13
14std::string SP800_56C_Two_Step::name() const {
15 return fmt("SP800-56C({})", m_prf->name());
16}
17
18std::unique_ptr<KDF> SP800_56C_Two_Step::new_object() const {
19 return std::make_unique<SP800_56C_Two_Step>(m_prf->new_object(), m_exp->new_object());
20}
21
22void SP800_56C_Two_Step::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
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
std::unique_ptr< KDF > new_object() const override
std::string name() const override
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