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

randombit / botan / 13262741994

11 Feb 2025 12:19PM UTC coverage: 91.656% (-0.003%) from 91.659%
13262741994

Pull #4647

github

web-flow
Merge 0b8e56724 into f372b5a9e
Pull Request #4647: Avoid using mem_ops.h or assert.h in public headers

94864 of 103500 relevant lines covered (91.66%)

11330304.66 hits per line

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

93.33
/src/lib/xof/xof.cpp
1
/*
2
* Extendable Output Function Base Class
3
* (C) 2023 Jack Lloyd
4
*     2023 Fabian Albert, René Meusel - Rohde & Schwarz Cybersecurity
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8

9
#include <botan/xof.h>
10

11
#include <botan/assert.h>
12
#include <botan/internal/scan_name.h>
13

14
#if defined(BOTAN_HAS_SHAKE_XOF)
15
   #include <botan/internal/shake_xof.h>
16
#endif
17

18
#include <botan/exceptn.h>
19
#include <botan/internal/fmt.h>
20

21
namespace Botan {
22

23
//static
24
std::unique_ptr<XOF> XOF::create(std::string_view algo_spec, std::string_view provider) {
6,579✔
25
   const SCAN_Name req(algo_spec);
6,579✔
26

27
   if(!provider.empty() && provider != "base") {
6,941✔
28
      return nullptr;  // unknown provider
×
29
   }
30

31
#if defined(BOTAN_HAS_SHAKE_XOF)
32
   if(req.algo_name() == "SHAKE-128" && req.arg_count() == 0) {
6,579✔
33
      return std::make_unique<SHAKE_128_XOF>();
2,459✔
34
   }
35
   if(req.algo_name() == "SHAKE-256" && req.arg_count() == 0) {
4,120✔
36
      return std::make_unique<SHAKE_256_XOF>();
4,112✔
37
   }
38
#endif
39

40
   return nullptr;
8✔
41
}
6,579✔
42

43
//static
44
std::unique_ptr<XOF> XOF::create_or_throw(std::string_view algo_spec, std::string_view provider) {
6,217✔
45
   if(auto xof = XOF::create(algo_spec, provider)) {
6,217✔
46
      return xof;
6,217✔
47
   }
6,217✔
48
   throw Lookup_Error("XOF", algo_spec, provider);
×
49
}
50

51
// static
52
std::vector<std::string> XOF::providers(std::string_view algo_spec) {
185✔
53
   return probe_providers_of<XOF>(algo_spec, {"base"});
185✔
54
}
55

56
std::string XOF::provider() const {
27✔
57
   return "base";
27✔
58
}
59

60
void XOF::start(std::span<const uint8_t> salt, std::span<const uint8_t> key) {
808,669✔
61
   if(!key_spec().valid_keylength(key.size())) {
808,669✔
62
      throw Invalid_Key_Length(name(), key.size());
4✔
63
   }
64

65
   if(!valid_salt_length(salt.size())) {
808,667✔
66
      throw Invalid_Argument(fmt("{} cannot accept a salt length of {}", name(), salt.size()));
6✔
67
   }
68

69
   m_xof_started = true;
808,664✔
70
   start_msg(salt, key);
808,664✔
71
}
808,664✔
72

73
void XOF::start_msg(std::span<const uint8_t> salt, std::span<const uint8_t> key) {
713,995✔
74
   BOTAN_UNUSED(salt, key);
713,995✔
75
}
713,995✔
76

77
}  // 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

© 2026 Coveralls, Inc