[PATCH 4/4] Fix --without-openssl tests

Alex Xu alex_y_xu at yahoo.ca
Mon Jun 11 00:05:41 AEST 2018


---
 regress/unittests/bitmap/tests.c              | 33 ++++++++++++++++++-
 regress/unittests/hostkeys/test_iterate.c     | 22 +++++++++++++
 regress/unittests/kex/test_kex.c              |  6 ++++
 .../sshbuf/test_sshbuf_getput_crypto.c        |  3 +-
 .../sshbuf/test_sshbuf_getput_fuzz.c          |  3 +-
 regress/unittests/sshbuf/tests.c              |  4 +++
 regress/unittests/sshkey/common.c             |  4 +++
 regress/unittests/sshkey/common.h             |  3 +-
 regress/unittests/sshkey/test_file.c          |  7 +++-
 regress/unittests/sshkey/test_fuzz.c          |  6 +++-
 regress/unittests/sshkey/test_sshkey.c        |  8 +++++
 regress/unittests/sshkey/tests.c              |  4 +++
 regress/unittests/test_helper/test_helper.c   |  6 ++++
 regress/unittests/test_helper/test_helper.h   | 12 +++++++
 14 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/regress/unittests/bitmap/tests.c b/regress/unittests/bitmap/tests.c
index 23025f90..ead89601 100644
--- a/regress/unittests/bitmap/tests.c
+++ b/regress/unittests/bitmap/tests.c
@@ -16,7 +16,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
+#endif
 
 #include "../test_helper/test_helper.h"
 
@@ -28,7 +30,9 @@ void
 tests(void)
 {
 	struct bitmap *b;
+#ifdef WITH_OPENSSL
 	BIGNUM *bn;
+#endif
 	size_t len;
 	int i, j, k, n;
 	u_char bbuf[1024], bnbuf[1024];
@@ -37,8 +41,10 @@ tests(void)
 	TEST_START("bitmap_new");
 	b = bitmap_new();
 	ASSERT_PTR_NE(b, NULL);
+#ifdef WITH_OPENSSL
 	bn = BN_new();
 	ASSERT_PTR_NE(bn, NULL);
+#endif
 	TEST_DONE();
 
 	TEST_START("bitmap_set_bit / bitmap_test_bit");
@@ -46,23 +52,32 @@ tests(void)
 		for (j = -1; j < NTESTS; j++) {
 			for (k = -1; k < NTESTS; k++) {
 				bitmap_zero(b);
+#ifdef WITH_OPENSSL
 				BN_clear(bn);
+#endif
 
 				test_subtest_info("set %d/%d/%d", i, j, k);
 				/* Set bits */
 				if (i >= 0) {
 					ASSERT_INT_EQ(bitmap_set_bit(b, i), 0);
+#ifdef WITH_OPENSSL
 					ASSERT_INT_EQ(BN_set_bit(bn, i), 1);
+#endif
 				}
 				if (j >= 0) {
 					ASSERT_INT_EQ(bitmap_set_bit(b, j), 0);
+#ifdef WITH_OPENSSL
 					ASSERT_INT_EQ(BN_set_bit(bn, j), 1);
+#endif
 				}
 				if (k >= 0) {
 					ASSERT_INT_EQ(bitmap_set_bit(b, k), 0);
+#ifdef WITH_OPENSSL
 					ASSERT_INT_EQ(BN_set_bit(bn, k), 1);
+#endif
 				}
 
+#ifdef WITH_OPENSSL
 				/* Check perfect match between bitmap and bn */
 				test_subtest_info("match %d/%d/%d", i, j, k);
 				for (n = 0; n < NTESTS; n++) {
@@ -76,6 +91,7 @@ tests(void)
 				    (int)bitmap_nbits(b));
 				ASSERT_INT_EQ(BN_num_bytes(bn),
 				    (int)bitmap_nbytes(b));
+#endif /* WITH_OPENSSL */
 
 				/* Test serialisation */
 				test_subtest_info("serialise %d/%d/%d",
@@ -86,10 +102,12 @@ tests(void)
 				    sizeof(bbuf)), 0);
 				for (n = len; n < (int)sizeof(bbuf); n++)
 					ASSERT_U8_EQ(bbuf[n], 0xfc);
+#ifdef WITH_OPENSSL
 				r = BN_bn2bin(bn, bnbuf);
 				ASSERT_INT_GE(r, 0);
 				ASSERT_INT_EQ(r, (int)len);
 				ASSERT_MEM_EQ(bbuf, bnbuf, len);
+#endif
 
 				/* Test deserialisation */
 				test_subtest_info("deserialise %d/%d/%d",
@@ -97,39 +115,52 @@ tests(void)
 				bitmap_zero(b);
 				ASSERT_INT_EQ(bitmap_from_string(b, bnbuf,
 				    len), 0);
+#ifdef WITH_OPENSSL
 				for (n = 0; n < NTESTS; n++) {
 					ASSERT_INT_EQ(BN_is_bit_set(bn, n),
 					    bitmap_test_bit(b, n));
 				}
+#endif
 
 				/* Test clearing bits */
 				test_subtest_info("clear %d/%d/%d",
 				    i, j, k);
 				for (n = 0; n < NTESTS; n++) {
 					ASSERT_INT_EQ(bitmap_set_bit(b, n), 0);
+#ifdef WITH_OPENSSL
 					ASSERT_INT_EQ(BN_set_bit(bn, n), 1);
+#endif
 				}
 				if (i >= 0) {
 					bitmap_clear_bit(b, i);
+#ifdef WITH_OPENSSL
 					BN_clear_bit(bn, i);
+#endif
 				}
 				if (j >= 0) {
 					bitmap_clear_bit(b, j);
+#ifdef WITH_OPENSSL
 					BN_clear_bit(bn, j);
+#endif
 				}
 				if (k >= 0) {
 					bitmap_clear_bit(b, k);
+#ifdef WITH_OPENSSL
 					BN_clear_bit(bn, k);
+#endif
 				}
+#ifdef WITH_OPENSSL
 				for (n = 0; n < NTESTS; n++) {
 					ASSERT_INT_EQ(BN_is_bit_set(bn, n),
 					    bitmap_test_bit(b, n));
 				}
+#endif
 			}
 		}
 	}
 	bitmap_free(b);
