Coverage Report

Created: 2022-06-23 06:44

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