Coverage Report

Created: 2023-02-13 06:21

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