Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
14 BOTAN_FUTURE_INTERNAL_HEADER(sp800_56c.h)
15
16 namespace Botan {
17
18 /**
19 * NIST SP 800-56C KDF
20 */
21 class BOTAN_PUBLIC_API(2,0) SP800_56C final : public KDF
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
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan::MessageAuthenticationCode
Definition: mac.h:21
m_exp
BigInt m_exp
Definition: pow_mod.cpp:51
Botan::SP800_56C::clone
KDF * clone() const override
Definition: sp800_56c.h:26
Botan::SP800_56C::SP800_56C
SP800_56C(MessageAuthenticationCode *mac, KDF *exp)
Definition: sp800_56c.h:54
salt_len
size_t salt_len
Definition: x509_obj.cpp:25
Botan
Definition: alg_id.cpp:13
Botan::KDF
Definition: kdf.h:20
Botan::KDF::kdf
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
Botan::SP800_56C::name
std::string name() const override
Definition: sp800_56c.h:24
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
Botan::SP800_56C
Definition: sp800_56c.h:21