Coverage Report

Created: 2026-08-05 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/botan/src/fuzzer/mp_comba_mul.cpp
Line
Count
Source
1
/*
2
* (C) 2023 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#include "mp_fuzzers.h"
8
9
175
void fuzz(std::span<const uint8_t> in) {
10
175
   const size_t words = (in.size() + sizeof(word) - 1) / sizeof(word);
11
12
175
   if(in.empty() || words > 2 * 16) {
13
55
      return;
14
55
   }
15
120
   const size_t in_len = in.size();
16
17
120
   word x[24] = {0};
18
120
   word y[24] = {0};
19
20
120
   std::memcpy(x, in.data(), in_len / 2);
21
120
   std::memcpy(y, in.data() + in_len / 2, in_len - (in_len / 2));
22
23
120
   const size_t x_words = ((in_len / 2) + sizeof(word) - 1) / sizeof(word);
24
120
   const size_t y_words = ((in_len - (in_len / 2)) + sizeof(word) - 1) / sizeof(word);
25
26
120
   word z4[2 * 4] = {0};
27
120
   word z6[2 * 6] = {0};
28
120
   word z8[2 * 8] = {0};
29
120
   word z9[2 * 9] = {0};
30
120
   word z16[2 * 16] = {0};
31
120
   word z24[2 * 24] = {0};
32
33
120
   word z_ref[2 * 24] = {0};
34
35
120
   Botan::basecase_mul(z_ref, 2 * 24, x, x_words, y, y_words);
36
37
120
   if(words <= 8) {
38
46
      Botan::bigint_comba_mul4(z4, x, y);
39
46
   }
40
120
   if(words <= 12) {
41
58
      Botan::bigint_comba_mul6(z6, x, y);
42
58
   }
43
120
   if(words <= 16) {
44
75
      Botan::bigint_comba_mul8(z8, x, y);
45
75
   }
46
120
   if(words <= 18) {
47
84
      Botan::bigint_comba_mul9(z9, x, y);
48
84
   }
49
120
   if(words <= 32) {
50
106
      Botan::bigint_comba_mul16(z16, x, y);
51
106
   }
52
120
   if(words <= 48) {
53
120
      Botan::bigint_comba_mul24(z24, x, y);
54
120
   }
55
56
120
   if(words <= 8) {
57
46
      compare_word_vec(z4, 2 * 4, z6, 2 * 6, "mul4 vs mul6");
58
46
   }
59
120
   if(words <= 12) {
60
58
      compare_word_vec(z6, 2 * 6, z8, 2 * 8, "mul6 vs mul8");
61
58
   }
62
120
   if(words <= 16) {
63
75
      compare_word_vec(z8, 2 * 8, z9, 2 * 9, "mul8 vs mul9");
64
75
   }
65
120
   if(words <= 18) {
66
84
      compare_word_vec(z9, 2 * 9, z16, 2 * 16, "mul9 vs mul16");
67
84
   }
68
120
   if(words <= 32) {
69
106
      compare_word_vec(z16, 2 * 16, z24, 2 * 24, "mul16 vs mul24");
70
106
   }
71
72
120
   compare_word_vec(z24, 2 * 24, z_ref, 2 * 24, "mul24 vs basecase mul");
73
120
}