summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2017-10-09 11:30:43 +1100
committerMartin Thomson <martin.thomson@gmail.com>2017-10-09 11:30:43 +1100
commite78fea278cc67fa308ea7b62630c02f8217c3630 (patch)
tree0d43bcc8af95c8b3c6632571f5121faf4092588c /fuzz
parent474f1bcabd34eee91a34831260ea514660162d2f (diff)
parentc21e2ced85ff55b338ea1758179d358126d9204b (diff)
downloadnss-hg-e78fea278cc67fa308ea7b62630c02f8217c3630.tar.gz
Merge NSS trunk to NSS_TLS13_DRAFT19_BRANCH
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/mpi_expmod_target.cc9
-rw-r--r--fuzz/tls_socket.h1
2 files changed, 7 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);
diff --git a/fuzz/tls_socket.h b/fuzz/tls_socket.h
index 61fa4b3a8..e30f6fa3c 100644
--- a/fuzz/tls_socket.h
+++ b/fuzz/tls_socket.h
@@ -10,6 +10,7 @@
class DummyPrSocket : public DummyIOLayerMethods {
public:
DummyPrSocket(const uint8_t *buf, size_t len) : buf_(buf), len_(len) {}
+ virtual ~DummyPrSocket() {}
int32_t Read(PRFileDesc *f, void *data, int32_t len) override;
int32_t Write(PRFileDesc *f, const void *buf, int32_t length) override;