summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2019-05-14 14:45:53 +0200
committerRobert Swiecki <robert@swiecki.net>2019-05-14 14:45:53 +0200
commit320e5d40ed52a1a1b3761467505a5d46b0dc5aca (patch)
tree86d9a0bcf3f9697bba52e37c58fc2b638d53d891
parent5827b6e0370ef8805cc455e8a0b77bbfcc84b752 (diff)
downloadhonggfuzz-320e5d40ed52a1a1b3761467505a5d46b0dc5aca.tar.gz
examples/openssl: move init to CTX #5
-rw-r--r--examples/openssl/client.c6
-rw-r--r--examples/openssl/server.c12
2 files changed, 10 insertions, 8 deletions
diff --git a/examples/openssl/client.c b/examples/openssl/client.c
index f1a6240d..3a395849 100644
--- a/examples/openssl/client.c
+++ b/examples/openssl/client.c
@@ -556,8 +556,10 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
#endif /* defined(HF_SSL_IS_BORINGSSL) */
SSL_CTX_set_ecdh_auto(ctx, 1);
+#if defined(TLS1_3_VERSION)
SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION);
+#endif /* defined(TLS1_3_VERSION) */
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
SSL_CTX_set_timeout(ctx, 3);
@@ -565,9 +567,9 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
SSL_CTX_enable_ct(ctx, SSL_CT_VALIDATION_PERMISSIVE);
SSL_CTX_set_max_early_data(ctx, 1024);
#endif /* defined(HF_SSL_IS_OPENSSL_GE_1_1) */
-#if !defined(HF_SSL_IS_BORINGSSL)
+#if defined(HF_SSL_IS_OPENSSL_GE_1_1) || defined(HF_SSL_IS_LIBRESSL)
SSL_CTX_set_dh_auto(ctx, 1);
-#endif /* !defined(HF_SSL_IS_BORINGSSL) */
+#endif /* #if defined(HF_SSL_IS_OPENSSL_GE_1_1) || defined(HF_SSL_IS_LIBRESSL) */
long opts = SSL_CTX_get_options(ctx);
opts |= SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
diff --git a/examples/openssl/server.c b/examples/openssl/server.c
index 1bf0faa9..f087cb25 100644
--- a/examples/openssl/server.c
+++ b/examples/openssl/server.c
@@ -612,8 +612,10 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
SSL_CTX_set_alpn_select_cb(ctx, alpn_callback, NULL);
SSL_CTX_set_next_protos_advertised_cb(ctx, npn_callback, NULL);
SSL_CTX_set_ecdh_auto(ctx, 1);
+#if defined(TLS1_3_VERSION)
SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION);
+#endif /* defined(TLS1_3_VERSION) */
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
SSL_CTX_set_timeout(ctx, 3);
@@ -621,9 +623,11 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
SSL_CTX_enable_ct(ctx, SSL_CT_VALIDATION_STRICT);
SSL_CTX_set_max_early_data(ctx, 1024);
#endif /* defined(HF_SSL_IS_OPENSSL_GE_1_1) */
-#if !defined(HF_SSL_IS_BORINGSSL)
+
+#if defined(HF_SSL_IS_OPENSSL_GE_1_1) || defined(HF_SSL_IS_LIBRESSL)
SSL_CTX_set_dh_auto(ctx, 1);
-#endif /* !defined(HF_SSL_IS_BORINGSSL) */
+ SSL_CTX_set_generate_session_id(ctx, session_id_callback);
+#endif /* defined(HF_SSL_IS_OPENSSL_GE_1_1) || defined(HF_SSL_IS_LIBRESSL) */
long opts = SSL_CTX_get_options(ctx);
opts |= SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
@@ -631,10 +635,6 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
opts |= SSL_OP_ALL;
SSL_CTX_set_options(ctx, opts);
-#if !defined(HF_SSL_IS_BORINGSSL)
- SSL_CTX_set_generate_session_id(ctx, session_id_callback);
-#endif /* !defined(HF_SSL_IS_BORINGSSL) */
-
return 1;
}