/src/botan/src/lib/kdf/sp800_56c/sp800_56c_two_step.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
13 | | namespace Botan { |
14 | | |
15 | 0 | std::string SP800_56C_Two_Step::name() const { |
16 | 0 | return fmt("SP800-56C({})", m_prf->name()); |
17 | 0 | } |
18 | | |
19 | 0 | std::unique_ptr<KDF> SP800_56C_Two_Step::new_object() const { |
20 | 0 | return std::make_unique<SP800_56C_Two_Step>(m_prf->new_object(), m_exp->new_object()); |
21 | 0 | } |
22 | | |
23 | | void 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 | 0 | std::span<const uint8_t> label) const { |
27 | | // Randomness Extraction |
28 | 0 | m_prf->set_key(salt); |
29 | 0 | m_prf->update(secret); |
30 | 0 | const auto k_dk = m_prf->final(); |
31 | | |
32 | | // Key Expansion |
33 | 0 | m_exp->derive_key(key, k_dk, {} /* no salt */, label); |
34 | 0 | } |
35 | | |
36 | | } // namespace Botan |