Botan 2.19.3
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
15
16namespace Botan {
17
18/**
19 * NIST SP 800-56C KDF
20 */
22 {
23 public:
24 std::string name() const override { return "SP800-56C(" + m_prf->name() + ")"; }
25
26 KDF* clone() const override { return new SP800_56C(m_prf->clone(), m_exp->clone()); }
27
28 /**
29 * Derive a key using the SP800-56C KDF.
30 *
31 * The implementation hard codes the context value for the
32 * expansion step to the empty string.
33 *
34 * @param key derived keying material K_M
35 * @param key_len the desired output length in bytes
36 * @param secret shared secret Z
37 * @param secret_len size of Z in bytes
38 * @param salt salt s of the extraction step
39 * @param salt_len size of s in bytes
40 * @param label label for the expansion step
41 * @param label_len size of label in bytes
42 *
43 * @throws Invalid_Argument key_len > 2^32
44 */
45 size_t kdf(uint8_t key[], size_t key_len,
46 const uint8_t secret[], size_t secret_len,
47 const uint8_t salt[], size_t salt_len,
48 const uint8_t label[], size_t label_len) const override;
49
50 /**
51 * @param mac MAC algorithm used for randomness extraction
52 * @param exp KDF used for key expansion
53 */
54 SP800_56C(MessageAuthenticationCode* mac, KDF* exp) : m_prf(mac), m_exp(exp) {}
55 private:
56 std::unique_ptr<MessageAuthenticationCode> m_prf;
57 std::unique_ptr<KDF> m_exp;
58 };
59}
60
61#endif
virtual size_t 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 =0
KDF * clone() const override
Definition sp800_56c.h:26
SP800_56C(MessageAuthenticationCode *mac, KDF *exp)
Definition sp800_56c.h:54
std::string name() const override
Definition sp800_56c.h:24
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition compiler.h:136
size_t salt_len
Definition x509_obj.cpp:25