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

randombit / botan / 22767334863

06 Mar 2026 02:18PM UTC coverage: 90.267% (-1.6%) from 91.906%
22767334863

Pull #5417

github

web-flow
Merge d2806a100 into ebae7cd2e
Pull Request #5417: Add PKCS#12 support

104563 of 115837 relevant lines covered (90.27%)

11526821.13 hits per line

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

95.0
/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) {
76,736✔
16
      t = a % b;
76,479✔
17
      t.swap(b);
76,479✔
18
      t.swap(a);
76,479✔
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 size_t half = in.size() / 2;
257✔
33
   const Botan::BigInt x = Botan::BigInt::from_bytes(in.subspan(0, half));
257✔
34
   const Botan::BigInt y = Botan::BigInt::from_bytes(in.subspan(half, in.size() - half));
257✔
35

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

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