Bug 1885489 - Part 9: Add SnapshotIterator::readObject(). r=iain
[gecko.git] / security / nss / fuzz / mpi_addmod_target.cc
bloba7802b62e2e145c26a5b4eacc0e6036b3b176c67
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/. */
5 /*
6 * This target fuzzes NSS mpi against openssl bignum.
7 * It therefore requires openssl to be installed.
8 */
10 #include "mpi_helper.h"
12 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 if (size < 3) {
15 return 0;
17 INIT_FOUR_NUMBERS
19 auto modulus = get_modulus(data, size, ctx);
20 // Compare with OpenSSL add mod
21 m1 = &std::get<1>(modulus);
22 assert(mp_addmod(&a, &b, m1, &c) == MP_OKAY);
23 (void)BN_mod_add(C, A, B, std::get<0>(modulus), ctx);
24 check_equal(C, &c, max_size);
26 CLEANUP_AND_RETURN