Botan 3.7.1
Crypto and TLS for C&
sp800_56c_two_step.h
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#ifndef BOTAN_SP800_56C_H_
9#define BOTAN_SP800_56C_H_
10
11#include <botan/kdf.h>
12#include <botan/mac.h>
13
14namespace Botan {
15
16/**
17 * NIST SP 800-56C Two-Step KDF (Section 5)
18 */
20 public:
21 std::string name() const override;
22
23 std::unique_ptr<KDF> new_object() const override;
24
25 /**
26 * @param mac MAC algorithm used for randomness extraction
27 * @param exp KDF used for key expansion
28 */
29 SP800_56C_Two_Step(std::unique_ptr<MessageAuthenticationCode> mac, std::unique_ptr<KDF> exp) :
30 m_prf(std::move(mac)), m_exp(std::move(exp)) {}
31
32 private:
33 /**
34 * Derive a key using the SP800-56C Two-Step KDF.
35 *
36 * The implementation hard codes the context value for the
37 * expansion step to the empty string.
38 *
39 * @param key derived keying material K_M
40 * @param secret shared secret Z
41 * @param salt salt s of the extraction step
42 * @param label label for the expansion step
43 */
44 void perform_kdf(std::span<uint8_t> key,
45 std::span<const uint8_t> secret,
46 std::span<const uint8_t> salt,
47 std::span<const uint8_t> label) const override;
48
49 private:
50 std::unique_ptr<MessageAuthenticationCode> m_prf;
51 std::unique_ptr<KDF> m_exp;
52};
53} // namespace Botan
54
55#endif
std::unique_ptr< KDF > new_object() const override
std::string name() const override
SP800_56C_Two_Step(std::unique_ptr< MessageAuthenticationCode > mac, std::unique_ptr< KDF > exp)
int(* final)(unsigned char *, CTX *)