summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc')
-rw-r--r--llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc b/llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc
new file mode 100644
index 00000000000..9dc2d5dc21b
--- /dev/null
+++ b/llvm/lib/Fuzzer/fuzzer-test-suite/openssl-1.0.1f/target.cc
@@ -0,0 +1,39 @@
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#include <assert.h>
+#include <stdint.h>
+#include <stddef.h>
+
+#ifndef CERT_PATH
+# define CERT_PATH
+#endif
+
+SSL_CTX *Init() {
+ SSL_library_init();
+ SSL_load_error_strings();
+ ERR_load_BIO_strings();
+ OpenSSL_add_all_algorithms();
+ SSL_CTX *sctx;
+ assert (sctx = SSL_CTX_new(TLSv1_method()));
+ /* These two file were created with this command:
+ openssl req -x509 -newkey rsa:512 -keyout server.key \
+ -out server.pem -days 9999 -nodes -subj /CN=a/
+ */
+ assert(SSL_CTX_use_certificate_file(sctx, CERT_PATH "server.pem",
+ SSL_FILETYPE_PEM));
+ assert(SSL_CTX_use_PrivateKey_file(sctx, CERT_PATH "server.key",
+ SSL_FILETYPE_PEM));
+ return sctx;
+}
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ static SSL_CTX *sctx = Init();
+ SSL *server = SSL_new(sctx);
+ BIO *sinbio = BIO_new(BIO_s_mem());
+ BIO *soutbio = BIO_new(BIO_s_mem());
+ SSL_set_bio(server, sinbio, soutbio);
+ SSL_set_accept_state(server);
+ BIO_write(sinbio, Data, Size);
+ SSL_do_handshake(server);
+ SSL_free(server);
+ return 0;
+}
OpenPOWER on IntegriCloud