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

randombit / botan / 13210394651

08 Feb 2025 12:33AM UTC coverage: 91.656% (-0.006%) from 91.662%
13210394651

push

github

web-flow
Merge pull request #4642 from randombit/jack/target-info-header

Add internal target_info.h header

94837 of 103471 relevant lines covered (91.66%)

11243945.63 hits per line

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

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

7
#include "fuzzers.h"
8

9
#include <botan/numthry.h>
10

11
namespace {
12

13
Botan::BigInt ref_gcd(Botan::BigInt a, Botan::BigInt b) {
257✔
14
   Botan::BigInt t;
257✔
15
   while(b != 0) {
513✔
16
      t = a % b;
256✔
17
      t.swap(b);
256✔
18
      t.swap(a);
256✔
19
   }
20
   return a;
257✔
21
}
257✔
22

23
}  // namespace
24

25
void fuzz(std::span<const uint8_t> in) {
1,000✔
26
   static const size_t max_bits = 4096;
1,000✔
27

28
   if(2 * in.size() * 8 > max_bits) {
1,000✔
29
      return;
743✔
30
   }
31

32
   const Botan::BigInt x = Botan::BigInt::from_bytes(in.subspan(in.size() / 2));
257✔
33
   const Botan::BigInt y = Botan::BigInt::from_bytes(in.subspan(in.size() / 2, in.size() - (in.size() / 2)));
257✔
34

35
   const Botan::BigInt ref = ref_gcd(x, y);
257✔
36
   const Botan::BigInt lib = Botan::gcd(x, y);
257✔
37

38
   if(ref != lib) {
257✔
39
      FUZZER_WRITE_AND_CRASH("X = " << x.to_hex_string() << "\n"
×
40
                                    << "Y = " << y.to_hex_string() << "\n"
41
                                    << "L = " << lib.to_hex_string() << "\n"
42
                                    << "R = " << ref.to_hex_string() << "\n");
43
   }
44
}
257✔
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