• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5111374265

29 May 2023 11:19AM UTC coverage: 92.227% (+0.5%) from 91.723%
5111374265

push

github

randombit
Next release will be 3.1.0. Update release notes

75588 of 81959 relevant lines covered (92.23%)

11886470.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/lib/kdf/kdf1/kdf1.cpp
1
/*
2
* KDF1
3
* (C) 1999-2007 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/internal/kdf1.h>
9

10
#include <botan/exceptn.h>
11
#include <botan/internal/fmt.h>
12

13
namespace Botan {
14

15
std::string KDF1::name() const { return fmt("KDF1({})", m_hash->name()); }
18✔
16

17
std::unique_ptr<KDF> KDF1::new_object() const { return std::make_unique<KDF1>(m_hash->new_object()); }
6✔
18

19
void KDF1::kdf(uint8_t key[],
18✔
20
               size_t key_len,
21
               const uint8_t secret[],
22
               size_t secret_len,
23
               const uint8_t salt[],
24
               size_t salt_len,
25
               const uint8_t label[],
26
               size_t label_len) const {
27
   if(key_len == 0)
18✔
28
      return;
29

30
   if(key_len > m_hash->output_length())
18✔
31
      throw Invalid_Argument("KDF1 maximum output length exceeeded");
×
32

33
   m_hash->update(secret, secret_len);
18✔
34
   m_hash->update(label, label_len);
18✔
35
   m_hash->update(salt, salt_len);
18✔
36

37
   if(key_len == m_hash->output_length()) {
18✔
38
      // In this case we can hash directly into the output buffer
39
      m_hash->final(key);
18✔
40
   } else {
41
      // Otherwise a copy is required
42
      secure_vector<uint8_t> v = m_hash->final();
1✔
43
      copy_mem(key, v.data(), key_len);
1✔
44
   }
1✔
45
}
46

47
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc