Botan 3.4.0
Crypto and TLS for C&
sp800_56c.h
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#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 KDF
18 */
19class SP800_56C final : public KDF {
20 public:
21 std::string name() const override;
22
23 std::unique_ptr<KDF> new_object() const override;
24
25 /**
26 * Derive a key using the SP800-56C KDF.
27 *
28 * The implementation hard codes the context value for the
29 * expansion step to the empty string.
30 *
31 * @param key derived keying material K_M
32 * @param key_len the desired output length in bytes
33 * @param secret shared secret Z
34 * @param secret_len size of Z in bytes
35 * @param salt salt s of the extraction step
36 * @param salt_len size of s in bytes
37 * @param label label for the expansion step
38 * @param label_len size of label in bytes
39 */
40 void kdf(uint8_t key[],
41 size_t key_len,
42 const uint8_t secret[],
43 size_t secret_len,
44 const uint8_t salt[],
45 size_t salt_len,
46 const uint8_t label[],
47 size_t label_len) const override;
48
49 /**
50 * @param mac MAC algorithm used for randomness extraction
51 * @param exp KDF used for key expansion
52 */
53 SP800_56C(std::unique_ptr<MessageAuthenticationCode> mac, std::unique_ptr<KDF> exp) :
54 m_prf(std::move(mac)), m_exp(std::move(exp)) {}
55
56 private:
57 std::unique_ptr<MessageAuthenticationCode> m_prf;
58 std::unique_ptr<KDF> m_exp;
59};
60} // namespace Botan
61
62#endif
std::unique_ptr< KDF > new_object() const override
Definition sp800_56c.cpp:18
SP800_56C(std::unique_ptr< MessageAuthenticationCode > mac, std::unique_ptr< KDF > exp)
Definition sp800_56c.h:53
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
int(* final)(unsigned char *, CTX *)