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

randombit / botan / 4813715657

26 Apr 2023 10:37PM UTC coverage: 92.146% (-0.01%) from 92.159%
4813715657

push

github

77594 of 84208 relevant lines covered (92.15%)

12015927.05 hits per line

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

93.75
/src/fuzzer/ressol.cpp
1
/*
2
* (C) 2015,2016 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
#include <botan/reducer.h>
11

12
void fuzz(const uint8_t in[], size_t len)
1,000✔
13
   {
14
   // Ressol is mostly used for ECC point decompression so best to test smaller sizes
15
   static const size_t p_bits = 256;
1,000✔
16
   static const Botan::BigInt p = random_prime(fuzzer_rng(), p_bits);
1,000✔
17
   static const Botan::Modular_Reducer mod_p(p);
1,000✔
18

19
   if(len > p_bits / 8)
1,000✔
20
      return;
21

22
   try
33✔
23
      {
24
      const Botan::BigInt a = Botan::BigInt::decode(in, len);
33✔
25
      Botan::BigInt a_sqrt = Botan::sqrt_modulo_prime(a, p);
33✔
26

27
      if(a_sqrt > 0)
33✔
28
         {
29
         const Botan::BigInt a_redc = mod_p.reduce(a);
16✔
30
         const Botan::BigInt z = mod_p.square(a_sqrt);
16✔
31

32
         if(z != a_redc)
16✔
33
            {
34
            FUZZER_WRITE_AND_CRASH("A = " << a << "\n"
16✔
35
                                   << "P = " << p << "\n"
36
                                   << "R = " << a_sqrt << "\n"
37
                                   << "Z = " << z << "\n");
38
            }
39
         }
32✔
40
      }
65✔
41
   catch(Botan::Exception& e) {}
×
42

43
   return;
44
   }
45

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

© 2025 Coveralls, Inc