Coverage Report

Created: 2021-02-21 07:20

/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
      KDF* clone() const override { return new SP800_56C(m_prf->clone(), m_exp->clone()); }
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
0
      SP800_56C(MessageAuthenticationCode* mac, KDF* exp) : m_prf(mac), m_exp(exp) {}
51
   private:
52
      std::unique_ptr<MessageAuthenticationCode> m_prf;
53
      std::unique_ptr<KDF> m_exp;
54
   };
55
}
56
57
#endif