+#ifdef WITH_OPENSSL
 	BN_free(bn);
+#endif
 	TEST_DONE();
 }
-
diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c
index 751825dd..489bc70f 100644
--- a/regress/unittests/hostkeys/test_iterate.c
+++ b/regress/unittests/hostkeys/test_iterate.c
@@ -166,6 +166,7 @@ struct expected expected_full[] = {
 		NULL,				/* deserialised key */
 		NULL,				/* comment */
 	} },
+#ifdef WITH_OPENSSL
 	{ "dsa_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, {
 		NULL,
 		2,
@@ -192,6 +193,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ECDSA #1",
 	} },
+#endif
 	{ "ed25519_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, {
 		NULL,
 		4,
@@ -205,6 +207,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #1",
 	} },
+#ifdef WITH_OPENSSL
 	{ "rsa_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, {
 		NULL,
 		5,
@@ -218,6 +221,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"RSA #1",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		6,
@@ -244,6 +248,7 @@ struct expected expected_full[] = {
 		NULL,
 		NULL,
 	} },
+#ifdef WITH_OPENSSL
 	{ "dsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		8,
@@ -270,6 +275,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ECDSA #2",
 	} },
+#endif
 	{ "ed25519_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		10,
@@ -283,6 +289,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #2",
 	} },
+#ifdef WITH_OPENSSL
 	{ "rsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		11,
@@ -296,6 +303,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"RSA #2",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		12,
@@ -322,6 +330,7 @@ struct expected expected_full[] = {
 		NULL,
 		NULL,
 	} },
+#ifdef WITH_OPENSSL
 	{ "dsa_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		14,
@@ -348,6 +357,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ECDSA #3",
 	} },
+#endif
 	{ "ed25519_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		16,
@@ -361,6 +371,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #3",
 	} },
+#ifdef WITH_OPENSSL
 	{ "rsa_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
 		NULL,
 		17,
@@ -374,6 +385,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"RSA #3",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		18,
@@ -400,6 +412,7 @@ struct expected expected_full[] = {
 		NULL,
 		NULL,
 	} },
