Coverage Report

Created: 2024-05-20 06:23

/src/nss/fuzz/mpi_addmod_target.cc
Line
Count
Source
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
/*
6
 * This target fuzzes NSS mpi against openssl bignum.
7
 * It therefore requires openssl to be installed.
8
 */
9
10
#include "mpi_helper.h"
11
12
12.0k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13
  // We require at least size 3 to get two integers from Data.
14
12.0k
  if (size < 3) {
15
6
    return 0;
16
6
  }
17
60.1k
  INIT_FOUR_NUMBERS
18
19
60.1k
  auto modulus = get_modulus(data, size, ctx);
20
  // Compare with OpenSSL add mod
21
60.1k
  m1 = &std::get<1>(modulus);
22
60.1k
  assert(mp_addmod(&a, &b, m1, &c) == MP_OKAY);
23
12.0k
  (void)BN_mod_add(C, A, B, std::get<0>(modulus), ctx);
24
12.0k
  check_equal(C, &c, max_size);
25
26
12.0k
  CLEANUP_AND_RETURN
27
60.1k
}