PROV & SIGNATURE: Adapt the RSA signature code for PSS-parameters
[openssl.git] / fuzz / bndiv.c
index 30d84482a63e8cefad7e526a66238da942a38989..d9467b5e8b412cceecd539e744e4adcfc9891791 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL licenses, (the "License");
+ * Licensed under the Apache License 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * https://www.openssl.org/source/license.html
@@ -18,6 +18,9 @@
 #include <openssl/err.h>
 #include "fuzzer.h"
 
+/* 256 kB */
+#define MAX_LEN (256 * 1000)
+
 static BN_CTX *ctx;
 static BIGNUM *b1;
 static BIGNUM *b2;
@@ -35,7 +38,7 @@ int FuzzerInitialize(int *argc, char ***argv)
     ctx = BN_CTX_new();
 
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
-    ERR_get_state();
+    ERR_clear_error();
 
     return 1;
 }
@@ -47,6 +50,10 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     /* s1 and s2 will be the signs for b1 and b2. */
     int s1 = 0, s2 = 0;
 
+    /* limit the size of the input to avoid timeout */
+    if (len > MAX_LEN)
+        len = MAX_LEN;
+
     /* We are going to split the buffer in two, sizes l1 and l2, giving b1 and
      * b2.
      */