Coverage Report

Created: 2023-11-20 06:46

/src/botan/src/fuzzer/redc_p192.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.91k
void fuzz(const uint8_t in[], size_t len) {
13
1.91k
   if(len > 2 * 192 / 8) {
14
127
      return;
15
127
   }
16
17
1.78k
   static const Botan::BigInt& prime = Botan::prime_p192();
18
1.78k
   static const Botan::BigInt prime_2 = prime * prime;
19
1.78k
   static Botan::Modular_Reducer prime_redc(prime);
20
21
1.78k
   Botan::BigInt input = Botan::BigInt::decode(in, len);
22
23
1.78k
   if(input < prime_2) {
24
1.78k
      const Botan::BigInt ref = prime_redc.reduce(input);
25
26
1.78k
      Botan::secure_vector<Botan::word> ws;
27
1.78k
      Botan::redc_p192(input, ws);
28
29
1.78k
      FUZZER_ASSERT_EQUAL(ref, input);
30
1.78k
   }
31
1.78k
}