diff options
author | Franziskus Kiefer <franziskuskiefer@gmail.com> | 2017-09-12 13:37:44 +0200 |
---|---|---|
committer | Franziskus Kiefer <franziskuskiefer@gmail.com> | 2017-09-12 13:37:44 +0200 |
commit | a837ca19d695b4b01b019675bc99ec2aeaf564a4 (patch) | |
tree | 94bc928f455d06d28403cddf9698d77d21a911a6 /fuzz | |
parent | acaf7eaa04142c16dacc269f682c476e6f0d5807 (diff) | |
download | nss-hg-a837ca19d695b4b01b019675bc99ec2aeaf564a4.tar.gz |
Bug 1372101 - make exponents smaller in expmod fuzzing target, r=ttaubert
Differential Revision: https://phabricator.services.mozilla.com/D53
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/mpi_expmod_target.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fuzz/mpi_expmod_target.cc b/fuzz/mpi_expmod_target.cc index 23826e935..b9be5854f 100644 --- a/fuzz/mpi_expmod_target.cc +++ b/fuzz/mpi_expmod_target.cc @@ -19,9 +19,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto modulus = get_modulus(data, size, ctx); // Compare with OpenSSL exp mod m1 = &std::get<1>(modulus); - print_bn("A", A); - print_bn("B", B); - print_bn("m", std::get<0>(modulus)); + // The exponent b (B) can get really big. Make it smaller if necessary. + if (MP_USED(&b) > 100) { + size_t shift = (MP_USED(&b) - 100) * MP_DIGIT_BIT; + mp_div_2d(&b, shift, &b, nullptr); + BN_rshift(B, B, shift); + } check_equal(A, &a, max_size); check_equal(B, &b, max_size); check_equal(std::get<0>(modulus), m1, 3 * max_size); |