From fb1118fbee181ebbe9e392e154b296f14bcd5354 Mon Sep 17 00:00:00 2001
From: tb <>
Date: Sun, 19 Nov 2023 13:11:06 +0000
Subject: Unifdef OPENSSL_NO_ENGINE in libcrypto regress

---
 src/regress/lib/libcrypto/dsa/dsatest.c        |  4 +---
 src/regress/lib/libcrypto/ec/ectest.c          |  8 +-------
 src/regress/lib/libcrypto/ecdsa/ecdsatest.c    |  5 +----
 src/regress/lib/libcrypto/evp/evptest.c        | 25 +------------------------
 src/regress/lib/libcrypto/free/freenull.awk    |  9 +--------
 src/regress/lib/libcrypto/free/freenull.c.head |  5 +----
 src/regress/lib/libcrypto/gost/gost2814789t.c  |  8 +-------
 src/regress/lib/libcrypto/pbkdf2/pbkdf2.c      | 12 +-----------
 8 files changed, 8 insertions(+), 68 deletions(-)

diff --git a/src/regress/lib/libcrypto/dsa/dsatest.c b/src/regress/lib/libcrypto/dsa/dsatest.c
index 62343455f3..10ebc3a9f8 100644
--- a/src/regress/lib/libcrypto/dsa/dsatest.c
+++ b/src/regress/lib/libcrypto/dsa/dsatest.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: dsatest.c,v 1.9 2023/08/20 22:22:55 tb Exp $	*/
+/*	$OpenBSD: dsatest.c,v 1.10 2023/11/19 13:11:05 tb Exp $	*/
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -137,12 +137,10 @@ main(int argc, char **argv)
 	if ((dsa = DSA_new()) == NULL)
 		goto end;
 
-#ifdef OPENSSL_NO_ENGINE
 	if (DSA_get0_engine(dsa) != NULL) {
 		BIO_printf(bio_err, "ENGINE was not NULL\n");
 		goto end;
 	}
-#endif
 
 	if (!DSA_generate_parameters_ex(dsa, 512, seed, 20, &counter, &h, cb))
 		goto end;
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c
index f0b1028f48..b32b007b30 100644
--- a/src/regress/lib/libcrypto/ec/ectest.c
+++ b/src/regress/lib/libcrypto/ec/ectest.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ectest.c,v 1.21 2023/07/26 22:46:06 tb Exp $	*/
+/*	$OpenBSD: ectest.c,v 1.22 2023/11/19 13:11:05 tb Exp $	*/
 /*
  * Originally written by Bodo Moeller for the OpenSSL project.
  */
@@ -75,9 +75,6 @@
 #include <time.h>
 
 #include <openssl/ec.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/err.h>
 #include <openssl/obj_mac.h>
 #include <openssl/objects.h>
@@ -769,9 +766,6 @@ main(int argc, char *argv[])
 	/* test the internal curves */
 	internal_curve_test();
 
-#ifndef OPENSSL_NO_ENGINE
-	ENGINE_cleanup();
-#endif
 	CRYPTO_cleanup_all_ex_data();
 	ERR_free_strings();
 	ERR_remove_thread_state(NULL);
diff --git a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
index b0b9bd0065..ef724c74b5 100644
--- a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
+++ b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ecdsatest.c,v 1.17 2023/05/04 13:50:14 tb Exp $	*/
+/*	$OpenBSD: ecdsatest.c,v 1.18 2023/11/19 13:11:06 tb Exp $	*/
 /*
  * Written by Nils Larsch for the OpenSSL project.
  */
@@ -78,9 +78,6 @@
 #include <openssl/evp.h>
 #include <openssl/bn.h>
 #include <openssl/ecdsa.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/err.h>
 
 int test_builtin(void);
diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c
index 6f677dd959..0b9436a83f 100644
--- a/src/regress/lib/libcrypto/evp/evptest.c
+++ b/src/regress/lib/libcrypto/evp/evptest.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: evptest.c,v 1.12 2023/03/02 20:24:51 tb Exp $	*/
+/*	$OpenBSD: evptest.c,v 1.13 2023/11/19 13:11:06 tb Exp $	*/
 /* Written by Ben Laurie, 2001 */
 /*
  * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
@@ -53,9 +53,6 @@
 
 #include <openssl/opensslconf.h>
 #include <openssl/evp.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/err.h>
 #include <openssl/conf.h>
 
@@ -350,23 +347,6 @@ main(int argc, char **argv)
 	/* Load up the software EVP_CIPHER and EVP_MD definitions */
 	OpenSSL_add_all_ciphers();
 	OpenSSL_add_all_digests();
