Coverage Report

Created: 2020-02-14 15:38

/src/botan/src/fuzzer/redc_p521.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/curve_nistp.h>
10
11
void fuzz(const uint8_t in[], size_t len)
12
349
   {
13
349
   if(len > 2*(521+7)/8)
14
127
      return;
15
222
16
222
   static const Botan::BigInt& prime = Botan::prime_p521();
17
222
   static const Botan::BigInt prime_2 = prime * prime;
18
222
   static Botan::Modular_Reducer prime_redc(prime);
19
222
20
222
   Botan::BigInt input = Botan::BigInt::decode(in, len);
21
222
22
222
   if(input < prime_2)
23
217
      {
24
217
      const Botan::BigInt ref = prime_redc.reduce(input);
25
217
26
217
      Botan::secure_vector<Botan::word> ws;
27
217
      Botan::redc_p521(input, ws);
28
217
29
217
      FUZZER_ASSERT_EQUAL(ref, input);
30
217
      }
31
222
   }