summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/unittests/bitmap/tests.c4
-rw-r--r--regress/unittests/hostkeys/test_iterate.c28
-rw-r--r--regress/unittests/kex/test_kex.c12
-rw-r--r--regress/unittests/sshbuf/test_sshbuf_getput_crypto.c3
-rw-r--r--regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c8
-rw-r--r--regress/unittests/sshbuf/tests.c2
-rw-r--r--regress/unittests/sshkey/common.c6
-rw-r--r--regress/unittests/sshkey/test_file.c8
-rw-r--r--regress/unittests/sshkey/test_fuzz.c14
-rw-r--r--regress/unittests/sshkey/test_sshkey.c36
-rw-r--r--regress/unittests/sshkey/testdata/ed25519_1_pw12
-rw-r--r--regress/unittests/test_helper/test_helper.c12
-rw-r--r--regress/unittests/test_helper/test_helper.h4
-rw-r--r--regress/unittests/utf8/tests.c2
14 files changed, 120 insertions, 31 deletions
diff --git a/regress/unittests/bitmap/tests.c b/regress/unittests/bitmap/tests.c
index 23025f90a..f66a4ce46 100644
--- a/regress/unittests/bitmap/tests.c
+++ b/regress/unittests/bitmap/tests.c
@@ -16,7 +16,9 @@
16#include <stdlib.h> 16#include <stdlib.h>
17#include <string.h> 17#include <string.h>
18 18
19#ifdef WITH_OPENSSL
19#include <openssl/bn.h> 20#include <openssl/bn.h>
21#endif
20 22
21#include "../test_helper/test_helper.h" 23#include "../test_helper/test_helper.h"
22 24
@@ -27,6 +29,7 @@
27void 29void
28tests(void) 30tests(void)
29{ 31{
32#ifdef WITH_OPENSSL
30 struct bitmap *b; 33 struct bitmap *b;
31 BIGNUM *bn; 34 BIGNUM *bn;
32 size_t len; 35 size_t len;
@@ -131,5 +134,6 @@ tests(void)
131 bitmap_free(b); 134 bitmap_free(b);
132 BN_free(bn); 135 BN_free(bn);
133 TEST_DONE(); 136 TEST_DONE();
137#endif
134} 138}
135 139
diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c
index d6963bd2a..5904121ef 100644
--- a/regress/unittests/hostkeys/test_iterate.c
+++ b/regress/unittests/hostkeys/test_iterate.c
@@ -57,7 +57,7 @@ check(struct hostkey_foreach_line *l, void *_ctx)
57 int parse_key = (ctx->flags & HKF_WANT_PARSE_KEY) != 0; 57 int parse_key = (ctx->flags & HKF_WANT_PARSE_KEY) != 0;
58 const int matching = (ctx->flags & HKF_WANT_MATCH) != 0; 58 const int matching = (ctx->flags & HKF_WANT_MATCH) != 0;
59 u_int expected_status, expected_match; 59 u_int expected_status, expected_match;
60 int expected_keytype; 60 int expected_keytype, skip = 0;
61 61
62 test_subtest_info("entry %zu/%zu, file line %ld", 62 test_subtest_info("entry %zu/%zu, file line %ld",
63 ctx->i + 1, ctx->nexpected, l->linenum); 63 ctx->i + 1, ctx->nexpected, l->linenum);
@@ -92,13 +92,23 @@ check(struct hostkey_foreach_line *l, void *_ctx)
92 92
93#ifndef OPENSSL_HAS_ECC 93#ifndef OPENSSL_HAS_ECC
94 if (expected->l.keytype == KEY_ECDSA || 94 if (expected->l.keytype == KEY_ECDSA ||
95 expected->no_parse_keytype == KEY_ECDSA) { 95 expected->no_parse_keytype == KEY_ECDSA)
96 skip = 1;
97#endif /* OPENSSL_HAS_ECC */
98#ifndef WITH_OPENSSL
99 if (expected->l.keytype == KEY_DSA ||
100 expected->no_parse_keytype == KEY_DSA ||
101 expected->l.keytype == KEY_RSA ||
102 expected->no_parse_keytype == KEY_RSA ||
103 expected->l.keytype == KEY_ECDSA ||
104 expected->no_parse_keytype == KEY_ECDSA)
105 skip = 1;
106#endif /* WITH_OPENSSL */
107 if (skip) {
96 expected_status = HKF_STATUS_INVALID; 108 expected_status = HKF_STATUS_INVALID;
97 expected_keytype = KEY_UNSPEC; 109 expected_keytype = KEY_UNSPEC;
98 parse_key = 0; 110 parse_key = 0;
99 } 111 }
100#endif
101
102 UPDATE_MATCH_STATUS(match_host_p); 112 UPDATE_MATCH_STATUS(match_host_p);
103 UPDATE_MATCH_STATUS(match_host_s); 113 UPDATE_MATCH_STATUS(match_host_s);
104 UPDATE_MATCH_STATUS(match_ipv4); 114 UPDATE_MATCH_STATUS(match_ipv4);
@@ -145,7 +155,15 @@ prepare_expected(struct expected *expected, size_t n)
145#ifndef OPENSSL_HAS_ECC 155#ifndef OPENSSL_HAS_ECC
146 if (expected[i].l.keytype == KEY_ECDSA) 156 if (expected[i].l.keytype == KEY_ECDSA)
147 continue; 157 continue;
148#endif 158#endif /* OPENSSL_HAS_ECC */
159#ifndef WITH_OPENSSL
160 switch (expected[i].l.keytype) {
161 case KEY_RSA:
162 case KEY_DSA:
163 case KEY_ECDSA:
164 continue;
165 }
166#endif /* WITH_OPENSSL */
149 ASSERT_INT_EQ(sshkey_load_public( 167 ASSERT_INT_EQ(sshkey_load_public(
150 test_data_file(expected[i].key_file), &expected[i].l.key, 168 test_data_file(expected[i].key_file), &expected[i].l.key,
151 NULL), 0); 169 NULL), 0);
diff --git a/regress/unittests/kex/test_kex.c b/regress/unittests/kex/test_kex.c
index a860efc02..0e7cd9e07 100644
--- a/regress/unittests/kex/test_kex.c
+++ b/regress/unittests/kex/test_kex.c
@@ -142,13 +142,15 @@ do_kex_with_key(char *kex, int keytype, int bits)
142 sshbuf_free(state); 142 sshbuf_free(state);
143 ASSERT_PTR_NE(server2->kex, NULL); 143 ASSERT_PTR_NE(server2->kex, NULL);
144 /* XXX we need to set the callbacks */ 144 /* XXX we need to set the callbacks */
145#ifdef WITH_OPENSSL
145 server2->kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server; 146 server2->kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server;
146 server2->kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server; 147 server2->kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server;
147 server2->kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 148 server2->kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
148 server2->kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 149 server2->kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
149#ifdef OPENSSL_HAS_ECC 150#ifdef OPENSSL_HAS_ECC
150 server2->kex->kex[KEX_ECDH_SHA2] = kex_gen_server; 151 server2->kex->kex[KEX_ECDH_SHA2] = kex_gen_server;
151#endif 152#endif /* OPENSSL_HAS_ECC */
153#endif /* WITH_OPENSSL */
152 server2->kex->kex[KEX_C25519_SHA256] = kex_gen_server; 154 server2->kex->kex[KEX_C25519_SHA256] = kex_gen_server;
153 server2->kex->load_host_public_key = server->kex->load_host_public_key; 155 server2->kex->load_host_public_key = server->kex->load_host_public_key;
154 server2->kex->load_host_private_key = server->kex->load_host_private_key; 156 server2->kex->load_host_private_key = server->kex->load_host_private_key;
@@ -175,11 +177,13 @@ do_kex_with_key(char *kex, int keytype, int bits)
175static void 177static void
176do_kex(char *kex) 178do_kex(char *kex)
177{ 179{
180#ifdef WITH_OPENSSL
178 do_kex_with_key(kex, KEY_RSA, 2048); 181 do_kex_with_key(kex, KEY_RSA, 2048);
179 do_kex_with_key(kex, KEY_DSA, 1024); 182 do_kex_with_key(kex, KEY_DSA, 1024);
180#ifdef OPENSSL_HAS_ECC 183#ifdef OPENSSL_HAS_ECC
181 do_kex_with_key(kex, KEY_ECDSA, 256); 184 do_kex_with_key(kex, KEY_ECDSA, 256);
182#endif 185#endif /* OPENSSL_HAS_ECC */
186#endif /* WITH_OPENSSL */
183 do_kex_with_key(kex, KEY_ED25519, 256); 187 do_kex_with_key(kex, KEY_ED25519, 256);
184} 188}
185 189
@@ -187,13 +191,15 @@ void
187kex_tests(void) 191kex_tests(void)
188{ 192{
189 do_kex("curve25519-sha256@libssh.org"); 193 do_kex("curve25519-sha256@libssh.org");
194#ifdef WITH_OPENSSL
190#ifdef OPENSSL_HAS_ECC 195#ifdef OPENSSL_HAS_ECC
191 do_kex("ecdh-sha2-nistp256"); 196 do_kex("ecdh-sha2-nistp256");
192 do_kex("ecdh-sha2-nistp384"); 197 do_kex("ecdh-sha2-nistp384");
193 do_kex("ecdh-sha2-nistp521"); 198 do_kex("ecdh-sha2-nistp521");
194#endif 199#endif /* OPENSSL_HAS_ECC */
195 do_kex("diffie-hellman-group-exchange-sha256"); 200 do_kex("diffie-hellman-group-exchange-sha256");
196 do_kex("diffie-hellman-group-exchange-sha1"); 201 do_kex("diffie-hellman-group-exchange-sha1");
197 do_kex("diffie-hellman-group14-sha1"); 202 do_kex("diffie-hellman-group14-sha1");
198 do_kex("diffie-hellman-group1-sha1"); 203 do_kex("diffie-hellman-group1-sha1");
204#endif /* WITH_OPENSSL */
199} 205}
diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
index 5d39e63e1..492b3bdf0 100644
--- a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
+++ b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
@@ -7,6 +7,8 @@
7 7
8#include "includes.h" 8#include "includes.h"
9 9
10#ifdef WITH_OPENSSL
11
10#include <sys/types.h> 12#include <sys/types.h>
11#include <sys/param.h> 13#include <sys/param.h>
12#include <stdio.h> 14#include <stdio.h>
@@ -276,3 +278,4 @@ sshbuf_getput_crypto_tests(void)
276#endif 278#endif
277} 279}
278 280
281#endif /* WITH_OPENSSL */
diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
index ca06bfb00..1ca30be97 100644
--- a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
+++ b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
@@ -32,10 +32,12 @@ static void
32attempt_parse_blob(u_char *blob, size_t len) 32attempt_parse_blob(u_char *blob, size_t len)
33{ 33{
34 struct sshbuf *p1; 34 struct sshbuf *p1;
35#ifdef WITH_OPENSSL
35 BIGNUM *bn; 36 BIGNUM *bn;
36#if defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256) 37#if defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256)
37 EC_KEY *eck; 38 EC_KEY *eck;
38#endif 39#endif /* defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256) */
40#endif /* WITH_OPENSSL */
39 u_char *s; 41 u_char *s;
40 size_t l; 42 size_t l;
41 u_int8_t u8; 43 u_int8_t u8;
@@ -54,6 +56,7 @@ attempt_parse_blob(u_char *blob, size_t len)
54 bzero(s, l); 56 bzero(s, l);
55 free(s); 57 free(s);
56 } 58 }
59#ifdef WITH_OPENSSL
57 bn = NULL; 60 bn = NULL;
58 sshbuf_get_bignum2(p1, &bn); 61 sshbuf_get_bignum2(p1, &bn);
59 BN_clear_free(bn); 62 BN_clear_free(bn);
@@ -62,7 +65,8 @@ attempt_parse_blob(u_char *blob, size_t len)
62 ASSERT_PTR_NE(eck, NULL); 65 ASSERT_PTR_NE(eck, NULL);
63 sshbuf_get_eckey(p1, eck); 66 sshbuf_get_eckey(p1, eck);
64 EC_KEY_free(eck); 67 EC_KEY_free(eck);
65#endif 68#endif /* defined(OPENSSL_HAS_ECC) && defined(OPENSSL_HAS_NISTP256) */
69#endif /* WITH_OPENSSL */
66 sshbuf_free(p1); 70 sshbuf_free(p1);
67} 71}
68 72
diff --git a/regress/unittests/sshbuf/tests.c b/regress/unittests/sshbuf/tests.c
index 1557e4342..29916a10b 100644
--- a/regress/unittests/sshbuf/tests.c
+++ b/regress/unittests/sshbuf/tests.c
@@ -20,7 +20,9 @@ tests(void)
20{ 20{
21 sshbuf_tests(); 21 sshbuf_tests();
22 sshbuf_getput_basic_tests(); 22 sshbuf_getput_basic_tests();
23#ifdef WITH_OPENSSL
23 sshbuf_getput_crypto_tests(); 24 sshbuf_getput_crypto_tests();
25#endif
24 sshbuf_misc_tests(); 26 sshbuf_misc_tests();
25 sshbuf_fuzz_tests(); 27 sshbuf_fuzz_tests();
26 sshbuf_getput_fuzz_tests(); 28 sshbuf_getput_fuzz_tests();
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c
index e63465c47..e21638093 100644
--- a/regress/unittests/sshkey/common.c
+++ b/regress/unittests/sshkey/common.c
@@ -19,13 +19,15 @@
19#include <string.h> 19#include <string.h>
20#include <unistd.h> 20#include <unistd.h>
21 21
22#ifdef WITH_OPENSSL
22#include <openssl/bn.h> 23#include <openssl/bn.h>
23#include <openssl/rsa.h> 24#include <openssl/rsa.h>
24#include <openssl/dsa.h> 25#include <openssl/dsa.h>
25#include <openssl/objects.h> 26#include <openssl/objects.h>
26#ifdef OPENSSL_HAS_NISTP256 27#ifdef OPENSSL_HAS_NISTP256
27# include <openssl/ec.h> 28# include <openssl/ec.h>
28#endif 29#endif /* OPENSSL_HAS_NISTP256 */
30#endif /* WITH_OPENSSL */
29 31
30#include "openbsd-compat/openssl-compat.h" 32#include "openbsd-compat/openssl-compat.h"
31 33
@@ -72,6 +74,7 @@ load_text_file(const char *name)
72 return ret; 74 return ret;
73} 75}
74 76
77#ifdef WITH_OPENSSL
75BIGNUM * 78BIGNUM *
76load_bignum(const char *name) 79load_bignum(const char *name)
77{ 80{
@@ -160,4 +163,5 @@ dsa_priv_key(struct sshkey *k)
160 DSA_get0_key(k->dsa, NULL, &priv_key); 163 DSA_get0_key(k->dsa, NULL, &priv_key);
161 return priv_key; 164 return priv_key;
162} 165}
166#endif /* WITH_OPENSSL */
163 167
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c
index 65610dacc..55627bc12 100644
--- a/regress/unittests/sshkey/test_file.c
+++ b/regress/unittests/sshkey/test_file.c
@@ -19,13 +19,15 @@
19#include <string.h> 19#include <string.h>
20#include <unistd.h> 20#include <unistd.h>
21 21
22#ifdef WITH_OPENSSL
22#include <openssl/bn.h> 23#include <openssl/bn.h>
23#include <openssl/rsa.h> 24#include <openssl/rsa.h>
24#include <openssl/dsa.h> 25#include <openssl/dsa.h>
25#include <openssl/objects.h> 26#include <openssl/objects.h>
26#ifdef OPENSSL_HAS_NISTP256 27#ifdef OPENSSL_HAS_NISTP256
27# include <openssl/ec.h> 28# include <openssl/ec.h>
28#endif 29#endif /* OPENSSL_HAS_NISTP256 */
30#endif /* WITH_OPENSSL */
29 31
30#include "../test_helper/test_helper.h" 32#include "../test_helper/test_helper.h"
31 33
@@ -44,7 +46,9 @@ sshkey_file_tests(void)
44{ 46{
45 struct sshkey *k1, *k2; 47 struct sshkey *k1, *k2;
46 struct sshbuf *buf, *pw; 48 struct sshbuf *buf, *pw;
49#ifdef WITH_OPENSSL
47 BIGNUM *a, *b, *c; 50 BIGNUM *a, *b, *c;
51#endif
48 char *cp; 52 char *cp;
49 53
50 TEST_START("load passphrase"); 54 TEST_START("load passphrase");
@@ -52,6 +56,7 @@ sshkey_file_tests(void)
52 TEST_DONE(); 56 TEST_DONE();
53 57
54 58
59#ifdef WITH_OPENSSL
55 TEST_START("parse RSA from private"); 60 TEST_START("parse RSA from private");
56 buf = load_file("rsa_1"); 61 buf = load_file("rsa_1");
57 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); 62 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@@ -350,6 +355,7 @@ sshkey_file_tests(void)
350 355
351 sshkey_free(k1); 356 sshkey_free(k1);
352#endif /* OPENSSL_HAS_ECC */ 357#endif /* OPENSSL_HAS_ECC */
358#endif /* WITH_OPENSSL */
353 359
354 TEST_START("parse Ed25519 from private"); 360 TEST_START("parse Ed25519 from private");
355 buf = load_file("ed25519_1"); 361 buf = load_file("ed25519_1");
diff --git a/regress/unittests/sshkey/test_fuzz.c b/regress/unittests/sshkey/test_fuzz.c
index 5953de595..1323f8997 100644
--- a/regress/unittests/sshkey/test_fuzz.c
+++ b/regress/unittests/sshkey/test_fuzz.c
@@ -113,7 +113,7 @@ sshkey_fuzz_tests(void)
113 struct fuzz *fuzz; 113 struct fuzz *fuzz;
114 int r, i; 114 int r, i;
115 115
116 116#ifdef WITH_OPENSSL
117 TEST_START("fuzz RSA private"); 117 TEST_START("fuzz RSA private");
118 buf = load_file("rsa_1"); 118 buf = load_file("rsa_1");
119 fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf), 119 fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf),
@@ -246,7 +246,8 @@ sshkey_fuzz_tests(void)
246 sshbuf_free(fuzzed); 246 sshbuf_free(fuzzed);
247 fuzz_cleanup(fuzz); 247 fuzz_cleanup(fuzz);
248 TEST_DONE(); 248 TEST_DONE();
249#endif 249#endif /* OPENSSL_HAS_ECC */
250#endif /* WITH_OPENSSL */
250 251
251 TEST_START("fuzz Ed25519 private"); 252 TEST_START("fuzz Ed25519 private");
252 buf = load_file("ed25519_1"); 253 buf = load_file("ed25519_1");
@@ -270,6 +271,7 @@ sshkey_fuzz_tests(void)
270 fuzz_cleanup(fuzz); 271 fuzz_cleanup(fuzz);
271 TEST_DONE(); 272 TEST_DONE();
272 273
274#ifdef WITH_OPENSSL
273 TEST_START("fuzz RSA public"); 275 TEST_START("fuzz RSA public");
274 buf = load_file("rsa_1"); 276 buf = load_file("rsa_1");
275 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); 277 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@@ -312,7 +314,8 @@ sshkey_fuzz_tests(void)
312 public_fuzz(k1); 314 public_fuzz(k1);
313 sshkey_free(k1); 315 sshkey_free(k1);
314 TEST_DONE(); 316 TEST_DONE();
315#endif 317#endif /* OPENSSL_HAS_ECC */
318#endif /* WITH_OPENSSL */
316 319
317 TEST_START("fuzz Ed25519 public"); 320 TEST_START("fuzz Ed25519 public");
318 buf = load_file("ed25519_1"); 321 buf = load_file("ed25519_1");
@@ -328,6 +331,7 @@ sshkey_fuzz_tests(void)
328 sshkey_free(k1); 331 sshkey_free(k1);
329 TEST_DONE(); 332 TEST_DONE();
330 333
334#ifdef WITH_OPENSSL
331 TEST_START("fuzz RSA sig"); 335 TEST_START("fuzz RSA sig");
332 buf = load_file("rsa_1"); 336 buf = load_file("rsa_1");
333 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); 337 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@@ -368,7 +372,8 @@ sshkey_fuzz_tests(void)
368 sig_fuzz(k1, NULL); 372 sig_fuzz(k1, NULL);
369 sshkey_free(k1); 373 sshkey_free(k1);
370 TEST_DONE(); 374 TEST_DONE();
371#endif 375#endif /* OPENSSL_HAS_ECC */
376#endif /* WITH_OPENSSL */
372 377
373 TEST_START("fuzz Ed25519 sig"); 378 TEST_START("fuzz Ed25519 sig");
374 buf = load_file("ed25519_1"); 379 buf = load_file("ed25519_1");
@@ -379,5 +384,6 @@ sshkey_fuzz_tests(void)
379 TEST_DONE(); 384 TEST_DONE();
380 385
381/* XXX fuzz decoded new-format blobs too */ 386/* XXX fuzz decoded new-format blobs too */
387/* XXX fuzz XMSS too */
382 388
383} 389}
diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c
index d003483f5..42395b8db 100644
--- a/regress/unittests/sshkey/test_sshkey.c
+++ b/regress/unittests/sshkey/test_sshkey.c
@@ -50,6 +50,7 @@ put_opt(struct sshbuf *b, const char *name, const char *value)
50 sshbuf_free(sect); 50 sshbuf_free(sect);
51} 51}
52 52
53#ifdef WITH_OPENSSL
53static void 54static void
54build_cert(struct sshbuf *b, struct sshkey *k, const char *type, 55build_cert(struct sshbuf *b, struct sshkey *k, const char *type,
55 struct sshkey *sign_key, struct sshkey *ca_key, 56 struct sshkey *sign_key, struct sshkey *ca_key,
@@ -110,6 +111,7 @@ build_cert(struct sshbuf *b, struct sshkey *k, const char *type,
110 sshbuf_free(principals); 111 sshbuf_free(principals);
111 sshbuf_free(pk); 112 sshbuf_free(pk);
112} 113}
114#endif /* WITH_OPENSSL */
113 115
114static void 116static void
115signature_test(struct sshkey *k, struct sshkey *bad, const char *sig_alg, 117signature_test(struct sshkey *k, struct sshkey *bad, const char *sig_alg,
@@ -176,10 +178,13 @@ get_private(const char *n)
176void 178void
177sshkey_tests(void) 179sshkey_tests(void)
178{ 180{
179 struct sshkey *k1, *k2, *k3, *k4, *kr, *kd, *kf; 181 struct sshkey *k1, *k2, *k3, *kf;
182#ifdef WITH_OPENSSL
183 struct sshkey *k4, *kr, *kd;
180#ifdef OPENSSL_HAS_ECC 184#ifdef OPENSSL_HAS_ECC
181 struct sshkey *ke; 185 struct sshkey *ke;
182#endif 186#endif /* OPENSSL_HAS_ECC */
187#endif /* WITH_OPENSSL */
183 struct sshbuf *b; 188 struct sshbuf *b;
184 189
185 TEST_START("new invalid"); 190 TEST_START("new invalid");
@@ -193,6 +198,7 @@ sshkey_tests(void)
193 sshkey_free(k1); 198 sshkey_free(k1);
194 TEST_DONE(); 199 TEST_DONE();
195 200
201#ifdef WITH_OPENSSL
196 TEST_START("new/free KEY_RSA"); 202 TEST_START("new/free KEY_RSA");
197 k1 = sshkey_new(KEY_RSA); 203 k1 = sshkey_new(KEY_RSA);
198 ASSERT_PTR_NE(k1, NULL); 204 ASSERT_PTR_NE(k1, NULL);
@@ -281,7 +287,8 @@ sshkey_tests(void)
281 ASSERT_PTR_NE(EC_KEY_get0_public_key(ke->ecdsa), NULL); 287 ASSERT_PTR_NE(EC_KEY_get0_public_key(ke->ecdsa), NULL);
282 ASSERT_PTR_NE(EC_KEY_get0_private_key(ke->ecdsa), NULL); 288 ASSERT_PTR_NE(EC_KEY_get0_private_key(ke->ecdsa), NULL);
283 TEST_DONE(); 289 TEST_DONE();
284#endif 290#endif /* OPENSSL_HAS_ECC */
291#endif /* WITH_OPENSSL */
285 292
286 TEST_START("generate KEY_ED25519"); 293 TEST_START("generate KEY_ED25519");
287 ASSERT_INT_EQ(sshkey_generate(KEY_ED25519, 256, &kf), 0); 294 ASSERT_INT_EQ(sshkey_generate(KEY_ED25519, 256, &kf), 0);
@@ -291,6 +298,7 @@ sshkey_tests(void)
291 ASSERT_PTR_NE(kf->ed25519_sk, NULL); 298 ASSERT_PTR_NE(kf->ed25519_sk, NULL);
292 TEST_DONE(); 299 TEST_DONE();
293 300
301#ifdef WITH_OPENSSL
294 TEST_START("demote KEY_RSA"); 302 TEST_START("demote KEY_RSA");
295 ASSERT_INT_EQ(sshkey_from_private(kr, &k1), 0); 303 ASSERT_INT_EQ(sshkey_from_private(kr, &k1), 0);
296 ASSERT_PTR_NE(k1, NULL); 304 ASSERT_PTR_NE(k1, NULL);
@@ -338,7 +346,8 @@ sshkey_tests(void)
338 ASSERT_INT_EQ(sshkey_equal(ke, k1), 1); 346 ASSERT_INT_EQ(sshkey_equal(ke, k1), 1);
339 sshkey_free(k1); 347 sshkey_free(k1);
340 TEST_DONE(); 348 TEST_DONE();
341#endif 349#endif /* OPENSSL_HAS_ECC */
350#endif /* WITH_OPENSSL */
342 351
343 TEST_START("demote KEY_ED25519"); 352 TEST_START("demote KEY_ED25519");
344 ASSERT_INT_EQ(sshkey_from_private(kf, &k1), 0); 353 ASSERT_INT_EQ(sshkey_from_private(kf, &k1), 0);
@@ -354,17 +363,20 @@ sshkey_tests(void)
354 sshkey_free(k1); 363 sshkey_free(k1);
355 TEST_DONE(); 364 TEST_DONE();
356 365
366#ifdef WITH_OPENSSL
357 TEST_START("equal mismatched key types"); 367 TEST_START("equal mismatched key types");
358 ASSERT_INT_EQ(sshkey_equal(kd, kr), 0); 368 ASSERT_INT_EQ(sshkey_equal(kd, kr), 0);
359#ifdef OPENSSL_HAS_ECC 369#ifdef OPENSSL_HAS_ECC
360 ASSERT_INT_EQ(sshkey_equal(kd, ke), 0); 370 ASSERT_INT_EQ(sshkey_equal(kd, ke), 0);
361 ASSERT_INT_EQ(sshkey_equal(kr, ke), 0); 371 ASSERT_INT_EQ(sshkey_equal(kr, ke), 0);
362 ASSERT_INT_EQ(sshkey_equal(ke, kf), 0); 372 ASSERT_INT_EQ(sshkey_equal(ke, kf), 0);
363#endif 373#endif /* OPENSSL_HAS_ECC */
364 ASSERT_INT_EQ(sshkey_equal(kd, kf), 0); 374 ASSERT_INT_EQ(sshkey_equal(kd, kf), 0);
365 TEST_DONE(); 375 TEST_DONE();
376#endif /* WITH_OPENSSL */
366 377
367 TEST_START("equal different keys"); 378 TEST_START("equal different keys");
379#ifdef WITH_OPENSSL
368 ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &k1), 0); 380 ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &k1), 0);
369 ASSERT_INT_EQ(sshkey_equal(kr, k1), 0); 381 ASSERT_INT_EQ(sshkey_equal(kr, k1), 0);
370 sshkey_free(k1); 382 sshkey_free(k1);
@@ -375,17 +387,20 @@ sshkey_tests(void)
375 ASSERT_INT_EQ(sshkey_generate(KEY_ECDSA, 256, &k1), 0); 387 ASSERT_INT_EQ(sshkey_generate(KEY_ECDSA, 256, &k1), 0);
376 ASSERT_INT_EQ(sshkey_equal(ke, k1), 0); 388 ASSERT_INT_EQ(sshkey_equal(ke, k1), 0);
377 sshkey_free(k1); 389 sshkey_free(k1);
378#endif 390#endif /* OPENSSL_HAS_ECC */
391#endif /* WITH_OPENSSL */
379 ASSERT_INT_EQ(sshkey_generate(KEY_ED25519, 256, &k1), 0); 392 ASSERT_INT_EQ(sshkey_generate(KEY_ED25519, 256, &k1), 0);
380 ASSERT_INT_EQ(sshkey_equal(kf, k1), 0); 393 ASSERT_INT_EQ(sshkey_equal(kf, k1), 0);
381 sshkey_free(k1); 394 sshkey_free(k1);
382 TEST_DONE(); 395 TEST_DONE();
383 396
397#ifdef WITH_OPENSSL
384 sshkey_free(kr); 398 sshkey_free(kr);
385 sshkey_free(kd); 399 sshkey_free(kd);
386#ifdef OPENSSL_HAS_ECC 400#ifdef OPENSSL_HAS_ECC
387 sshkey_free(ke); 401 sshkey_free(ke);
388#endif 402#endif /* OPENSSL_HAS_ECC */
403#endif /* WITH_OPENSSL */
389 sshkey_free(kf); 404 sshkey_free(kf);
390 405
391 TEST_START("certify key"); 406 TEST_START("certify key");
@@ -434,6 +449,7 @@ sshkey_tests(void)
434 sshbuf_reset(b); 449 sshbuf_reset(b);
435 TEST_DONE(); 450 TEST_DONE();
436 451
452#ifdef WITH_OPENSSL
437 TEST_START("sign and verify RSA"); 453 TEST_START("sign and verify RSA");
438 k1 = get_private("rsa_1"); 454 k1 = get_private("rsa_1");
439 ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_2.pub"), &k2, 455 ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_2.pub"), &k2,
@@ -479,7 +495,8 @@ sshkey_tests(void)
479 sshkey_free(k1); 495 sshkey_free(k1);
480 sshkey_free(k2); 496 sshkey_free(k2);
481 TEST_DONE(); 497 TEST_DONE();
482#endif 498#endif /* OPENSSL_HAS_ECC */
499#endif /* WITH_OPENSSL */
483 500
484 TEST_START("sign and verify ED25519"); 501 TEST_START("sign and verify ED25519");
485 k1 = get_private("ed25519_1"); 502 k1 = get_private("ed25519_1");
@@ -490,6 +507,7 @@ sshkey_tests(void)
490 sshkey_free(k2); 507 sshkey_free(k2);
491 TEST_DONE(); 508 TEST_DONE();
492 509
510#ifdef WITH_OPENSSL
493 TEST_START("nested certificate"); 511 TEST_START("nested certificate");
494 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k1), 0); 512 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k1), 0);
495 ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_1.pub"), &k2, 513 ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_1.pub"), &k2,
@@ -504,5 +522,5 @@ sshkey_tests(void)
504 sshkey_free(k3); 522 sshkey_free(k3);
505 sshbuf_free(b); 523 sshbuf_free(b);
506 TEST_DONE(); 524 TEST_DONE();
507 525#endif /* WITH_OPENSSL */
508} 526}
diff --git a/regress/unittests/sshkey/testdata/ed25519_1_pw b/regress/unittests/sshkey/testdata/ed25519_1_pw
index c3b7ae7f8..da94d2b8e 100644
--- a/regress/unittests/sshkey/testdata/ed25519_1_pw
+++ b/regress/unittests/sshkey/testdata/ed25519_1_pw
@@ -1,8 +1,8 @@
1-----BEGIN OPENSSH PRIVATE KEY----- 1-----BEGIN OPENSSH PRIVATE KEY-----
2b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABCus+kaow 2b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABDKT56mBA
3AUjHphacvRp98dAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIFOG6kY7Rf4UtCFv 3tXIMsWqmuuA2gdAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIFOG6kY7Rf4UtCFv
4PwKgo/BztXck2xC4a2WyA34XtIwZAAAAoJaqqgiYQuElraJAmYOm7Tb4nJ3eI4oj9mQ52M 4PwKgo/BztXck2xC4a2WyA34XtIwZAAAAoC13U47yfUOSZJePNUAwWXuFOk3aOKwPM5PMvK
5/Yd+ION2Ur1v8BDewpDX+LHEYgKHo3Mlmcn2UyF+QJ+7xUCW7QCtk/4szrJzw74DlEl6mH 50zwRnMZZjgn+tsMAYPwhsT3Mx3h5QzvVGFyFEqsiK7j4vAotD+LVQeBN5TwWbUBx4lnoGs
6T8PT/f/av7PpECBD/YD3NoDlB9OWm/Q4sHcxfBEKfTGD7s2Onn71HgrdEOPqd4Sj/IQigR 63iAfYVDakO/gNvVBDDGOqv5kdCc4cgn5HacjHQLKOAx6KzHe7JFn7uCywMdVVQjlpI6LHb
7drfjtXEMlD32k9n3dd2eS9x7AHWYaGFEMkOcY= 7mHkaKiVX/C2oiRnsoe17HZ8Fxyt3vd1qNM8BE=
8-----END OPENSSH PRIVATE KEY----- 8-----END OPENSSH PRIVATE KEY-----
diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c
index 127e76c2b..9014ce8e4 100644
--- a/regress/unittests/test_helper/test_helper.c
+++ b/regress/unittests/test_helper/test_helper.c
@@ -23,6 +23,7 @@
23#include <sys/param.h> 23#include <sys/param.h>
24#include <sys/uio.h> 24#include <sys/uio.h>
25 25
26#include <stdarg.h>
26#include <fcntl.h> 27#include <fcntl.h>
27#include <stdio.h> 28#include <stdio.h>
28#ifdef HAVE_STDINT_H 29#ifdef HAVE_STDINT_H
@@ -34,8 +35,10 @@
34#include <unistd.h> 35#include <unistd.h>
35#include <signal.h> 36#include <signal.h>
36 37
38#ifdef WITH_OPENSSL
37#include <openssl/bn.h> 39#include <openssl/bn.h>
38#include <openssl/err.h> 40#include <openssl/err.h>
41#endif
39 42
40#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS) 43#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS)
41# include <vis.h> 44# include <vis.h>
@@ -126,7 +129,9 @@ main(int argc, char **argv)
126 int ch; 129 int ch;
127 130
128 seed_rng(); 131 seed_rng();
132#ifdef WITH_OPENSSL
129 ERR_load_CRYPTO_strings(); 133 ERR_load_CRYPTO_strings();
134#endif
130 135
131 /* Handle systems without __progname */ 136 /* Handle systems without __progname */
132 if (__progname == NULL) { 137 if (__progname == NULL) {
@@ -287,6 +292,7 @@ test_subtest_info(const char *fmt, ...)
287void 292void
288ssl_err_check(const char *file, int line) 293ssl_err_check(const char *file, int line)
289{ 294{
295#ifdef WITH_OPENSSL
290 long openssl_error = ERR_get_error(); 296 long openssl_error = ERR_get_error();
291 297
292 if (openssl_error == 0) 298 if (openssl_error == 0)
@@ -294,6 +300,10 @@ ssl_err_check(const char *file, int line)
294 300
295 fprintf(stderr, "\n%s:%d: uncaught OpenSSL error: %s", 301 fprintf(stderr, "\n%s:%d: uncaught OpenSSL error: %s",
296 file, line, ERR_error_string(openssl_error, NULL)); 302 file, line, ERR_error_string(openssl_error, NULL));
303#else /* WITH_OPENSSL */
304 fprintf(stderr, "\n%s:%d: uncaught OpenSSL error ",
305 file, line);
306#endif /* WITH_OPENSSL */
297 abort(); 307 abort();
298} 308}
299 309
@@ -338,6 +348,7 @@ test_header(const char *file, int line, const char *a1, const char *a2,
338 a2 != NULL ? ", " : "", a2 != NULL ? a2 : ""); 348 a2 != NULL ? ", " : "", a2 != NULL ? a2 : "");
339} 349}
340 350
351#ifdef WITH_OPENSSL
341void 352void
342assert_bignum(const char *file, int line, const char *a1, const char *a2, 353assert_bignum(const char *file, int line, const char *a1, const char *a2,
343 const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred) 354 const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred)
@@ -350,6 +361,7 @@ assert_bignum(const char *file, int line, const char *a1, const char *a2,
350 fprintf(stderr, "%12s = 0x%s\n", a2, BN_bn2hex(aa2)); 361 fprintf(stderr, "%12s = 0x%s\n", a2, BN_bn2hex(aa2));
351 test_die(); 362 test_die();
352} 363}
364#endif
353 365
354void 366void
355assert_string(const char *file, int line, const char *a1, const char *a2, 367assert_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 1f893c8dd..66302201c 100644
--- a/regress/unittests/test_helper/test_helper.h
+++ b/regress/unittests/test_helper/test_helper.h
@@ -27,8 +27,10 @@
27# include <stdint.h> 27# include <stdint.h>
28#endif 28#endif
29 29
30#ifdef WITH_OPENSSL
30#include <openssl/bn.h> 31#include <openssl/bn.h>
31#include <openssl/err.h> 32#include <openssl/err.h>
33#endif
32 34
33enum test_predicate { 35enum test_predicate {
34 TEST_EQ, TEST_NE, TEST_LT, TEST_LE, TEST_GT, TEST_GE 36 TEST_EQ, TEST_NE, TEST_LT, TEST_LE, TEST_GT, TEST_GE
@@ -50,9 +52,11 @@ int test_is_slow(void);
50void test_subtest_info(const char *fmt, ...) 52void test_subtest_info(const char *fmt, ...)
51 __attribute__((format(printf, 1, 2))); 53 __attribute__((format(printf, 1, 2)));
52void ssl_err_check(const char *file, int line); 54void ssl_err_check(const char *file, int line);
55#ifdef WITH_OPENSSL
53void assert_bignum(const char *file, int line, 56void assert_bignum(const char *file, int line,
54 const char *a1, const char *a2, 57 const char *a1, const char *a2,
55 const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred); 58 const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred);
59#endif
56void assert_string(const char *file, int line, 60void assert_string(const char *file, int line,
57 const char *a1, const char *a2, 61 const char *a1, const char *a2,
58 const char *aa1, const char *aa2, enum test_predicate pred); 62 const char *aa1, const char *aa2, enum test_predicate pred);
diff --git a/regress/unittests/utf8/tests.c b/regress/unittests/utf8/tests.c
index f0bbca509..8cf524ddb 100644
--- a/regress/unittests/utf8/tests.c
+++ b/regress/unittests/utf8/tests.c
@@ -9,7 +9,9 @@
9#include "includes.h" 9#include "includes.h"
10 10
11#include <locale.h> 11#include <locale.h>
12#include <stdarg.h>
12#include <string.h> 13#include <string.h>
14#include <stdio.h>
13 15
14#include "../test_helper/test_helper.h" 16#include "../test_helper/test_helper.h"
15 17