Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

hkdf.h
Go to the documentation of this file.
1 /*
2 * HKDF
3 * (C) 2013,2015 Jack Lloyd
4 * (C) 2016 René Korthaus, Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9 #ifndef BOTAN_HKDF_H__
10 #define BOTAN_HKDF_H__
11
12 #include <botan/mac.h>
13 #include <botan/hash.h>
14 #include <botan/kdf.h>
15
16 namespace Botan {
17
18 /**
19 * HKDF from RFC 5869.
20 */
21 class BOTAN_DLL HKDF final : public KDF
22 {
23 public:
24 /**
25 * @param prf MAC algorithm to use
26 */
27 explicit HKDF(MessageAuthenticationCode* prf) : m_prf(prf) {}
28
29 KDF* clone() const override { return new HKDF(m_prf->clone()); }
30
31 std::string name() const override { return "HKDF(" + m_prf->name() + ")"; }
32
33 size_t kdf(uint8_t key[], size_t key_len,
34 const uint8_t secret[], size_t secret_len,
35 const uint8_t salt[], size_t salt_len,
36 const uint8_t label[], size_t label_len) const override;
37
38 private:
39 std::unique_ptr<MessageAuthenticationCode> m_prf;
40 };
41
42 /**
43 * HKDF Extraction Step from RFC 5869.
44 */
45 class BOTAN_DLL HKDF_Extract final : public KDF
46 {
47 public:
48 /**
49 * @param prf MAC algorithm to use
50 */
51 explicit HKDF_Extract(MessageAuthenticationCode* prf) : m_prf(prf) {}
52
53 KDF* clone() const override { return new HKDF_Extract(m_prf->clone()); }
54
55 std::string name() const override { return "HKDF-Extract(" + m_prf->name() + ")"; }
56
57 size_t kdf(uint8_t key[], size_t key_len,
58 const uint8_t secret[], size_t secret_len,
59 const uint8_t salt[], size_t salt_len,
60 const uint8_t label[], size_t label_len) const override;
61
62 private:
63 std::unique_ptr<MessageAuthenticationCode> m_prf;
64 };
65
66 /**
67 * HKDF Expansion Step from RFC 5869.
68 */
69 class BOTAN_DLL HKDF_Expand final : public KDF
70 {
71 public:
72 /**
73 * @param prf MAC algorithm to use
74 */
75 explicit HKDF_Expand(MessageAuthenticationCode* prf) : m_prf(prf) {}
76
77 KDF* clone() const override { return new HKDF_Expand(m_prf->clone()); }
78
79 std::string name() const override { return "HKDF-Expand(" + m_prf->name() + ")"; }
80
81 size_t kdf(uint8_t key[], size_t key_len,
82 const uint8_t secret[], size_t secret_len,
83 const uint8_t salt[], size_t salt_len,
84 const uint8_t label[], size_t label_len) const override;
85
86 private:
87 std::unique_ptr<MessageAuthenticationCode> m_prf;
88 };
89
90 }
91
92 #endif
Botan::HKDF
Definition: hkdf.h:21
Botan::HKDF_Extract::clone
KDF * clone() const override
Definition: hkdf.h:53
Botan::HKDF::name
std::string name() const override
Definition: hkdf.h:31
Botan::HKDF_Expand::name
std::string name() const override
Definition: hkdf.h:79
Botan::HKDF::clone
KDF * clone() const override
Definition: hkdf.h:29
Botan::MessageAuthenticationCode
Definition: mac.h:20
Botan::HKDF_Extract::name
std::string name() const override
Definition: hkdf.h:55
Botan::HKDF_Expand::clone
KDF * clone() const override
Definition: hkdf.h:77
Botan::HKDF_Extract
Definition: hkdf.h:45
Botan::HKDF_Expand
Definition: hkdf.h:69
Botan
Definition: alg_id.cpp:13
Botan::KDF
Definition: kdf.h:20
Botan::HKDF::HKDF
HKDF(MessageAuthenticationCode *prf)
Definition: hkdf.h:27
Botan::HKDF_Extract::HKDF_Extract
HKDF_Extract(MessageAuthenticationCode *prf)
Definition: hkdf.h:51
Botan::HKDF_Expand::HKDF_Expand
HKDF_Expand(MessageAuthenticationCode *prf)
Definition: hkdf.h:75