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/. */
6 * This target fuzzes NSS mpi against openssl bignum.
7 * It therefore requires openssl to be installed.
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.
19 // Compare with OpenSSL addition
20 assert(mp_add(&a
, &b
, &c
) == MP_OKAY
);
21 (void)BN_add(C
, A
, B
);
22 check_equal(C
, &c
, max_size
);
24 // Check a + b == a - -b
26 assert(mp_sub(&a
, &b
, &r
) == MP_OKAY
);
27 bool eq
= mp_cmp(&r
, &c
) == 0;
29 char rC
[max_size
], cC
[max_size
], aC
[max_size
], bC
[max_size
];
34 std::cout
<< "a = " << std::hex
<< aC
<< std::endl
;
35 std::cout
<< "-b = " << std::hex
<< bC
<< std::endl
;
36 std::cout
<< "a + b = " << std::hex
<< cC
<< std::endl
;
37 std::cout
<< "a - -b = " << std::hex
<< rC
<< std::endl
;