summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/unittests/hostkeys/test_iterate.c19
-rw-r--r--regress/unittests/sshkey/test_file.c4
-rw-r--r--regress/unittests/sshkey/test_fuzz.c4
3 files changed, 21 insertions, 6 deletions
diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c
index 68a70610e..fc095ea49 100644
--- a/regress/unittests/hostkeys/test_iterate.c
+++ b/regress/unittests/hostkeys/test_iterate.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: test_iterate.c,v 1.1 2015/02/16 22:18:34 djm Exp $ */ 1/* $OpenBSD: test_iterate.c,v 1.2 2015/03/04 23:22:35 djm Exp $ */
2/* 2/*
3 * Regress test for hostfile.h hostkeys_foreach() 3 * Regress test for hostfile.h hostkeys_foreach()
4 * 4 *
@@ -54,7 +54,7 @@ check(struct hostkey_foreach_line *l, void *_ctx)
54{ 54{
55 struct cbctx *ctx = (struct cbctx *)_ctx; 55 struct cbctx *ctx = (struct cbctx *)_ctx;
56 const struct expected *expected; 56 const struct expected *expected;
57 const 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;
@@ -87,12 +87,21 @@ check(struct hostkey_foreach_line *l, void *_ctx)
87 expected_status = HKF_STATUS_MATCHED; \ 87 expected_status = HKF_STATUS_MATCHED; \
88 } \ 88 } \
89 } while (0) 89 } while (0)
90 expected_keytype = (parse_key || expected->no_parse_keytype < 0) ?
91 expected->l.keytype : expected->no_parse_keytype;
92
93#ifndef WITH_SSH1
94 if (expected->l.keytype == KEY_RSA1 ||
95 expected->no_parse_keytype == KEY_RSA1) {
96 expected_status = HKF_STATUS_INVALID;
97 expected_keytype = KEY_UNSPEC;
98 parse_key = 0;
99 }
100#endif
90 UPDATE_MATCH_STATUS(match_host_p); 101 UPDATE_MATCH_STATUS(match_host_p);
91 UPDATE_MATCH_STATUS(match_host_s); 102 UPDATE_MATCH_STATUS(match_host_s);
92 UPDATE_MATCH_STATUS(match_ipv4); 103 UPDATE_MATCH_STATUS(match_ipv4);
93 UPDATE_MATCH_STATUS(match_ipv6); 104 UPDATE_MATCH_STATUS(match_ipv6);
94 expected_keytype = (parse_key || expected->no_parse_keytype < 0) ?
95 expected->l.keytype : expected->no_parse_keytype;
96 105
97 ASSERT_PTR_NE(l->path, NULL); /* Don't care about path */ 106 ASSERT_PTR_NE(l->path, NULL); /* Don't care about path */
98 ASSERT_LONG_LONG_EQ(l->linenum, expected->l.linenum); 107 ASSERT_LONG_LONG_EQ(l->linenum, expected->l.linenum);
@@ -132,6 +141,8 @@ prepare_expected(struct expected *expected, size_t n)
132 for (i = 0; i < n; i++) { 141 for (i = 0; i < n; i++) {
133 if (expected[i].key_file == NULL) 142 if (expected[i].key_file == NULL)
134 continue; 143 continue;
144 if (expected[i].l.keytype == KEY_RSA1)
145 continue;
135 ASSERT_INT_EQ(sshkey_load_public( 146 ASSERT_INT_EQ(sshkey_load_public(
136 test_data_file(expected[i].key_file), &expected[i].l.key, 147 test_data_file(expected[i].key_file), &expected[i].l.key,
137 NULL), 0); 148 NULL), 0);
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c
index 9c38a7c61..fa95212bf 100644
--- a/regress/unittests/sshkey/test_file.c
+++ b/regress/unittests/sshkey/test_file.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: test_file.c,v 1.2 2014/12/22 02:15:52 djm Exp $ */ 1/* $OpenBSD: test_file.c,v 1.3 2015/03/04 23:22:35 djm Exp $ */
2/* 2/*
3 * Regress test for sshkey.h key management API 3 * Regress test for sshkey.h key management API
4 * 4 *
@@ -51,6 +51,7 @@ sshkey_file_tests(void)
51 pw = load_text_file("pw"); 51 pw = load_text_file("pw");
52 TEST_DONE(); 52 TEST_DONE();
53 53
54#ifdef WITH_SSH1
54 TEST_START("parse RSA1 from private"); 55 TEST_START("parse RSA1 from private");
55 buf = load_file("rsa1_1"); 56 buf = load_file("rsa1_1");
56 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "rsa1_1", 57 ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "rsa1_1",
@@ -99,6 +100,7 @@ sshkey_file_tests(void)
99 TEST_DONE(); 100 TEST_DONE();
100 101
101 sshkey_free(k1); 102 sshkey_free(k1);
103#endif
102 104
103 TEST_START("parse RSA from private"); 105 TEST_START("parse RSA from private");
104 buf = load_file("rsa_1"); 106 buf = load_file("rsa_1");
diff --git a/regress/unittests/sshkey/test_fuzz.c b/regress/unittests/sshkey/test_fuzz.c
index 14518ce98..1f08a2e43 100644
--- a/regress/unittests/sshkey/test_fuzz.c
+++ b/regress/unittests/sshkey/test_fuzz.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: test_fuzz.c,v 1.3 2015/01/26 06:11:28 djm Exp $ */ 1/* $OpenBSD: test_fuzz.c,v 1.4 2015/03/04 23:22:35 djm Exp $ */
2/* 2/*
3 * Fuzz tests for key parsing 3 * Fuzz tests for key parsing
4 * 4 *
@@ -104,6 +104,7 @@ sshkey_fuzz_tests(void)
104 struct fuzz *fuzz; 104 struct fuzz *fuzz;
105 int r; 105 int r;
106 106
107#ifdef WITH_SSH1
107 TEST_START("fuzz RSA1 private"); 108 TEST_START("fuzz RSA1 private");
108 buf = load_file("rsa1_1"); 109 buf = load_file("rsa1_1");
109 fuzz = fuzz_begin(FUZZ_1_BIT_FLIP | FUZZ_1_BYTE_FLIP | 110 fuzz = fuzz_begin(FUZZ_1_BIT_FLIP | FUZZ_1_BYTE_FLIP |
@@ -147,6 +148,7 @@ sshkey_fuzz_tests(void)
147 sshbuf_free(fuzzed); 148 sshbuf_free(fuzzed);
148 fuzz_cleanup(fuzz); 149 fuzz_cleanup(fuzz);
149 TEST_DONE(); 150 TEST_DONE();
151#endif
150 152
151 TEST_START("fuzz RSA private"); 153 TEST_START("fuzz RSA private");
152 buf = load_file("rsa_1"); 154 buf = load_file("rsa_1");