Coverage Report

Created: 2024-11-21 07:03

/src/cryptopp/hkdf.h
Line
Count
Source (jump to first uncovered line)
1
// hkdf.h - written and placed in public domain by Jeffrey Walton.
2
3
/// \file hkdf.h
4
/// \brief Classes for HKDF from RFC 5869
5
/// \since Crypto++ 5.6.3
6
7
#ifndef CRYPTOPP_HKDF_H
8
#define CRYPTOPP_HKDF_H
9
10
#include "cryptlib.h"
11
#include "secblock.h"
12
#include "algparam.h"
13
#include "hmac.h"
14
15
NAMESPACE_BEGIN(CryptoPP)
16
17
/// \brief Extract-and-Expand Key Derivation Function (HKDF)
18
/// \tparam T HashTransformation class
19
/// \sa <A HREF="http://eprint.iacr.org/2010/264">Cryptographic Extraction and Key
20
///   Derivation: The HKDF Scheme</A> and
21
///   <A HREF="http://tools.ietf.org/html/rfc5869">HMAC-based Extract-and-Expand Key
22
///   Derivation Function (HKDF)</A>
23
/// \since Crypto++ 5.6.3
24
template <class T>
25
class HKDF : public KeyDerivationFunction
26
{
27
public:
28
  virtual ~HKDF() {}
29
30
205
  static std::string StaticAlgorithmName () {
31
205
    const std::string name(std::string("HKDF(") +
32
205
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
205
    return name;
34
205
  }
CryptoPP::HKDF<CryptoPP::SHA1>::StaticAlgorithmName()
Line
Count
Source
30
15
  static std::string StaticAlgorithmName () {
31
15
    const std::string name(std::string("HKDF(") +
32
15
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
15
    return name;
34
15
  }
CryptoPP::HKDF<CryptoPP::SHA224>::StaticAlgorithmName()
Line
Count
Source
30
8
  static std::string StaticAlgorithmName () {
31
8
    const std::string name(std::string("HKDF(") +
32
8
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
8
    return name;
34
8
  }
CryptoPP::HKDF<CryptoPP::SHA384>::StaticAlgorithmName()
Line
Count
Source
30
10
  static std::string StaticAlgorithmName () {
31
10
    const std::string name(std::string("HKDF(") +
32
10
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
10
    return name;
34
10
  }
CryptoPP::HKDF<CryptoPP::SHA512>::StaticAlgorithmName()
Line
Count
Source
30
1
  static std::string StaticAlgorithmName () {
31
1
    const std::string name(std::string("HKDF(") +
32
1
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
1
    return name;
34
1
  }
CryptoPP::HKDF<CryptoPP::SHAKE128>::StaticAlgorithmName()
Line
Count
Source
30
18
  static std::string StaticAlgorithmName () {
31
18
    const std::string name(std::string("HKDF(") +
32
18
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
18
    return name;
34
18
  }
CryptoPP::HKDF<CryptoPP::SHAKE256>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD128>::StaticAlgorithmName()
Line
Count
Source
30
6
  static std::string StaticAlgorithmName () {
31
6
    const std::string name(std::string("HKDF(") +
32
6
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
6
    return name;
34
6
  }
CryptoPP::HKDF<CryptoPP::RIPEMD160>::StaticAlgorithmName()
Line
Count
Source
30
10
  static std::string StaticAlgorithmName () {
31
10
    const std::string name(std::string("HKDF(") +
32
10
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
10
    return name;
34
10
  }
CryptoPP::HKDF<CryptoPP::RIPEMD256>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD320>::StaticAlgorithmName()
Line
Count
Source
30
7
  static std::string StaticAlgorithmName () {
31
7
    const std::string name(std::string("HKDF(") +
32
7
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
7
    return name;
34
7
  }
CryptoPP::HKDF<CryptoPP::Whirlpool>::StaticAlgorithmName()
Line
Count
Source
30
40
  static std::string StaticAlgorithmName () {
31
40
    const std::string name(std::string("HKDF(") +
32
40
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
40
    return name;
34
40
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::StaticAlgorithmName()
Line
Count
Source
30
9
  static std::string StaticAlgorithmName () {
31
9
    const std::string name(std::string("HKDF(") +
32
9
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
9
    return name;
34
9
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::StaticAlgorithmName()
Line
Count
Source
30
6
  static std::string StaticAlgorithmName () {
31
6
    const std::string name(std::string("HKDF(") +
32
6
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
6
    return name;
34
6
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::StaticAlgorithmName()
Line
Count
Source
30
17
  static std::string StaticAlgorithmName () {
31
17
    const std::string name(std::string("HKDF(") +
32
17
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
17
    return name;
34
17
  }
CryptoPP::HKDF<CryptoPP::SM3>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::BLAKE2b>::StaticAlgorithmName()
Line
Count
Source
30
2
  static std::string StaticAlgorithmName () {
31
2
    const std::string name(std::string("HKDF(") +
32
2
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
2
    return name;
34
2
  }
CryptoPP::HKDF<CryptoPP::BLAKE2s>::StaticAlgorithmName()
Line
Count
Source
30
9
  static std::string StaticAlgorithmName () {
31
9
    const std::string name(std::string("HKDF(") +
32
9
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
9
    return name;
34
9
  }
CryptoPP::HKDF<CryptoPP::Tiger>::StaticAlgorithmName()
Line
Count
Source
30
5
  static std::string StaticAlgorithmName () {
31
5
    const std::string name(std::string("HKDF(") +
32
5
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
5
    return name;
34
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::StaticAlgorithmName()
Line
Count
Source
30
5
  static std::string StaticAlgorithmName () {
31
5
    const std::string name(std::string("HKDF(") +
32
5
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
5
    return name;
34
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::StaticAlgorithmName()
Line
Count
Source
30
2
  static std::string StaticAlgorithmName () {
31
2
    const std::string name(std::string("HKDF(") +
32
2
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
2
    return name;
34
2
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::StaticAlgorithmName()
Line
Count
Source
30
1
  static std::string StaticAlgorithmName () {
31
1
    const std::string name(std::string("HKDF(") +
32
1
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
1
    return name;
34
1
  }
CryptoPP::HKDF<CryptoPP::LSH224>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::LSH256>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
CryptoPP::HKDF<CryptoPP::LSH384>::StaticAlgorithmName()
Line
Count
Source
30
5
  static std::string StaticAlgorithmName () {
31
5
    const std::string name(std::string("HKDF(") +
32
5
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
5
    return name;
34
5
  }
CryptoPP::HKDF<CryptoPP::LSH512>::StaticAlgorithmName()
Line
Count
Source
30
1
  static std::string StaticAlgorithmName () {
31
1
    const std::string name(std::string("HKDF(") +
32
1
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
1
    return name;
34
1
  }
CryptoPP::HKDF<CryptoPP::LSH512_256>::StaticAlgorithmName()
Line
Count
Source
30
4
  static std::string StaticAlgorithmName () {
31
4
    const std::string name(std::string("HKDF(") +
32
4
      std::string(T::StaticAlgorithmName()) + std::string(")"));
33
4
    return name;
34
4
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::StaticAlgorithmName()
35
36
  // KeyDerivationFunction interface
37
205
  std::string AlgorithmName() const {
38
205
    return StaticAlgorithmName();
39
205
  }
CryptoPP::HKDF<CryptoPP::SHA1>::AlgorithmName() const
Line
Count
Source
37
15
  std::string AlgorithmName() const {
38
15
    return StaticAlgorithmName();
39
15
  }
CryptoPP::HKDF<CryptoPP::SHA224>::AlgorithmName() const
Line
Count
Source
37
8
  std::string AlgorithmName() const {
38
8
    return StaticAlgorithmName();
39
8
  }
CryptoPP::HKDF<CryptoPP::SHA384>::AlgorithmName() const
Line
Count
Source
37
10
  std::string AlgorithmName() const {
38
10
    return StaticAlgorithmName();
39
10
  }
CryptoPP::HKDF<CryptoPP::SHA512>::AlgorithmName() const
Line
Count
Source
37
1
  std::string AlgorithmName() const {
38
1
    return StaticAlgorithmName();
39
1
  }
CryptoPP::HKDF<CryptoPP::SHAKE128>::AlgorithmName() const
Line
Count
Source
37
18
  std::string AlgorithmName() const {
38
18
    return StaticAlgorithmName();
39
18
  }
CryptoPP::HKDF<CryptoPP::SHAKE256>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD128>::AlgorithmName() const
Line
Count
Source
37
6
  std::string AlgorithmName() const {
38
6
    return StaticAlgorithmName();
39
6
  }
CryptoPP::HKDF<CryptoPP::RIPEMD160>::AlgorithmName() const
Line
Count
Source
37
10
  std::string AlgorithmName() const {
38
10
    return StaticAlgorithmName();
39
10
  }
CryptoPP::HKDF<CryptoPP::RIPEMD256>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD320>::AlgorithmName() const
Line
Count
Source
37
7
  std::string AlgorithmName() const {
38
7
    return StaticAlgorithmName();
39
7
  }
CryptoPP::HKDF<CryptoPP::Whirlpool>::AlgorithmName() const
Line
Count
Source
37
40
  std::string AlgorithmName() const {
38
40
    return StaticAlgorithmName();
39
40
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::AlgorithmName() const
Line
Count
Source
37
9
  std::string AlgorithmName() const {
38
9
    return StaticAlgorithmName();
39
9
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::AlgorithmName() const
Line
Count
Source
37
6
  std::string AlgorithmName() const {
38
6
    return StaticAlgorithmName();
39
6
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::AlgorithmName() const
Line
Count
Source
37
17
  std::string AlgorithmName() const {
38
17
    return StaticAlgorithmName();
39
17
  }
CryptoPP::HKDF<CryptoPP::SM3>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::BLAKE2b>::AlgorithmName() const
Line
Count
Source
37
2
  std::string AlgorithmName() const {
38
2
    return StaticAlgorithmName();
39
2
  }
CryptoPP::HKDF<CryptoPP::BLAKE2s>::AlgorithmName() const
Line
Count
Source
37
9
  std::string AlgorithmName() const {
38
9
    return StaticAlgorithmName();
39
9
  }
CryptoPP::HKDF<CryptoPP::Tiger>::AlgorithmName() const
Line
Count
Source
37
5
  std::string AlgorithmName() const {
38
5
    return StaticAlgorithmName();
39
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::AlgorithmName() const
Line
Count
Source
37
5
  std::string AlgorithmName() const {
38
5
    return StaticAlgorithmName();
39
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::AlgorithmName() const
Line
Count
Source
37
2
  std::string AlgorithmName() const {
38
2
    return StaticAlgorithmName();
39
2
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::AlgorithmName() const
Line
Count
Source
37
1
  std::string AlgorithmName() const {
38
1
    return StaticAlgorithmName();
39
1
  }
CryptoPP::HKDF<CryptoPP::LSH224>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::LSH256>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
CryptoPP::HKDF<CryptoPP::LSH384>::AlgorithmName() const
Line
Count
Source
37
5
  std::string AlgorithmName() const {
38
5
    return StaticAlgorithmName();
39
5
  }
CryptoPP::HKDF<CryptoPP::LSH512>::AlgorithmName() const
Line
Count
Source
37
1
  std::string AlgorithmName() const {
38
1
    return StaticAlgorithmName();
39
1
  }
CryptoPP::HKDF<CryptoPP::LSH512_256>::AlgorithmName() const
Line
Count
Source
37
4
  std::string AlgorithmName() const {
38
4
    return StaticAlgorithmName();
39
4
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::AlgorithmName() const
40
41
  // KeyDerivationFunction interface
42
1.17k
  size_t MaxDerivedKeyLength() const {
43
1.17k
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
1.17k
  }
CryptoPP::HKDF<CryptoPP::SHA1>::MaxDerivedKeyLength() const
Line
Count
Source
42
77
  size_t MaxDerivedKeyLength() const {
43
77
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
77
  }
CryptoPP::HKDF<CryptoPP::SHA224>::MaxDerivedKeyLength() const
Line
Count
Source
42
38
  size_t MaxDerivedKeyLength() const {
43
38
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
38
  }
CryptoPP::HKDF<CryptoPP::SHA384>::MaxDerivedKeyLength() const
Line
Count
Source
42
53
  size_t MaxDerivedKeyLength() const {
43
53
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
53
  }
CryptoPP::HKDF<CryptoPP::SHA512>::MaxDerivedKeyLength() const
Line
Count
Source
42
55
  size_t MaxDerivedKeyLength() const {
43
55
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
55
  }
CryptoPP::HKDF<CryptoPP::SHAKE128>::MaxDerivedKeyLength() const
Line
Count
Source
42
77
  size_t MaxDerivedKeyLength() const {
43
77
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
77
  }
CryptoPP::HKDF<CryptoPP::SHAKE256>::MaxDerivedKeyLength() const
Line
Count
Source
42
57
  size_t MaxDerivedKeyLength() const {
43
57
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
57
  }
CryptoPP::HKDF<CryptoPP::RIPEMD128>::MaxDerivedKeyLength() const
Line
Count
Source
42
26
  size_t MaxDerivedKeyLength() const {
43
26
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
26
  }
CryptoPP::HKDF<CryptoPP::RIPEMD160>::MaxDerivedKeyLength() const
Line
Count
Source
42
44
  size_t MaxDerivedKeyLength() const {
43
44
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
44
  }
CryptoPP::HKDF<CryptoPP::RIPEMD256>::MaxDerivedKeyLength() const
Line
Count
Source
42
30
  size_t MaxDerivedKeyLength() const {
43
30
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
30
  }
CryptoPP::HKDF<CryptoPP::RIPEMD320>::MaxDerivedKeyLength() const
Line
Count
Source
42
44
  size_t MaxDerivedKeyLength() const {
43
44
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
44
  }
CryptoPP::HKDF<CryptoPP::Whirlpool>::MaxDerivedKeyLength() const
Line
Count
Source
42
141
  size_t MaxDerivedKeyLength() const {
43
141
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
141
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::MaxDerivedKeyLength() const
Line
Count
Source
42
33
  size_t MaxDerivedKeyLength() const {
43
33
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
33
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::MaxDerivedKeyLength() const
Line
Count
Source
42
32
  size_t MaxDerivedKeyLength() const {
43
32
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
32
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::MaxDerivedKeyLength() const
Line
Count
Source
42
49
  size_t MaxDerivedKeyLength() const {
43
49
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
49
  }
CryptoPP::HKDF<CryptoPP::SM3>::MaxDerivedKeyLength() const
Line
Count
Source
42
38
  size_t MaxDerivedKeyLength() const {
43
38
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
38
  }
CryptoPP::HKDF<CryptoPP::BLAKE2b>::MaxDerivedKeyLength() const
Line
Count
Source
42
29
  size_t MaxDerivedKeyLength() const {
43
29
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
29
  }
CryptoPP::HKDF<CryptoPP::BLAKE2s>::MaxDerivedKeyLength() const
Line
Count
Source
42
70
  size_t MaxDerivedKeyLength() const {
43
70
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
70
  }
CryptoPP::HKDF<CryptoPP::Tiger>::MaxDerivedKeyLength() const
Line
Count
Source
42
25
  size_t MaxDerivedKeyLength() const {
43
25
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
25
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::MaxDerivedKeyLength() const
Line
Count
Source
42
21
  size_t MaxDerivedKeyLength() const {
43
21
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
21
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::MaxDerivedKeyLength() const
Line
Count
Source
42
24
  size_t MaxDerivedKeyLength() const {
43
24
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
24
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::MaxDerivedKeyLength() const
Line
Count
Source
42
30
  size_t MaxDerivedKeyLength() const {
43
30
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
30
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::MaxDerivedKeyLength() const
Line
Count
Source
42
70
  size_t MaxDerivedKeyLength() const {
43
70
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
70
  }
CryptoPP::HKDF<CryptoPP::LSH224>::MaxDerivedKeyLength() const
Line
Count
Source
42
23
  size_t MaxDerivedKeyLength() const {
43
23
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
23
  }
CryptoPP::HKDF<CryptoPP::LSH256>::MaxDerivedKeyLength() const
Line
Count
Source
42
25
  size_t MaxDerivedKeyLength() const {
43
25
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
25
  }
CryptoPP::HKDF<CryptoPP::LSH384>::MaxDerivedKeyLength() const
Line
Count
Source
42
29
  size_t MaxDerivedKeyLength() const {
43
29
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
29
  }
CryptoPP::HKDF<CryptoPP::LSH512>::MaxDerivedKeyLength() const
Line
Count
Source
42
20
  size_t MaxDerivedKeyLength() const {
43
20
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
20
  }
CryptoPP::HKDF<CryptoPP::LSH512_256>::MaxDerivedKeyLength() const
Line
Count
Source
42
19
  size_t MaxDerivedKeyLength() const {
43
19
    return static_cast<size_t>(T::DIGESTSIZE) * 255;
44
19
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::MaxDerivedKeyLength() const
45
46
  // KeyDerivationFunction interface
47
  size_t GetValidDerivedLength(size_t keylength) const;
48
49
  // KeyDerivationFunction interface
50
  size_t DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen,
51
      const NameValuePairs& params) const;
52
53
  /// \brief Derive a key from a seed
54
  /// \param derived the derived output buffer
55
  /// \param derivedLen the size of the derived buffer, in bytes
56
  /// \param secret the seed input buffer
57
  /// \param secretLen the size of the secret buffer, in bytes
58
  /// \param salt the salt input buffer
59
  /// \param saltLen the size of the salt buffer, in bytes
60
  /// \param info the additional input buffer
61
  /// \param infoLen the size of the info buffer, in bytes
62
  /// \return the number of iterations performed
63
  /// \throw InvalidDerivedKeyLength if <tt>derivedLen</tt> is invalid for the scheme
64
  /// \details DeriveKey() provides a standard interface to derive a key from
65
  ///   a seed and other parameters. Each class that derives from KeyDerivationFunction
66
  ///   provides an overload that accepts most parameters used by the derivation function.
67
  /// \details <tt>salt</tt> and <tt>info</tt> can be <tt>nullptr</tt> with 0 length.
68
  ///   HKDF is unusual in that a non-NULL salt with length 0 is different than a
69
  ///   NULL <tt>salt</tt>. A NULL <tt>salt</tt> causes HKDF to use a string of 0's
70
  ///   of length <tt>T::DIGESTSIZE</tt> for the <tt>salt</tt>.
71
  /// \details HKDF always returns 1 because it only performs 1 iteration. Other
72
  ///   derivation functions, like PBKDF's, will return more interesting values.
73
  size_t DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen,
74
      const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const;
75
76
protected:
77
  // KeyDerivationFunction interface
78
205
  const Algorithm & GetAlgorithm() const {
79
205
    return *this;
80
205
  }
CryptoPP::HKDF<CryptoPP::SHA1>::GetAlgorithm() const
Line
Count
Source
78
15
  const Algorithm & GetAlgorithm() const {
79
15
    return *this;
80
15
  }
CryptoPP::HKDF<CryptoPP::SHA224>::GetAlgorithm() const
Line
Count
Source
78
8
  const Algorithm & GetAlgorithm() const {
79
8
    return *this;
80
8
  }
CryptoPP::HKDF<CryptoPP::SHA384>::GetAlgorithm() const
Line
Count
Source
78
10
  const Algorithm & GetAlgorithm() const {
79
10
    return *this;
80
10
  }
CryptoPP::HKDF<CryptoPP::SHA512>::GetAlgorithm() const
Line
Count
Source
78
1
  const Algorithm & GetAlgorithm() const {
79
1
    return *this;
80
1
  }
CryptoPP::HKDF<CryptoPP::SHAKE128>::GetAlgorithm() const
Line
Count
Source
78
18
  const Algorithm & GetAlgorithm() const {
79
18
    return *this;
80
18
  }
CryptoPP::HKDF<CryptoPP::SHAKE256>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD128>::GetAlgorithm() const
Line
Count
Source
78
6
  const Algorithm & GetAlgorithm() const {
79
6
    return *this;
80
6
  }
CryptoPP::HKDF<CryptoPP::RIPEMD160>::GetAlgorithm() const
Line
Count
Source
78
10
  const Algorithm & GetAlgorithm() const {
79
10
    return *this;
80
10
  }
CryptoPP::HKDF<CryptoPP::RIPEMD256>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::RIPEMD320>::GetAlgorithm() const
Line
Count
Source
78
7
  const Algorithm & GetAlgorithm() const {
79
7
    return *this;
80
7
  }
CryptoPP::HKDF<CryptoPP::Whirlpool>::GetAlgorithm() const
Line
Count
Source
78
40
  const Algorithm & GetAlgorithm() const {
79
40
    return *this;
80
40
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::GetAlgorithm() const
Line
Count
Source
78
9
  const Algorithm & GetAlgorithm() const {
79
9
    return *this;
80
9
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::GetAlgorithm() const
Line
Count
Source
78
6
  const Algorithm & GetAlgorithm() const {
79
6
    return *this;
80
6
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::GetAlgorithm() const
Line
Count
Source
78
17
  const Algorithm & GetAlgorithm() const {
79
17
    return *this;
80
17
  }
CryptoPP::HKDF<CryptoPP::SM3>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::BLAKE2b>::GetAlgorithm() const
Line
Count
Source
78
2
  const Algorithm & GetAlgorithm() const {
79
2
    return *this;
80
2
  }
CryptoPP::HKDF<CryptoPP::BLAKE2s>::GetAlgorithm() const
Line
Count
Source
78
9
  const Algorithm & GetAlgorithm() const {
79
9
    return *this;
80
9
  }
CryptoPP::HKDF<CryptoPP::Tiger>::GetAlgorithm() const
Line
Count
Source
78
5
  const Algorithm & GetAlgorithm() const {
79
5
    return *this;
80
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::GetAlgorithm() const
Line
Count
Source
78
5
  const Algorithm & GetAlgorithm() const {
79
5
    return *this;
80
5
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::GetAlgorithm() const
Line
Count
Source
78
2
  const Algorithm & GetAlgorithm() const {
79
2
    return *this;
80
2
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::GetAlgorithm() const
Line
Count
Source
78
1
  const Algorithm & GetAlgorithm() const {
79
1
    return *this;
80
1
  }
CryptoPP::HKDF<CryptoPP::LSH224>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::LSH256>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
CryptoPP::HKDF<CryptoPP::LSH384>::GetAlgorithm() const
Line
Count
Source
78
5
  const Algorithm & GetAlgorithm() const {
79
5
    return *this;
80
5
  }
CryptoPP::HKDF<CryptoPP::LSH512>::GetAlgorithm() const
Line
Count
Source
78
1
  const Algorithm & GetAlgorithm() const {
79
1
    return *this;
80
1
  }
CryptoPP::HKDF<CryptoPP::LSH512_256>::GetAlgorithm() const
Line
Count
Source
78
4
  const Algorithm & GetAlgorithm() const {
79
4
    return *this;
80
4
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::GetAlgorithm() const
81
82
  // If salt is absent (NULL), then use the NULL vector. Missing is different than
83
  // EMPTY (Non-NULL, 0 length). The length of s_NullVector used depends on the Hash
84
  // function. SHA-256 will use 32 bytes of s_NullVector.
85
  typedef byte NullVectorType[T::DIGESTSIZE];
86
191
  static const NullVectorType& GetNullVector() {
87
191
    static const NullVectorType s_NullVector = {0};
88
191
    return s_NullVector;
89
191
  }
CryptoPP::HKDF<CryptoPP::SHA1>::GetNullVector()
Line
Count
Source
86
22
  static const NullVectorType& GetNullVector() {
87
22
    static const NullVectorType s_NullVector = {0};
88
22
    return s_NullVector;
89
22
  }
CryptoPP::HKDF<CryptoPP::SHA224>::GetNullVector()
Line
Count
Source
86
1
  static const NullVectorType& GetNullVector() {
87
1
    static const NullVectorType s_NullVector = {0};
88
1
    return s_NullVector;
89
1
  }
CryptoPP::HKDF<CryptoPP::SHA384>::GetNullVector()
Line
Count
Source
86
5
  static const NullVectorType& GetNullVector() {
87
5
    static const NullVectorType s_NullVector = {0};
88
5
    return s_NullVector;
89
5
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA512>::GetNullVector()
CryptoPP::HKDF<CryptoPP::SHAKE128>::GetNullVector()
Line
Count
Source
86
24
  static const NullVectorType& GetNullVector() {
87
24
    static const NullVectorType s_NullVector = {0};
88
24
    return s_NullVector;
89
24
  }
CryptoPP::HKDF<CryptoPP::SHAKE256>::GetNullVector()
Line
Count
Source
86
25
  static const NullVectorType& GetNullVector() {
87
25
    static const NullVectorType s_NullVector = {0};
88
25
    return s_NullVector;
89
25
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD128>::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD160>::GetNullVector()
CryptoPP::HKDF<CryptoPP::RIPEMD256>::GetNullVector()
Line
Count
Source
86
3
  static const NullVectorType& GetNullVector() {
87
3
    static const NullVectorType s_NullVector = {0};
88
3
    return s_NullVector;
89
3
  }
CryptoPP::HKDF<CryptoPP::RIPEMD320>::GetNullVector()
Line
Count
Source
86
9
  static const NullVectorType& GetNullVector() {
87
9
    static const NullVectorType s_NullVector = {0};
88
9
    return s_NullVector;
89
9
  }
CryptoPP::HKDF<CryptoPP::Whirlpool>::GetNullVector()
Line
Count
Source
86
32
  static const NullVectorType& GetNullVector() {
87
32
    static const NullVectorType s_NullVector = {0};
88
32
    return s_NullVector;
89
32
  }
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::GetNullVector()
Line
Count
Source
86
2
  static const NullVectorType& GetNullVector() {
87
2
    static const NullVectorType s_NullVector = {0};
88
2
    return s_NullVector;
89
2
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Weak1::MD4>::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Weak1::MD5>::GetNullVector()
CryptoPP::HKDF<CryptoPP::SM3>::GetNullVector()
Line
Count
Source
86
3
  static const NullVectorType& GetNullVector() {
87
3
    static const NullVectorType s_NullVector = {0};
88
3
    return s_NullVector;
89
3
  }
CryptoPP::HKDF<CryptoPP::BLAKE2b>::GetNullVector()
Line
Count
Source
86
1
  static const NullVectorType& GetNullVector() {
87
1
    static const NullVectorType s_NullVector = {0};
88
1
    return s_NullVector;
89
1
  }
CryptoPP::HKDF<CryptoPP::BLAKE2s>::GetNullVector()
Line
Count
Source
86
8
  static const NullVectorType& GetNullVector() {
87
8
    static const NullVectorType s_NullVector = {0};
88
8
    return s_NullVector;
89
8
  }
CryptoPP::HKDF<CryptoPP::Tiger>::GetNullVector()
Line
Count
Source
86
1
  static const NullVectorType& GetNullVector() {
87
1
    static const NullVectorType s_NullVector = {0};
88
1
    return s_NullVector;
89
1
  }
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::GetNullVector()
Line
Count
Source
86
4
  static const NullVectorType& GetNullVector() {
87
4
    static const NullVectorType s_NullVector = {0};
88
4
    return s_NullVector;
89
4
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::GetNullVector()
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::GetNullVector()
Line
Count
Source
86
50
  static const NullVectorType& GetNullVector() {
87
50
    static const NullVectorType s_NullVector = {0};
88
50
    return s_NullVector;
89
50
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH224>::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH256>::GetNullVector()
CryptoPP::HKDF<CryptoPP::LSH384>::GetNullVector()
Line
Count
Source
86
1
  static const NullVectorType& GetNullVector() {
87
1
    static const NullVectorType s_NullVector = {0};
88
1
    return s_NullVector;
89
1
  }
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH512>::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH512_256>::GetNullVector()
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::GetNullVector()
90
};
91
92
template <class T>
93
size_t HKDF<T>::GetValidDerivedLength(size_t keylength) const
94
974
{
95
974
  if (keylength > MaxDerivedKeyLength())
96
205
    return MaxDerivedKeyLength();
97
769
  return keylength;
98
974
}
CryptoPP::HKDF<CryptoPP::SHA1>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
62
{
95
62
  if (keylength > MaxDerivedKeyLength())
96
15
    return MaxDerivedKeyLength();
97
47
  return keylength;
98
62
}
CryptoPP::HKDF<CryptoPP::SHA224>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
30
{
95
30
  if (keylength > MaxDerivedKeyLength())
96
8
    return MaxDerivedKeyLength();
97
22
  return keylength;
98
30
}
CryptoPP::HKDF<CryptoPP::SHA384>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
43
{
95
43
  if (keylength > MaxDerivedKeyLength())
96
10
    return MaxDerivedKeyLength();
97
33
  return keylength;
98
43
}
CryptoPP::HKDF<CryptoPP::SHA512>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
54
{
95
54
  if (keylength > MaxDerivedKeyLength())
96
1
    return MaxDerivedKeyLength();
97
53
  return keylength;
98
54
}
CryptoPP::HKDF<CryptoPP::SHAKE128>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
59
{
95
59
  if (keylength > MaxDerivedKeyLength())
96
18
    return MaxDerivedKeyLength();
97
41
  return keylength;
98
59
}
CryptoPP::HKDF<CryptoPP::SHAKE256>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
53
{
95
53
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
49
  return keylength;
98
53
}
CryptoPP::HKDF<CryptoPP::RIPEMD128>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
20
{
95
20
  if (keylength > MaxDerivedKeyLength())
96
6
    return MaxDerivedKeyLength();
97
14
  return keylength;
98
20
}
CryptoPP::HKDF<CryptoPP::RIPEMD160>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
34
{
95
34
  if (keylength > MaxDerivedKeyLength())
96
10
    return MaxDerivedKeyLength();
97
24
  return keylength;
98
34
}
CryptoPP::HKDF<CryptoPP::RIPEMD256>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
26
{
95
26
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
22
  return keylength;
98
26
}
CryptoPP::HKDF<CryptoPP::RIPEMD320>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
37
{
95
37
  if (keylength > MaxDerivedKeyLength())
96
7
    return MaxDerivedKeyLength();
97
30
  return keylength;
98
37
}
CryptoPP::HKDF<CryptoPP::Whirlpool>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
101
{
95
101
  if (keylength > MaxDerivedKeyLength())
96
40
    return MaxDerivedKeyLength();
97
61
  return keylength;
98
101
}
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
24
{
95
24
  if (keylength > MaxDerivedKeyLength())
96
9
    return MaxDerivedKeyLength();
97
15
  return keylength;
98
24
}
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
26
{
95
26
  if (keylength > MaxDerivedKeyLength())
96
6
    return MaxDerivedKeyLength();
97
20
  return keylength;
98
26
}
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
32
{
95
32
  if (keylength > MaxDerivedKeyLength())
96
17
    return MaxDerivedKeyLength();
97
15
  return keylength;
98
32
}
CryptoPP::HKDF<CryptoPP::SM3>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
34
{
95
34
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
30
  return keylength;
98
34
}
CryptoPP::HKDF<CryptoPP::BLAKE2b>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
27
{
95
27
  if (keylength > MaxDerivedKeyLength())
96
2
    return MaxDerivedKeyLength();
97
25
  return keylength;
98
27
}
CryptoPP::HKDF<CryptoPP::BLAKE2s>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
61
{
95
61
  if (keylength > MaxDerivedKeyLength())
96
9
    return MaxDerivedKeyLength();
97
52
  return keylength;
98
61
}
CryptoPP::HKDF<CryptoPP::Tiger>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
20
{
95
20
  if (keylength > MaxDerivedKeyLength())
96
5
    return MaxDerivedKeyLength();
97
15
  return keylength;
98
20
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
17
{
95
17
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
13
  return keylength;
98
17
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
19
{
95
19
  if (keylength > MaxDerivedKeyLength())
96
5
    return MaxDerivedKeyLength();
97
14
  return keylength;
98
19
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
28
{
95
28
  if (keylength > MaxDerivedKeyLength())
96
2
    return MaxDerivedKeyLength();
97
26
  return keylength;
98
28
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
69
{
95
69
  if (keylength > MaxDerivedKeyLength())
96
1
    return MaxDerivedKeyLength();
97
68
  return keylength;
98
69
}
CryptoPP::HKDF<CryptoPP::LSH224>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
19
{
95
19
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
15
  return keylength;
98
19
}
CryptoPP::HKDF<CryptoPP::LSH256>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
21
{
95
21
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
17
  return keylength;
98
21
}
CryptoPP::HKDF<CryptoPP::LSH384>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
24
{
95
24
  if (keylength > MaxDerivedKeyLength())
96
5
    return MaxDerivedKeyLength();
97
19
  return keylength;
98
24
}
CryptoPP::HKDF<CryptoPP::LSH512>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
19
{
95
19
  if (keylength > MaxDerivedKeyLength())
96
1
    return MaxDerivedKeyLength();
97
18
  return keylength;
98
19
}
CryptoPP::HKDF<CryptoPP::LSH512_256>::GetValidDerivedLength(unsigned long) const
Line
Count
Source
94
15
{
95
15
  if (keylength > MaxDerivedKeyLength())
96
4
    return MaxDerivedKeyLength();
97
11
  return keylength;
98
15
}
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::GetValidDerivedLength(unsigned long) const
99
100
template <class T>
101
size_t HKDF<T>::DeriveKey(byte *derived, size_t derivedLen,
102
    const byte *secret, size_t secretLen, const NameValuePairs& params) const
103
0
{
104
0
  CRYPTOPP_ASSERT(secret && secretLen);
105
0
  CRYPTOPP_ASSERT(derived && derivedLen);
106
0
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
107
108
0
  ConstByteArrayParameter p;
109
0
  SecByteBlock salt, info;
110
111
0
  if (params.GetValue("Salt", p))
112
0
    salt.Assign(p.begin(), p.size());
113
0
  else
114
0
    salt.Assign(GetNullVector(), T::DIGESTSIZE);
115
116
0
  if (params.GetValue("Info", p))
117
0
    info.Assign(p.begin(), p.size());
118
0
  else
119
0
    info.Assign(GetNullVector(), 0);
120
121
0
  return DeriveKey(derived, derivedLen, secret, secretLen, salt.begin(), salt.size(), info.begin(), info.size());
122
0
}
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA1>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA224>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA384>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA512>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHAKE128>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHAKE256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD128>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD160>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::RIPEMD320>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Whirlpool>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Weak1::MD2>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Weak1::MD4>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Weak1::MD5>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SM3>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::BLAKE2b>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::BLAKE2s>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Tiger>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH224>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH384>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH512>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::LSH512_256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&) const
123
124
template <class T>
125
size_t HKDF<T>::DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen,
126
    const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const
127
974
{
128
974
  CRYPTOPP_ASSERT(secret && secretLen);
129
974
  CRYPTOPP_ASSERT(derived && derivedLen);
130
974
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
974
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
974
  if (salt == NULLPTR)
136
191
  {
137
191
    salt = GetNullVector();
138
191
    saltLen = T::DIGESTSIZE;
139
191
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
974
  HMAC<T> hmac;
143
974
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
974
  hmac.SetKey(salt, saltLen);
147
974
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
974
  hmac.SetKey(key.begin(), key.size());
151
974
  byte block = 0;
152
153
  // Expand
154
87.8k
  while (derivedLen > 0)
155
86.8k
  {
156
86.8k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
86.8k
    if (infoLen) {hmac.Update(info, infoLen);}
158
86.8k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
86.8k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
86.8k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
86.8k
    std::memcpy(derived, buffer, segmentLen);
168
86.8k
#endif
169
170
86.8k
    derived += segmentLen;
171
86.8k
    derivedLen -= segmentLen;
172
86.8k
  }
173
174
974
  return 1;
175
974
}
CryptoPP::HKDF<CryptoPP::SHA1>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
62
{
128
62
  CRYPTOPP_ASSERT(secret && secretLen);
129
62
  CRYPTOPP_ASSERT(derived && derivedLen);
130
62
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
62
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
62
  if (salt == NULLPTR)
136
22
  {
137
22
    salt = GetNullVector();
138
22
    saltLen = T::DIGESTSIZE;
139
22
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
62
  HMAC<T> hmac;
143
62
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
62
  hmac.SetKey(salt, saltLen);
147
62
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
62
  hmac.SetKey(key.begin(), key.size());
151
62
  byte block = 0;
152
153
  // Expand
154
7.24k
  while (derivedLen > 0)
155
7.17k
  {
156
7.17k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
7.17k
    if (infoLen) {hmac.Update(info, infoLen);}
158
7.17k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
7.17k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
7.17k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
7.17k
    std::memcpy(derived, buffer, segmentLen);
168
7.17k
#endif
169
170
7.17k
    derived += segmentLen;
171
7.17k
    derivedLen -= segmentLen;
172
7.17k
  }
173
174
62
  return 1;
175
62
}
CryptoPP::HKDF<CryptoPP::SHA224>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
30
{
128
30
  CRYPTOPP_ASSERT(secret && secretLen);
129
30
  CRYPTOPP_ASSERT(derived && derivedLen);
130
30
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
30
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
30
  if (salt == NULLPTR)
136
1
  {
137
1
    salt = GetNullVector();
138
1
    saltLen = T::DIGESTSIZE;
139
1
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
30
  HMAC<T> hmac;
143
30
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
30
  hmac.SetKey(salt, saltLen);
147
30
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
30
  hmac.SetKey(key.begin(), key.size());
151
30
  byte block = 0;
152
153
  // Expand
154
2.49k
  while (derivedLen > 0)
155
2.46k
  {
156
2.46k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
2.46k
    if (infoLen) {hmac.Update(info, infoLen);}
158
2.46k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
2.46k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
2.46k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
2.46k
    std::memcpy(derived, buffer, segmentLen);
168
2.46k
#endif
169
170
2.46k
    derived += segmentLen;
171
2.46k
    derivedLen -= segmentLen;
172
2.46k
  }
173
174
30
  return 1;
175
30
}
CryptoPP::HKDF<CryptoPP::SHA384>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
43
{
128
43
  CRYPTOPP_ASSERT(secret && secretLen);
129
43
  CRYPTOPP_ASSERT(derived && derivedLen);
130
43
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
43
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
43
  if (salt == NULLPTR)
136
5
  {
137
5
    salt = GetNullVector();
138
5
    saltLen = T::DIGESTSIZE;
139
5
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
43
  HMAC<T> hmac;
143
43
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
43
  hmac.SetKey(salt, saltLen);
147
43
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
43
  hmac.SetKey(key.begin(), key.size());
151
43
  byte block = 0;
152
153
  // Expand
154
3.70k
  while (derivedLen > 0)
155
3.66k
  {
156
3.66k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
3.66k
    if (infoLen) {hmac.Update(info, infoLen);}
158
3.66k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
3.66k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
3.66k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
3.66k
    std::memcpy(derived, buffer, segmentLen);
168
3.66k
#endif
169
170
3.66k
    derived += segmentLen;
171
3.66k
    derivedLen -= segmentLen;
172
3.66k
  }
173
174
43
  return 1;
175
43
}
CryptoPP::HKDF<CryptoPP::SHA512>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
54
{
128
54
  CRYPTOPP_ASSERT(secret && secretLen);
129
54
  CRYPTOPP_ASSERT(derived && derivedLen);
130
54
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
54
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
54
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
54
  HMAC<T> hmac;
143
54
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
54
  hmac.SetKey(salt, saltLen);
147
54
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
54
  hmac.SetKey(key.begin(), key.size());
151
54
  byte block = 0;
152
153
  // Expand
154
5.70k
  while (derivedLen > 0)
155
5.64k
  {
156
5.64k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
5.64k
    if (infoLen) {hmac.Update(info, infoLen);}
158
5.64k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
5.64k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
5.64k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
5.64k
    std::memcpy(derived, buffer, segmentLen);
168
5.64k
#endif
169
170
5.64k
    derived += segmentLen;
171
5.64k
    derivedLen -= segmentLen;
172
5.64k
  }
173
174
54
  return 1;
175
54
}
CryptoPP::HKDF<CryptoPP::SHAKE128>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
59
{
128
59
  CRYPTOPP_ASSERT(secret && secretLen);
129
59
  CRYPTOPP_ASSERT(derived && derivedLen);
130
59
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
59
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
59
  if (salt == NULLPTR)
136
24
  {
137
24
    salt = GetNullVector();
138
24
    saltLen = T::DIGESTSIZE;
139
24
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
59
  HMAC<T> hmac;
143
59
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
59
  hmac.SetKey(salt, saltLen);
147
59
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
59
  hmac.SetKey(key.begin(), key.size());
151
59
  byte block = 0;
152
153
  // Expand
154
1.87k
  while (derivedLen > 0)
155
1.81k
  {
156
1.81k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.81k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.81k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.81k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.81k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.81k
    std::memcpy(derived, buffer, segmentLen);
168
1.81k
#endif
169
170
1.81k
    derived += segmentLen;
171
1.81k
    derivedLen -= segmentLen;
172
1.81k
  }
173
174
59
  return 1;
175
59
}
CryptoPP::HKDF<CryptoPP::SHAKE256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
53
{
128
53
  CRYPTOPP_ASSERT(secret && secretLen);
129
53
  CRYPTOPP_ASSERT(derived && derivedLen);
130
53
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
53
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
53
  if (salt == NULLPTR)
136
25
  {
137
25
    salt = GetNullVector();
138
25
    saltLen = T::DIGESTSIZE;
139
25
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
53
  HMAC<T> hmac;
143
53
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
53
  hmac.SetKey(salt, saltLen);
147
53
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
53
  hmac.SetKey(key.begin(), key.size());
151
53
  byte block = 0;
152
153
  // Expand
154
6.84k
  while (derivedLen > 0)
155
6.79k
  {
156
6.79k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
6.79k
    if (infoLen) {hmac.Update(info, infoLen);}
158
6.79k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
6.79k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
6.79k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
6.79k
    std::memcpy(derived, buffer, segmentLen);
168
6.79k
#endif
169
170
6.79k
    derived += segmentLen;
171
6.79k
    derivedLen -= segmentLen;
172
6.79k
  }
173
174
53
  return 1;
175
53
}
CryptoPP::HKDF<CryptoPP::RIPEMD128>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
20
{
128
20
  CRYPTOPP_ASSERT(secret && secretLen);
129
20
  CRYPTOPP_ASSERT(derived && derivedLen);
130
20
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
20
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
20
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
20
  HMAC<T> hmac;
143
20
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
20
  hmac.SetKey(salt, saltLen);
147
20
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
20
  hmac.SetKey(key.begin(), key.size());
151
20
  byte block = 0;
152
153
  // Expand
154
1.16k
  while (derivedLen > 0)
155
1.14k
  {
156
1.14k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.14k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.14k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.14k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.14k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.14k
    std::memcpy(derived, buffer, segmentLen);
168
1.14k
#endif
169
170
1.14k
    derived += segmentLen;
171
1.14k
    derivedLen -= segmentLen;
172
1.14k
  }
173
174
20
  return 1;
175
20
}
CryptoPP::HKDF<CryptoPP::RIPEMD160>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
34
{
128
34
  CRYPTOPP_ASSERT(secret && secretLen);
129
34
  CRYPTOPP_ASSERT(derived && derivedLen);
130
34
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
34
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
34
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
34
  HMAC<T> hmac;
143
34
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
34
  hmac.SetKey(salt, saltLen);
147
34
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
34
  hmac.SetKey(key.begin(), key.size());
151
34
  byte block = 0;
152
153
  // Expand
154
3.11k
  while (derivedLen > 0)
155
3.07k
  {
156
3.07k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
3.07k
    if (infoLen) {hmac.Update(info, infoLen);}
158
3.07k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
3.07k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
3.07k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
3.07k
    std::memcpy(derived, buffer, segmentLen);
168
3.07k
#endif
169
170
3.07k
    derived += segmentLen;
171
3.07k
    derivedLen -= segmentLen;
172
3.07k
  }
173
174
34
  return 1;
175
34
}
CryptoPP::HKDF<CryptoPP::RIPEMD256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
26
{
128
26
  CRYPTOPP_ASSERT(secret && secretLen);
129
26
  CRYPTOPP_ASSERT(derived && derivedLen);
130
26
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
26
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
26
  if (salt == NULLPTR)
136
3
  {
137
3
    salt = GetNullVector();
138
3
    saltLen = T::DIGESTSIZE;
139
3
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
26
  HMAC<T> hmac;
143
26
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
26
  hmac.SetKey(salt, saltLen);
147
26
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
26
  hmac.SetKey(key.begin(), key.size());
151
26
  byte block = 0;
152
153
  // Expand
154
3.06k
  while (derivedLen > 0)
155
3.03k
  {
156
3.03k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
3.03k
    if (infoLen) {hmac.Update(info, infoLen);}
158
3.03k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
3.03k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
3.03k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
3.03k
    std::memcpy(derived, buffer, segmentLen);
168
3.03k
#endif
169
170
3.03k
    derived += segmentLen;
171
3.03k
    derivedLen -= segmentLen;
172
3.03k
  }
173
174
26
  return 1;
175
26
}
CryptoPP::HKDF<CryptoPP::RIPEMD320>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
37
{
128
37
  CRYPTOPP_ASSERT(secret && secretLen);
129
37
  CRYPTOPP_ASSERT(derived && derivedLen);
130
37
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
37
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
37
  if (salt == NULLPTR)
136
9
  {
137
9
    salt = GetNullVector();
138
9
    saltLen = T::DIGESTSIZE;
139
9
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
37
  HMAC<T> hmac;
143
37
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
37
  hmac.SetKey(salt, saltLen);
147
37
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
37
  hmac.SetKey(key.begin(), key.size());
151
37
  byte block = 0;
152
153
  // Expand
154
2.65k
  while (derivedLen > 0)
155
2.61k
  {
156
2.61k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
2.61k
    if (infoLen) {hmac.Update(info, infoLen);}
158
2.61k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
2.61k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
2.61k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
2.61k
    std::memcpy(derived, buffer, segmentLen);
168
2.61k
#endif
169
170
2.61k
    derived += segmentLen;
171
2.61k
    derivedLen -= segmentLen;
172
2.61k
  }
173
174
37
  return 1;
175
37
}
CryptoPP::HKDF<CryptoPP::Whirlpool>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
101
{
128
101
  CRYPTOPP_ASSERT(secret && secretLen);
129
101
  CRYPTOPP_ASSERT(derived && derivedLen);
130
101
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
101
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
101
  if (salt == NULLPTR)
136
32
  {
137
32
    salt = GetNullVector();
138
32
    saltLen = T::DIGESTSIZE;
139
32
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
101
  HMAC<T> hmac;
143
101
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
101
  hmac.SetKey(salt, saltLen);
147
101
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
101
  hmac.SetKey(key.begin(), key.size());
151
101
  byte block = 0;
152
153
  // Expand
154
6.59k
  while (derivedLen > 0)
155
6.48k
  {
156
6.48k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
6.48k
    if (infoLen) {hmac.Update(info, infoLen);}
158
6.48k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
6.48k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
6.48k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
6.48k
    std::memcpy(derived, buffer, segmentLen);
168
6.48k
#endif
169
170
6.48k
    derived += segmentLen;
171
6.48k
    derivedLen -= segmentLen;
172
6.48k
  }
173
174
101
  return 1;
175
101
}
CryptoPP::HKDF<CryptoPP::Weak1::MD2>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
24
{
128
24
  CRYPTOPP_ASSERT(secret && secretLen);
129
24
  CRYPTOPP_ASSERT(derived && derivedLen);
130
24
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
24
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
24
  if (salt == NULLPTR)
136
2
  {
137
2
    salt = GetNullVector();
138
2
    saltLen = T::DIGESTSIZE;
139
2
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
24
  HMAC<T> hmac;
143
24
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
24
  hmac.SetKey(salt, saltLen);
147
24
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
24
  hmac.SetKey(key.begin(), key.size());
151
24
  byte block = 0;
152
153
  // Expand
154
1.89k
  while (derivedLen > 0)
155
1.86k
  {
156
1.86k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.86k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.86k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.86k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.86k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.86k
    std::memcpy(derived, buffer, segmentLen);
168
1.86k
#endif
169
170
1.86k
    derived += segmentLen;
171
1.86k
    derivedLen -= segmentLen;
172
1.86k
  }
173
174
24
  return 1;
175
24
}
CryptoPP::HKDF<CryptoPP::Weak1::MD4>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
26
{
128
26
  CRYPTOPP_ASSERT(secret && secretLen);
129
26
  CRYPTOPP_ASSERT(derived && derivedLen);
130
26
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
26
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
26
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
26
  HMAC<T> hmac;
143
26
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
26
  hmac.SetKey(salt, saltLen);
147
26
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
26
  hmac.SetKey(key.begin(), key.size());
151
26
  byte block = 0;
152
153
  // Expand
154
1.55k
  while (derivedLen > 0)
155
1.53k
  {
156
1.53k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.53k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.53k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.53k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.53k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.53k
    std::memcpy(derived, buffer, segmentLen);
168
1.53k
#endif
169
170
1.53k
    derived += segmentLen;
171
1.53k
    derivedLen -= segmentLen;
172
1.53k
  }
173
174
26
  return 1;
175
26
}
CryptoPP::HKDF<CryptoPP::Weak1::MD5>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
32
{
128
32
  CRYPTOPP_ASSERT(secret && secretLen);
129
32
  CRYPTOPP_ASSERT(derived && derivedLen);
130
32
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
32
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
32
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
32
  HMAC<T> hmac;
143
32
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
32
  hmac.SetKey(salt, saltLen);
147
32
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
32
  hmac.SetKey(key.begin(), key.size());
151
32
  byte block = 0;
152
153
  // Expand
154
1.61k
  while (derivedLen > 0)
155
1.57k
  {
156
1.57k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.57k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.57k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.57k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.57k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.57k
    std::memcpy(derived, buffer, segmentLen);
168
1.57k
#endif
169
170
1.57k
    derived += segmentLen;
171
1.57k
    derivedLen -= segmentLen;
172
1.57k
  }
173
174
32
  return 1;
175
32
}
CryptoPP::HKDF<CryptoPP::SM3>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
34
{
128
34
  CRYPTOPP_ASSERT(secret && secretLen);
129
34
  CRYPTOPP_ASSERT(derived && derivedLen);
130
34
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
34
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
34
  if (salt == NULLPTR)
136
3
  {
137
3
    salt = GetNullVector();
138
3
    saltLen = T::DIGESTSIZE;
139
3
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
34
  HMAC<T> hmac;
143
34
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
34
  hmac.SetKey(salt, saltLen);
147
34
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
34
  hmac.SetKey(key.begin(), key.size());
151
34
  byte block = 0;
152
153
  // Expand
154
3.43k
  while (derivedLen > 0)
155
3.39k
  {
156
3.39k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
3.39k
    if (infoLen) {hmac.Update(info, infoLen);}
158
3.39k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
3.39k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
3.39k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
3.39k
    std::memcpy(derived, buffer, segmentLen);
168
3.39k
#endif
169
170
3.39k
    derived += segmentLen;
171
3.39k
    derivedLen -= segmentLen;
172
3.39k
  }
173
174
34
  return 1;
175
34
}
CryptoPP::HKDF<CryptoPP::BLAKE2b>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
27
{
128
27
  CRYPTOPP_ASSERT(secret && secretLen);
129
27
  CRYPTOPP_ASSERT(derived && derivedLen);
130
27
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
27
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
27
  if (salt == NULLPTR)
136
1
  {
137
1
    salt = GetNullVector();
138
1
    saltLen = T::DIGESTSIZE;
139
1
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
27
  HMAC<T> hmac;
143
27
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
27
  hmac.SetKey(salt, saltLen);
147
27
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
27
  hmac.SetKey(key.begin(), key.size());
151
27
  byte block = 0;
152
153
  // Expand
154
2.91k
  while (derivedLen > 0)
155
2.88k
  {
156
2.88k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
2.88k
    if (infoLen) {hmac.Update(info, infoLen);}
158
2.88k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
2.88k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
2.88k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
2.88k
    std::memcpy(derived, buffer, segmentLen);
168
2.88k
#endif
169
170
2.88k
    derived += segmentLen;
171
2.88k
    derivedLen -= segmentLen;
172
2.88k
  }
173
174
27
  return 1;
175
27
}
CryptoPP::HKDF<CryptoPP::BLAKE2s>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
61
{
128
61
  CRYPTOPP_ASSERT(secret && secretLen);
129
61
  CRYPTOPP_ASSERT(derived && derivedLen);
130
61
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
61
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
61
  if (salt == NULLPTR)
136
8
  {
137
8
    salt = GetNullVector();
138
8
    saltLen = T::DIGESTSIZE;
139
8
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
61
  HMAC<T> hmac;
143
61
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
61
  hmac.SetKey(salt, saltLen);
147
61
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
61
  hmac.SetKey(key.begin(), key.size());
151
61
  byte block = 0;
152
153
  // Expand
154
7.49k
  while (derivedLen > 0)
155
7.43k
  {
156
7.43k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
7.43k
    if (infoLen) {hmac.Update(info, infoLen);}
158
7.43k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
7.43k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
7.43k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
7.43k
    std::memcpy(derived, buffer, segmentLen);
168
7.43k
#endif
169
170
7.43k
    derived += segmentLen;
171
7.43k
    derivedLen -= segmentLen;
172
7.43k
  }
173
174
61
  return 1;
175
61
}
CryptoPP::HKDF<CryptoPP::Tiger>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
20
{
128
20
  CRYPTOPP_ASSERT(secret && secretLen);
129
20
  CRYPTOPP_ASSERT(derived && derivedLen);
130
20
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
20
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
20
  if (salt == NULLPTR)
136
1
  {
137
1
    salt = GetNullVector();
138
1
    saltLen = T::DIGESTSIZE;
139
1
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
20
  HMAC<T> hmac;
143
20
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
20
  hmac.SetKey(salt, saltLen);
147
20
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
20
  hmac.SetKey(key.begin(), key.size());
151
20
  byte block = 0;
152
153
  // Expand
154
1.72k
  while (derivedLen > 0)
155
1.70k
  {
156
1.70k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.70k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.70k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.70k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.70k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.70k
    std::memcpy(derived, buffer, segmentLen);
168
1.70k
#endif
169
170
1.70k
    derived += segmentLen;
171
1.70k
    derivedLen -= segmentLen;
172
1.70k
  }
173
174
20
  return 1;
175
20
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<28u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
17
{
128
17
  CRYPTOPP_ASSERT(secret && secretLen);
129
17
  CRYPTOPP_ASSERT(derived && derivedLen);
130
17
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
17
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
17
  if (salt == NULLPTR)
136
4
  {
137
4
    salt = GetNullVector();
138
4
    saltLen = T::DIGESTSIZE;
139
4
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
17
  HMAC<T> hmac;
143
17
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
17
  hmac.SetKey(salt, saltLen);
147
17
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
17
  hmac.SetKey(key.begin(), key.size());
151
17
  byte block = 0;
152
153
  // Expand
154
1.36k
  while (derivedLen > 0)
155
1.34k
  {
156
1.34k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.34k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.34k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.34k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.34k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.34k
    std::memcpy(derived, buffer, segmentLen);
168
1.34k
#endif
169
170
1.34k
    derived += segmentLen;
171
1.34k
    derivedLen -= segmentLen;
172
1.34k
  }
173
174
17
  return 1;
175
17
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<32u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
19
{
128
19
  CRYPTOPP_ASSERT(secret && secretLen);
129
19
  CRYPTOPP_ASSERT(derived && derivedLen);
130
19
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
19
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
19
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
19
  HMAC<T> hmac;
143
19
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
19
  hmac.SetKey(salt, saltLen);
147
19
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
19
  hmac.SetKey(key.begin(), key.size());
151
19
  byte block = 0;
152
153
  // Expand
154
1.68k
  while (derivedLen > 0)
155
1.66k
  {
156
1.66k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.66k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.66k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.66k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.66k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.66k
    std::memcpy(derived, buffer, segmentLen);
168
1.66k
#endif
169
170
1.66k
    derived += segmentLen;
171
1.66k
    derivedLen -= segmentLen;
172
1.66k
  }
173
174
19
  return 1;
175
19
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<48u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
28
{
128
28
  CRYPTOPP_ASSERT(secret && secretLen);
129
28
  CRYPTOPP_ASSERT(derived && derivedLen);
130
28
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
28
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
28
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
28
  HMAC<T> hmac;
143
28
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
28
  hmac.SetKey(salt, saltLen);
147
28
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
28
  hmac.SetKey(key.begin(), key.size());
151
28
  byte block = 0;
152
153
  // Expand
154
3.41k
  while (derivedLen > 0)
155
3.38k
  {
156
3.38k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
3.38k
    if (infoLen) {hmac.Update(info, infoLen);}
158
3.38k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
3.38k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
3.38k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
3.38k
    std::memcpy(derived, buffer, segmentLen);
168
3.38k
#endif
169
170
3.38k
    derived += segmentLen;
171
3.38k
    derivedLen -= segmentLen;
172
3.38k
  }
173
174
28
  return 1;
175
28
}
CryptoPP::HKDF<CryptoPP::Keccak_Final<64u> >::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
69
{
128
69
  CRYPTOPP_ASSERT(secret && secretLen);
129
69
  CRYPTOPP_ASSERT(derived && derivedLen);
130
69
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
69
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
69
  if (salt == NULLPTR)
136
50
  {
137
50
    salt = GetNullVector();
138
50
    saltLen = T::DIGESTSIZE;
139
50
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
69
  HMAC<T> hmac;
143
69
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
69
  hmac.SetKey(salt, saltLen);
147
69
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
69
  hmac.SetKey(key.begin(), key.size());
151
69
  byte block = 0;
152
153
  // Expand
154
8.95k
  while (derivedLen > 0)
155
8.88k
  {
156
8.88k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
8.88k
    if (infoLen) {hmac.Update(info, infoLen);}
158
8.88k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
8.88k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
8.88k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
8.88k
    std::memcpy(derived, buffer, segmentLen);
168
8.88k
#endif
169
170
8.88k
    derived += segmentLen;
171
8.88k
    derivedLen -= segmentLen;
172
8.88k
  }
173
174
69
  return 1;
175
69
}
CryptoPP::HKDF<CryptoPP::LSH224>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
19
{
128
19
  CRYPTOPP_ASSERT(secret && secretLen);
129
19
  CRYPTOPP_ASSERT(derived && derivedLen);
130
19
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
19
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
19
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
19
  HMAC<T> hmac;
143
19
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
19
  hmac.SetKey(salt, saltLen);
147
19
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
19
  hmac.SetKey(key.begin(), key.size());
151
19
  byte block = 0;
152
153
  // Expand
154
1.20k
  while (derivedLen > 0)
155
1.18k
  {
156
1.18k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.18k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.18k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.18k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.18k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.18k
    std::memcpy(derived, buffer, segmentLen);
168
1.18k
#endif
169
170
1.18k
    derived += segmentLen;
171
1.18k
    derivedLen -= segmentLen;
172
1.18k
  }
173
174
19
  return 1;
175
19
}
CryptoPP::HKDF<CryptoPP::LSH256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
21
{
128
21
  CRYPTOPP_ASSERT(secret && secretLen);
129
21
  CRYPTOPP_ASSERT(derived && derivedLen);
130
21
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
21
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
21
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
21
  HMAC<T> hmac;
143
21
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
21
  hmac.SetKey(salt, saltLen);
147
21
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
21
  hmac.SetKey(key.begin(), key.size());
151
21
  byte block = 0;
152
153
  // Expand
154
1.53k
  while (derivedLen > 0)
155
1.51k
  {
156
1.51k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.51k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.51k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.51k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.51k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.51k
    std::memcpy(derived, buffer, segmentLen);
168
1.51k
#endif
169
170
1.51k
    derived += segmentLen;
171
1.51k
    derivedLen -= segmentLen;
172
1.51k
  }
173
174
21
  return 1;
175
21
}
CryptoPP::HKDF<CryptoPP::LSH384>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
24
{
128
24
  CRYPTOPP_ASSERT(secret && secretLen);
129
24
  CRYPTOPP_ASSERT(derived && derivedLen);
130
24
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
24
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
24
  if (salt == NULLPTR)
136
1
  {
137
1
    salt = GetNullVector();
138
1
    saltLen = T::DIGESTSIZE;
139
1
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
24
  HMAC<T> hmac;
143
24
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
24
  hmac.SetKey(salt, saltLen);
147
24
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
24
  hmac.SetKey(key.begin(), key.size());
151
24
  byte block = 0;
152
153
  // Expand
154
1.89k
  while (derivedLen > 0)
155
1.86k
  {
156
1.86k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.86k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.86k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.86k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.86k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.86k
    std::memcpy(derived, buffer, segmentLen);
168
1.86k
#endif
169
170
1.86k
    derived += segmentLen;
171
1.86k
    derivedLen -= segmentLen;
172
1.86k
  }
173
174
24
  return 1;
175
24
}
CryptoPP::HKDF<CryptoPP::LSH512>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
19
{
128
19
  CRYPTOPP_ASSERT(secret && secretLen);
129
19
  CRYPTOPP_ASSERT(derived && derivedLen);
130
19
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
19
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
19
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
19
  HMAC<T> hmac;
143
19
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
19
  hmac.SetKey(salt, saltLen);
147
19
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
19
  hmac.SetKey(key.begin(), key.size());
151
19
  byte block = 0;
152
153
  // Expand
154
1.79k
  while (derivedLen > 0)
155
1.77k
  {
156
1.77k
    if (block++) {hmac.Update(buffer, buffer.size());}
157
1.77k
    if (infoLen) {hmac.Update(info, infoLen);}
158
1.77k
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
1.77k
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
1.77k
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
1.77k
    std::memcpy(derived, buffer, segmentLen);
168
1.77k
#endif
169
170
1.77k
    derived += segmentLen;
171
1.77k
    derivedLen -= segmentLen;
172
1.77k
  }
173
174
19
  return 1;
175
19
}
CryptoPP::HKDF<CryptoPP::LSH512_256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
Line
Count
Source
127
15
{
128
15
  CRYPTOPP_ASSERT(secret && secretLen);
129
15
  CRYPTOPP_ASSERT(derived && derivedLen);
130
15
  CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength());
131
132
15
  ThrowIfInvalidDerivedKeyLength(derivedLen);
133
134
  // HKDF business logic. NULL is different than empty.
135
15
  if (salt == NULLPTR)
136
0
  {
137
0
    salt = GetNullVector();
138
0
    saltLen = T::DIGESTSIZE;
139
0
  }
140
141
  // key is PRK from the RFC, salt is IKM from the RFC
142
15
  HMAC<T> hmac;
143
15
  SecByteBlock key(T::DIGESTSIZE), buffer(T::DIGESTSIZE);
144
145
  // Extract
146
15
  hmac.SetKey(salt, saltLen);
147
15
  hmac.CalculateDigest(key, secret, secretLen);
148
149
  // Key
150
15
  hmac.SetKey(key.begin(), key.size());
151
15
  byte block = 0;
152
153
  // Expand
154
940
  while (derivedLen > 0)
155
925
  {
156
925
    if (block++) {hmac.Update(buffer, buffer.size());}
157
925
    if (infoLen) {hmac.Update(info, infoLen);}
158
925
    hmac.CalculateDigest(buffer, &block, 1);
159
160
#if CRYPTOPP_MSC_VERSION
161
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
162
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
163
    memcpy_s(derived, segmentLen, buffer, segmentLen);
164
#else
165
925
    const size_t digestSize = static_cast<size_t>(T::DIGESTSIZE);
166
925
    const size_t segmentLen = STDMIN(derivedLen, digestSize);
167
925
    std::memcpy(derived, buffer, segmentLen);
168
925
#endif
169
170
925
    derived += segmentLen;
171
925
    derivedLen -= segmentLen;
172
925
  }
173
174
15
  return 1;
175
15
}
Unexecuted instantiation: CryptoPP::HKDF<CryptoPP::SHA256>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long) const
176
177
NAMESPACE_END
178
179
#endif // CRYPTOPP_HKDF_H