+#ifdef WITH_OPENSSL
 	{ "dsa_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, {
 		NULL,
 		20,
@@ -426,6 +439,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ECDSA #5",
 	} },
+#endif
 	{ "ed25519_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, {
 		NULL,
 		22,
@@ -439,6 +453,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #5",
 	} },
+#ifdef WITH_OPENSSL
 	{ "rsa_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, {
 		NULL,
 		23,
@@ -452,6 +467,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"RSA #5",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		24,
@@ -470,6 +486,7 @@ struct expected expected_full[] = {
 	 * hostname and addresses in the pre-hashed known_hosts are split
 	 * to separate lines.
 	 */
+#ifdef WITH_OPENSSL
 	{ "dsa_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, {
 		NULL,
 		25,
@@ -548,6 +565,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ECDSA #6",
 	} },
+#endif
 	{ "ed25519_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, {
 		NULL,
 		31,
@@ -587,6 +605,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #6",
 	} },
+#ifdef WITH_OPENSSL
 	{ "rsa_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, {
 		NULL,
 		34,
@@ -626,6 +645,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"RSA #6",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		37,
@@ -678,6 +698,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"ED25519 #4",
 	} },
+#ifdef WITH_OPENSSL
 	{ "ecdsa_4.pub" , -1, -1, HKF_MATCH_HOST, 0, 0, 0, -1, {
 		NULL,
 		41,
@@ -704,6 +725,7 @@ struct expected expected_full[] = {
 		NULL,	/* filled at runtime */
 		"DSA #4",
 	} },
+#endif
 	{ NULL, -1, -1, 0, 0, 0, 0, -1, {
 		NULL,
 		43,
diff --git a/regress/unittests/kex/test_kex.c b/regress/unittests/kex/test_kex.c
index 6e5999bb..73e9af79 100644
--- a/regress/unittests/kex/test_kex.c
+++ b/regress/unittests/kex/test_kex.c
@@ -145,12 +145,14 @@ do_kex_with_key(char *kex, int keytype, int bits)
 	sshbuf_free(state);
 	ASSERT_PTR_NE(server2->kex, NULL);
 	/* XXX we need to set the callbacks */
+#ifdef WITH_OPENSSL
 	server2->kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
 	server2->kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
 	server2->kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
 	server2->kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
 #ifdef OPENSSL_HAS_ECC
 	server2->kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
+#endif
 #endif
 	server2->kex->kex[KEX_C25519_SHA256] = kexc25519_server;
 	server2->kex->load_host_public_key = server->kex->load_host_public_key;
@@ -178,10 +180,12 @@ do_kex_with_key(char *kex, int keytype, int bits)
 static void
 do_kex(char *kex)
 {
+#ifdef WITH_OPENSSL
 	do_kex_with_key(kex, KEY_RSA, 2048);
 	do_kex_with_key(kex, KEY_DSA, 1024);
 #ifdef OPENSSL_HAS_ECC
 	do_kex_with_key(kex, KEY_ECDSA, 256);
+#endif
 #endif
 	do_kex_with_key(kex, KEY_ED25519, 256);
 }
@@ -190,6 +194,7 @@ void
 kex_tests(void)
 {
 	do_kex("curve25519-sha256 at libssh.org");
+#ifdef WITH_OPENSSL
 #ifdef OPENSSL_HAS_ECC
 	do_kex("ecdh-sha2-nistp256");
 	do_kex("ecdh-sha2-nistp384");
@@ -199,4 +204,5 @@ kex_tests(void)
 	do_kex("diffie-hellman-group-exchange-sha1");
 	do_kex("diffie-hellman-group14-sha1");
 	do_kex("diffie-hellman-group1-sha1");
+#endif /* WITH_OPENSSL */
 }
diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
index a68e1329..58ec1561 100644
--- a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
+++ b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
@@ -5,6 +5,7 @@
  * Placed in the public domain
  */
 
+#ifdef WITH_OPENSSL
 #include "includes.h"
 
 #include <sys/types.h>
@@ -406,4 +407,4 @@ sshbuf_getput_crypto_tests(void)
 	TEST_DONE();
 #endif
 }
-
+#endif
diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
index c6b5c29d..2a5e1977 100644
--- a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
+++ b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
@@ -5,6 +5,7 @@
  * Placed in the public domain
  */
 
+#ifdef WITH_OPENSSL
 #include "includes.h"
 
 #include <sys/types.h>
@@ -127,4 +128,4 @@ sshbuf_getput_fuzz_tests(void)
 	TEST_DONE();
 	TEST_ONERROR(NULL, NULL);
 }
-
+#endif /* WITH_OPENSSL */
diff --git a/regress/unittests/sshbuf/tests.c b/regress/unittests/sshbuf/tests.c
index 1557e434..21495b6b 100644
--- a/regress/unittests/sshbuf/tests.c
+++ b/regress/unittests/sshbuf/tests.c
@@ -20,9 +20,13 @@ tests(void)
 {
 	sshbuf_tests();
 	sshbuf_getput_basic_tests();
+#ifdef WITH_OPENSSL
 	sshbuf_getput_crypto_tests();
+#endif
 	sshbuf_misc_tests();
 	sshbuf_fuzz_tests();
+#ifdef WITH_OPENSSL
 	sshbuf_getput_fuzz_tests();
+#endif
 	sshbuf_fixed();
 }
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c
index b598f05c..ba13edd7 100644
--- a/regress/unittests/sshkey/common.c
+++ b/regress/unittests/sshkey/common.c
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
 #include <openssl/dsa.h>
@@ -26,6 +27,7 @@
 #ifdef OPENSSL_HAS_NISTP256
 # include <openssl/ec.h>
 #endif
+#endif /* WITH_OPENSSL */
 
 #include "../test_helper/test_helper.h"
 
@@ -70,6 +72,7 @@ load_text_file(const char *name)
 	return ret;
 }
 
