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

randombit / botan / 13200135613

07 Feb 2025 12:46PM UTC coverage: 91.265% (-0.009%) from 91.274%
13200135613

Pull #4642

github

web-flow
Merge 99ef28faf into 63d09d92d
Pull Request #4642: Add internal target_info.h header

94433 of 103471 relevant lines covered (91.27%)

11254908.78 hits per line

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

93.75
/src/fuzzer/mp_redc_crandall.cpp
1
/*
2
* (C) 2024 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "mp_fuzzers.h"
8

9
#include <botan/bigint.h>
10
#include <botan/internal/loadstor.h>
11

12
namespace {
13

14
consteval word crandall_C() {
15
   if(sizeof(word) == 8) {
16
      // secp256k1 modulus
17
      return static_cast<word>(0x1000003d1);
18
   } else {
19
      // 128 bit prime with largest possible C
20
      return 0xffffffe1;
21
   }
22
}
23

24
}  // namespace
25

26
void fuzz(std::span<const uint8_t> in) {
1,000✔
27
   if(in.size() != 8 * sizeof(word)) {
1,000✔
28
      return;
999✔
29
   }
30

31
   constexpr word C = crandall_C();
1✔
32

33
   static const Botan::BigInt refp = Botan::BigInt::power_of_2(4 * 8 * sizeof(C)) - C;
2✔
34
   static const Botan::BigInt refp2 = refp * refp;
1✔
35

36
   const auto refz = Botan::BigInt::from_bytes(in);
1✔
37

38
   if(refz >= refp2) {
1✔
39
      return;
×
40
   }
41

42
   const auto refc = refz % refp;
1✔
43

44
   std::array<word, 8> z = {};
1✔
45
   for(size_t i = 0; i != 8; ++i) {
9✔
46
      z[7 - i] = Botan::load_be<word>(in.subspan(sizeof(word) * i, sizeof(word)));
8✔
47
   }
48

49
   const auto rc = Botan::redc_crandall<word, 4, C>(z);
1✔
50

51
   compare_word_vec(rc.data(), 4, refc._data(), refc.sig_words(), "Crandall reduction");
2✔
52
}
1✔
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