-#ifndef OPENSSL_NO_ENGINE
-	/* Load all compiled-in ENGINEs */
-	ENGINE_load_builtin_engines();
-#endif
-#if 0
-	OPENSSL_config();
-#endif
-#ifndef OPENSSL_NO_ENGINE
-    /* Register all available ENGINE implementations of ciphers and digests.
-     * This could perhaps be changed to "ENGINE_register_all_complete()"? */
-	ENGINE_register_all_ciphers();
-	ENGINE_register_all_digests();
-    /* If we add command-line options, this statement should be switchable.
-     * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
-     * they weren't already initialised. */
-	/* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
-#endif
 
 	for (;;) {
 		char line[8 * 1024];
@@ -457,9 +437,6 @@ main(int argc, char **argv)
 	}
 	fclose(f);
 
-#ifndef OPENSSL_NO_ENGINE
-	ENGINE_cleanup();
-#endif
 	EVP_cleanup();
 	CRYPTO_cleanup_all_ex_data();
 	ERR_remove_thread_state(NULL);
diff --git a/src/regress/lib/libcrypto/free/freenull.awk b/src/regress/lib/libcrypto/free/freenull.awk
index 618034cc70..3a10d99ebb 100644
--- a/src/regress/lib/libcrypto/free/freenull.awk
+++ b/src/regress/lib/libcrypto/free/freenull.awk
@@ -1,4 +1,4 @@
-# $OpenBSD: freenull.awk,v 1.3 2023/07/28 18:29:26 tb Exp $
+# $OpenBSD: freenull.awk,v 1.4 2023/11/19 13:11:06 tb Exp $
 # Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
 #
 # Permission to use, copy, modify, and distribute this software for any
@@ -42,13 +42,6 @@
 	next
 }
 
-/^ENGINE_free$/ {
-	printf("#ifndef OPENSSL_NO_ENGINE\n")
-	printf("\tENGINE_free(NULL);\n")
-	printf("#endif\n")
-	next
-}
-
 /_free$/ {
 	printf("\t%s(NULL);\n", $0)
 }
diff --git a/src/regress/lib/libcrypto/free/freenull.c.head b/src/regress/lib/libcrypto/free/freenull.c.head
index dc1a7da523..43b87598e1 100644
--- a/src/regress/lib/libcrypto/free/freenull.c.head
+++ b/src/regress/lib/libcrypto/free/freenull.c.head
@@ -1,4 +1,4 @@
-/*	$OpenBSD: freenull.c.head,v 1.6 2023/07/28 17:13:56 tb Exp $	*/
+/*	$OpenBSD: freenull.c.head,v 1.7 2023/11/19 13:11:06 tb Exp $	*/
 
 #include <openssl/asn1.h>
 #include <openssl/cmac.h>
@@ -6,9 +6,6 @@
 #include <openssl/comp.h>
 #include <openssl/conf_api.h>
 #include <openssl/ct.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/gost.h>
 #include <openssl/hmac.h>
 #include <openssl/ocsp.h>
diff --git a/src/regress/lib/libcrypto/gost/gost2814789t.c b/src/regress/lib/libcrypto/gost/gost2814789t.c
index 5e439a7e36..f4914997cf 100644
--- a/src/regress/lib/libcrypto/gost/gost2814789t.c
+++ b/src/regress/lib/libcrypto/gost/gost2814789t.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: gost2814789t.c,v 1.9 2023/06/19 18:51:47 tb Exp $	*/
+/*	$OpenBSD: gost2814789t.c,v 1.10 2023/11/19 13:11:06 tb Exp $	*/
 /* vim: set fileencoding=ascii : Charset: ASCII */
 /* test/gostr2814789t.c */
 /* ====================================================================
@@ -24,9 +24,6 @@ int main(int argc, char *argv[])
 #include <inttypes.h>
 #include <openssl/conf.h>
 #include <openssl/crypto.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
@@ -1289,9 +1286,6 @@ int main(int argc, char *argv[])
     }
 
     ERR_load_crypto_strings();
-#ifndef OPENSSL_NO_ENGINE
-    ENGINE_load_builtin_engines();
-#endif
     OPENSSL_load_builtin_modules();
     OpenSSL_add_all_algorithms();
 
diff --git a/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c b/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c
index 9cbc031821..33b683f0a0 100644
--- a/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c
+++ b/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pbkdf2.c,v 1.2 2018/07/17 17:06:49 tb Exp $	*/
+/*	$OpenBSD: pbkdf2.c,v 1.3 2023/11/19 13:11:06 tb Exp $	*/
 /* Written by Christian Heimes, 2013 */
 /*
  * Copyright (c) 2013 The OpenSSL Project.  All rights reserved.
@@ -56,9 +56,6 @@
 
 #include <openssl/opensslconf.h>
 #include <openssl/evp.h>
-#ifndef OPENSSL_NO_ENGINE
-#include <openssl/engine.h>
-#endif
 #include <openssl/err.h>
 #include <openssl/conf.h>
 
@@ -192,10 +189,6 @@ main(int argc,char **argv)
 	const testdata *test = test_cases;
 
 	OpenSSL_add_all_digests();
-#ifndef OPENSSL_NO_ENGINE
-	ENGINE_load_builtin_engines();
-	ENGINE_register_all_digests();
-#endif
 
 	for (n = 0; test->pass != NULL; n++, test++) {
 		test_p5_pbkdf2(n, "sha1", test, sha1_results[n]);
@@ -203,9 +196,6 @@ main(int argc,char **argv)
 		test_p5_pbkdf2(n, "sha512", test, sha512_results[n]);
 	}
 
-#ifndef OPENSSL_NO_ENGINE
-	ENGINE_cleanup();
-#endif
 	EVP_cleanup();
 	CRYPTO_cleanup_all_ex_data();
 	ERR_remove_thread_state(NULL);
-- 
cgit v1.2.3-55-g6feb