+#ifdef WITH_OPENSSL
 BIGNUM *
 load_bignum(const char *name)
 {
@@ -81,4 +84,5 @@ load_bignum(const char *name)
 	sshbuf_free(buf);
 	return ret;
 }
+#endif /* WITH_OPENSSL */
 
diff --git a/regress/unittests/sshkey/common.h b/regress/unittests/sshkey/common.h
index bf7d19dc..f5b6ffa9 100644
--- a/regress/unittests/sshkey/common.h
+++ b/regress/unittests/sshkey/common.h
@@ -11,6 +11,7 @@ struct sshbuf *load_file(const char *name);
 /* Load a text file into a buffer */
 struct sshbuf *load_text_file(const char *name);
 
+#ifdef WITH_OPENSSL
 /* Load a bignum from a file */
 BIGNUM *load_bignum(const char *name);
-
+#endif
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c
index 99b7e21c..336cfbca 100644
--- a/regress/unittests/sshkey/test_file.c
+++ b/regress/unittests/sshkey/test_file.c
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
 #include <openssl/dsa.h>
@@ -26,6 +27,7 @@
 #ifdef OPENSSL_HAS_NISTP256
 # include <openssl/ec.h>
 #endif
+#endif
 
 #include "../test_helper/test_helper.h"
 
@@ -44,14 +46,16 @@ sshkey_file_tests(void)
 {
 	struct sshkey *k1, *k2;
 	struct sshbuf *buf, *pw;
+#ifdef WITH_OPENSSL
 	BIGNUM *a, *b, *c;
+#endif
 	char *cp;
 
 	TEST_START("load passphrase");
 	pw = load_text_file("pw");
 	TEST_DONE();
 
-
+#ifdef WITH_OPENSSL
 	TEST_START("parse RSA from private");
 	buf = load_file("rsa_1");
 	ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@@ -332,6 +336,7 @@ sshkey_file_tests(void)
 
 	sshkey_free(k1);
 #endif /* OPENSSL_HAS_ECC */
+#endif /* WITH_OPENSSL */
 
 	TEST_START("parse Ed25519 from private");
 	buf = load_file("ed25519_1");
diff --git a/regress/unittests/sshkey/test_fuzz.c b/regress/unittests/sshkey/test_fuzz.c
index d3b0c92b..a714e72e 100644
--- a/regress/unittests/sshkey/test_fuzz.c
+++ b/regress/unittests/sshkey/test_fuzz.c
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
 #include <openssl/dsa.h>
@@ -26,6 +27,7 @@
 #ifdef OPENSSL_HAS_NISTP256
 # include <openssl/ec.h>
 #endif
+#endif /* WITH_OPENSSL */
 
 #include "../test_helper/test_helper.h"
 
@@ -104,7 +106,7 @@ sshkey_fuzz_tests(void)
 	struct fuzz *fuzz;
 	int r;
 
-
+#ifdef WITH_OPENSSL
 	TEST_START("fuzz RSA private");
 	buf = load_file("rsa_1");
 	fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf),
