/src/botan/build/include/botan/sp800_56c.h
Line | Count | Source (jump to first uncovered line) |
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 | 0 | std::string name() const override { return "SP800-56C(" + m_prf->name() + ")"; } |
25 | | |
26 | 0 | 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 | 0 | 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 |