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

randombit / botan / 17116681101

21 Aug 2025 03:48AM UTC coverage: 90.663% (+0.01%) from 90.652%
17116681101

push

github

web-flow
Merge pull request #5061 from reneme/feature/ascon_hash256

100197 of 110516 relevant lines covered (90.66%)

12326281.62 hits per line

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

93.75
/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
#if defined(BOTAN_HAS_ASCON_XOF128)
19
   #include <botan/internal/ascon_xof128.h>
20
#endif
21

22
#include <botan/exceptn.h>
23
#include <botan/internal/fmt.h>
24

25
namespace Botan {
26

27
//static
28
std::unique_ptr<XOF> XOF::create(std::string_view algo_spec, std::string_view provider) {
6,859✔
29
   const SCAN_Name req(algo_spec);
6,859✔
30

31
   if(!provider.empty() && provider != "base") {
7,433✔
32
      return nullptr;  // unknown provider
×
33
   }
34

35
#if defined(BOTAN_HAS_SHAKE_XOF)
36
   if(req.algo_name() == "SHAKE-128" && req.arg_count() == 0) {
6,859✔
37
      return std::make_unique<SHAKE_128_XOF>();
2,491✔
38
   }
39
   if(req.algo_name() == "SHAKE-256" && req.arg_count() == 0) {
4,368✔
40
      return std::make_unique<SHAKE_256_XOF>();
4,148✔
41
   }
42
#endif
43

44
#if defined(BOTAN_HAS_ASCON_XOF128)
45
   if(req.algo_name() == "Ascon-XOF128" && req.arg_count() == 0) {
220✔
46
      return std::make_unique<Ascon_XOF128>();
212✔
47
   }
48
#endif
49

50
   return nullptr;
8✔
51
}
6,859✔
52

53
//static
54
std::unique_ptr<XOF> XOF::create_or_throw(std::string_view algo_spec, std::string_view provider) {
6,285✔
55
   if(auto xof = XOF::create(algo_spec, provider)) {
6,285✔
56
      return xof;
6,285✔
57
   }
6,285✔
58
   throw Lookup_Error("XOF", algo_spec, provider);
×
59
}
60

61
// static
62
std::vector<std::string> XOF::providers(std::string_view algo_spec) {
291✔
63
   return probe_providers_of<XOF>(algo_spec, {"base"});
291✔
64
}
65

66
std::string XOF::provider() const {
27✔
67
   return "base";
27✔
68
}
69

70
void XOF::start(std::span<const uint8_t> salt, std::span<const uint8_t> key) {
808,566✔
71
   if(!key_spec().valid_keylength(key.size())) {
808,566✔
72
      throw Invalid_Key_Length(name(), key.size());
4✔
73
   }
74

75
   if(!valid_salt_length(salt.size())) {
808,564✔
76
      throw Invalid_Argument(fmt("{} cannot accept a salt length of {}", name(), salt.size()));
6✔
77
   }
78

79
   m_xof_started = true;
808,561✔
80
   start_msg(salt, key);
808,561✔
81
}
808,561✔
82

83
void XOF::start_msg(std::span<const uint8_t> salt, std::span<const uint8_t> key) {
714,234✔
84
   BOTAN_UNUSED(salt, key);
714,234✔
85
}
714,234✔
86

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