@@ -347,6 +349,8 @@ sshkey_fuzz_tests(void)
 	TEST_DONE();
 #endif
 
+#endif /* WITH_OPENSSL */
+
 	TEST_START("fuzz Ed25519 sig");
 	buf = load_file("ed25519_1");
 	ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c
index 1aa608f9..19e20b06 100644
--- a/regress/unittests/sshkey/test_sshkey.c
+++ b/regress/unittests/sshkey/test_sshkey.c
@@ -16,12 +16,14 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
 #include <openssl/dsa.h>
 #if defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256)
 # include <openssl/ec.h>
 #endif
+#endif
 
 #include "../test_helper/test_helper.h"
 
@@ -193,6 +195,7 @@ sshkey_tests(void)
 	sshkey_free(k1);
 	TEST_DONE();
 
+#ifdef WITH_OPENSSL
 	TEST_START("new/free KEY_RSA");
 	k1 = sshkey_new(KEY_RSA);
 	ASSERT_PTR_NE(k1, NULL);
@@ -413,6 +416,7 @@ sshkey_tests(void)
 	sshkey_free(ke);
 #endif
 	sshkey_free(kf);
+#endif /* WITH_OPENSSL */
 
 	TEST_START("certify key");
 	ASSERT_INT_EQ(sshkey_load_public(test_data_file("ed25519_1.pub"),
@@ -457,6 +461,7 @@ sshkey_tests(void)
 	sshbuf_reset(b);
 	TEST_DONE();
 
+#ifdef WITH_OPENSSL
 	TEST_START("sign and verify RSA");
 	k1 = get_private("rsa_1");
 	ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_2.pub"), &k2,
@@ -503,6 +508,7 @@ sshkey_tests(void)
 	sshkey_free(k2);
 	TEST_DONE();
 #endif
+#endif /* WITH_OPENSSL */
 
 	TEST_START("sign and verify ED25519");
 	k1 = get_private("ed25519_1");
@@ -513,6 +519,7 @@ sshkey_tests(void)
 	sshkey_free(k2);
 	TEST_DONE();
 
+#ifdef WITH_OPENSSL
 	TEST_START("nested certificate");
 	ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k1), 0);
 	ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_1.pub"), &k2,
@@ -527,5 +534,6 @@ sshkey_tests(void)
 	sshkey_free(k3);
 	sshbuf_free(b);
 	TEST_DONE();
+#endif /* WITH_OPENSSL */
 
 }
diff --git a/regress/unittests/sshkey/tests.c b/regress/unittests/sshkey/tests.c
index 13f265cd..c3434566 100644
--- a/regress/unittests/sshkey/tests.c
+++ b/regress/unittests/sshkey/tests.c
@@ -7,7 +7,9 @@
 
 #include "includes.h"
 
+#ifdef WITH_OPENSSL
 #include <openssl/evp.h>
+#endif
 
 #include "../test_helper/test_helper.h"
 
@@ -18,8 +20,10 @@ void sshkey_fuzz_tests(void);
 void
 tests(void)
 {
+#ifdef WITH_OPENSSL
 	OpenSSL_add_all_algorithms();
 	ERR_load_CRYPTO_strings();
+#endif
 
 	sshkey_tests();
 	sshkey_file_tests();
diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c
index 866f3495..39d45a89 100644
--- a/regress/unittests/test_helper/test_helper.c
+++ b/regress/unittests/test_helper/test_helper.c
@@ -34,7 +34,9 @@
 #include <unistd.h>
 #include <signal.h>
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
+#endif
 
 #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS)
 # include <vis.h>
@@ -260,6 +262,7 @@ test_subtest_info(const char *fmt, ...)
 	va_end(ap);
 }
 
