Botan 3.7.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* (C) 2024 René Meusel, Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/internal/sp800_56c_two_step.h>
10
11#include <botan/internal/fmt.h>
12
13namespace Botan {
14
15std::string SP800_56C_Two_Step::name() const {
16 return fmt("SP800-56C({})", m_prf->name());
17}
18
19std::unique_ptr<KDF> SP800_56C_Two_Step::new_object() const {
20 return std::make_unique<SP800_56C_Two_Step>(m_prf->new_object(), m_exp->new_object());
21}
22
23void SP800_56C_Two_Step::perform_kdf(std::span<uint8_t> key,
24 std::span<const uint8_t> secret,
25 std::span<const uint8_t> salt,
26 std::span<const uint8_t> label) const {
27 // Randomness Extraction
28 m_prf->set_key(salt);
29 m_prf->update(secret);
30 const auto k_dk = m_prf->final();
31
32 // Key Expansion
33 m_exp->derive_key(key, k_dk, {} /* no salt */, label);
34}
35
36} // namespace Botan
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