Coverage Report

Created: 2023-06-05 07:26

/src/botan/src/fuzzer/redc_p384.cpp
Line
Count
Source
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/reducer.h>
10
#include <botan/internal/curve_nistp.h>
11
12
1.94k
void fuzz(const uint8_t in[], size_t len) {
13
1.94k
   if(len > 2 * 384 / 8)
14
127
      return;
15
16
1.81k
   static const Botan::BigInt& prime = Botan::prime_p384();
17
1.81k
   static const Botan::BigInt prime_2 = prime * prime;
18
1.81k
   static Botan::Modular_Reducer prime_redc(prime);
19
20
1.81k
   Botan::BigInt input = Botan::BigInt::decode(in, len);
21
22
1.81k
   if(input < prime_2) {
23
1.81k
      const Botan::BigInt ref = prime_redc.reduce(input);
24
25
1.81k
      Botan::secure_vector<Botan::word> ws;
26
1.81k
      Botan::redc_p384(input, ws);
27
28
1.81k
      FUZZER_ASSERT_EQUAL(ref, input);
29
1.81k
   }
30
1.81k
}