+#ifdef WITH_OPENSSL
 void
 ssl_err_check(const char *file, int line)
 {
@@ -272,6 +275,7 @@ ssl_err_check(const char *file, int line)
 	    file, line, ERR_error_string(openssl_error, NULL));
 	abort();
 }
+#endif
 
 static const char *
 pred_name(enum test_predicate p)
@@ -314,6 +318,7 @@ test_header(const char *file, int line, const char *a1, const char *a2,
 	    a2 != NULL ? ", " : "", a2 != NULL ? a2 : "");
 }
 
+#ifdef WITH_OPENSSL
 void
 assert_bignum(const char *file, int line, const char *a1, const char *a2,
     const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred)
@@ -326,6 +331,7 @@ assert_bignum(const char *file, int line, const char *a1, const char *a2,
 	fprintf(stderr, "%12s = 0x%s\n", a2, BN_bn2hex(aa2));
 	test_die();
 }
+#endif
 
 void
 assert_string(const char *file, int line, const char *a1, const char *a2,
diff --git a/regress/unittests/test_helper/test_helper.h b/regress/unittests/test_helper/test_helper.h
index 6da0066e..f0a1efb3 100644
--- a/regress/unittests/test_helper/test_helper.h
+++ b/regress/unittests/test_helper/test_helper.h
@@ -27,8 +27,10 @@
 # include <stdint.h>
 #endif
 
+#ifdef WITH_OPENSSL
 #include <openssl/bn.h>
 #include <openssl/err.h>
+#endif
 
 enum test_predicate {
 	TEST_EQ, TEST_NE, TEST_LT, TEST_LE, TEST_GT, TEST_GE
@@ -48,9 +50,11 @@ int test_is_quiet(void);
 void test_subtest_info(const char *fmt, ...)
     __attribute__((format(printf, 1, 2)));
 void ssl_err_check(const char *file, int line);
+#ifdef WITH_OPENSSL
 void assert_bignum(const char *file, int line,
     const char *a1, const char *a2,
     const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred);
+#endif
 void assert_string(const char *file, int line,
     const char *a1, const char *a2,
     const char *aa1, const char *aa2, enum test_predicate pred);
@@ -99,8 +103,10 @@ void assert_u64(const char *file, int line,
 #define TEST_ONERROR(f, c)		set_onerror_func(f, c)
 #define SSL_ERR_CHECK() 		ssl_err_check(__FILE__, __LINE__)
 
+#ifdef WITH_OPENSSL
 #define ASSERT_BIGNUM_EQ(a1, a2) \
 	assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#endif
 #define ASSERT_STRING_EQ(a1, a2) \
 	assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
 #define ASSERT_MEM_EQ(a1, a2, l) \
@@ -132,8 +138,10 @@ void assert_u64(const char *file, int line,
 #define ASSERT_U64_EQ(a1, a2) \
 	assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
 
+#ifdef WITH_OPENSSL
 #define ASSERT_BIGNUM_NE(a1, a2) \
 	assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#endif
 #define ASSERT_STRING_NE(a1, a2) \
 	assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
 #define ASSERT_MEM_NE(a1, a2, l) \
@@ -163,8 +171,10 @@ void assert_u64(const char *file, int line,
 #define ASSERT_U64_NE(a1, a2) \
 	assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
 
+#ifdef WITH_OPENSSL
 #define ASSERT_BIGNUM_LT(a1, a2) \
 	assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#endif
 #define ASSERT_STRING_LT(a1, a2) \
 	assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
 #define ASSERT_MEM_LT(a1, a2, l) \
@@ -250,8 +260,10 @@ void assert_u64(const char *file, int line,
 #define ASSERT_U64_GT(a1, a2) \
 	assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
 
+#ifdef WITH_OPENSSL
 #define ASSERT_BIGNUM_GE(a1, a2) \
 	assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#endif
 #define ASSERT_STRING_GE(a1, a2) \
 	assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
 #define ASSERT_MEM_GE(a1, a2, l) \
-- 
2.17.1



More information about the openssh-unix-dev mailing list