diff options
author | Colin Watson <cjwatson@debian.org> | 2018-10-19 21:29:01 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-10-20 22:54:15 +0100 |
commit | d80ebbf028196b2478beebf5a290b97f35e1eed9 (patch) | |
tree | 6666a5484923a26738675ff27a6186cfe15d4cad /regress/unittests | |
parent | 4f5bbf3f11efeec65bbd56464b20a19bd250e5cc (diff) | |
parent | 1d2a55436d4b556269f42ad5f7e16608b5a8ed74 (diff) |
New upstream release (7.9p1)
Diffstat (limited to 'regress/unittests')
-rw-r--r-- | regress/unittests/sshkey/common.c | 81 | ||||
-rw-r--r-- | regress/unittests/sshkey/common.h | 11 | ||||
-rwxr-xr-x | regress/unittests/sshkey/mktestdata.sh | 14 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_file.c | 32 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_sshkey.c | 58 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha1 | 15 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha1-cert.pub | 1 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha1.pub | 1 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha512 | 15 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha512-cert.pub | 1 | ||||
-rw-r--r-- | regress/unittests/sshkey/testdata/rsa_1_sha512.pub | 1 | ||||
-rw-r--r-- | regress/unittests/test_helper/fuzz.c | 8 | ||||
-rw-r--r-- | regress/unittests/test_helper/test_helper.c | 3 |
13 files changed, 183 insertions, 58 deletions
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c index b598f05cb..e63465c47 100644 --- a/regress/unittests/sshkey/common.c +++ b/regress/unittests/sshkey/common.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: common.c,v 1.2 2015/01/08 13:10:58 djm Exp $ */ | 1 | /* $OpenBSD: common.c,v 1.3 2018/09/13 09:03:20 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Helpers for key API tests | 3 | * Helpers for key API tests |
4 | * | 4 | * |
@@ -27,6 +27,8 @@ | |||
27 | # include <openssl/ec.h> | 27 | # include <openssl/ec.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include "openbsd-compat/openssl-compat.h" | ||
31 | |||
30 | #include "../test_helper/test_helper.h" | 32 | #include "../test_helper/test_helper.h" |
31 | 33 | ||
32 | #include "ssherr.h" | 34 | #include "ssherr.h" |
@@ -82,3 +84,80 @@ load_bignum(const char *name) | |||
82 | return ret; | 84 | return ret; |
83 | } | 85 | } |
84 | 86 | ||
87 | const BIGNUM * | ||
88 | rsa_n(struct sshkey *k) | ||
89 | { | ||
90 | const BIGNUM *n = NULL; | ||
91 | |||
92 | ASSERT_PTR_NE(k, NULL); | ||
93 | ASSERT_PTR_NE(k->rsa, NULL); | ||
94 | RSA_get0_key(k->rsa, &n, NULL, NULL); | ||
95 | return n; | ||
96 | } | ||
97 | |||
98 | const BIGNUM * | ||
99 | rsa_e(struct sshkey *k) | ||
100 | { | ||
101 | const BIGNUM *e = NULL; | ||
102 | |||
103 | ASSERT_PTR_NE(k, NULL); | ||
104 | ASSERT_PTR_NE(k->rsa, NULL); | ||
105 | RSA_get0_key(k->rsa, NULL, &e, NULL); | ||
106 | return e; | ||
107 | } | ||
108 | |||
109 | const BIGNUM * | ||
110 | rsa_p(struct sshkey *k) | ||
111 | { | ||
112 | const BIGNUM *p = NULL; | ||
113 | |||
114 | ASSERT_PTR_NE(k, NULL); | ||
115 | ASSERT_PTR_NE(k->rsa, NULL); | ||
116 | RSA_get0_factors(k->rsa, &p, NULL); | ||
117 | return p; | ||
118 | } | ||
119 | |||
120 | const BIGNUM * | ||
121 | rsa_q(struct sshkey *k) | ||
122 | { | ||
123 | const BIGNUM *q = NULL; | ||
124 | |||
125 | ASSERT_PTR_NE(k, NULL); | ||
126 | ASSERT_PTR_NE(k->rsa, NULL); | ||
127 | RSA_get0_factors(k->rsa, NULL, &q); | ||
128 | return q; | ||
129 | } | ||
130 | |||
131 | const BIGNUM * | ||
132 | dsa_g(struct sshkey *k) | ||
133 | { | ||
134 | const BIGNUM *g = NULL; | ||
135 | |||
136 | ASSERT_PTR_NE(k, NULL); | ||
137 | ASSERT_PTR_NE(k->dsa, NULL); | ||
138 | DSA_get0_pqg(k->dsa, NULL, NULL, &g); | ||
139 | return g; | ||
140 | } | ||
141 | |||
142 | const BIGNUM * | ||
143 | dsa_pub_key(struct sshkey *k) | ||
144 | { | ||
145 | const BIGNUM *pub_key = NULL; | ||
146 | |||
147 | ASSERT_PTR_NE(k, NULL); | ||
148 | ASSERT_PTR_NE(k->dsa, NULL); | ||
149 | DSA_get0_key(k->dsa, &pub_key, NULL); | ||
150 | return pub_key; | ||
151 | } | ||
152 | |||
153 | const BIGNUM * | ||
154 | dsa_priv_key(struct sshkey *k) | ||
155 | { | ||
156 | const BIGNUM *priv_key = NULL; | ||
157 | |||
158 | ASSERT_PTR_NE(k, NULL); | ||
159 | ASSERT_PTR_NE(k->dsa, NULL); | ||
160 | DSA_get0_key(k->dsa, NULL, &priv_key); | ||
161 | return priv_key; | ||
162 | } | ||
163 | |||
diff --git a/regress/unittests/sshkey/common.h b/regress/unittests/sshkey/common.h index bf7d19dce..7a514fdc8 100644 --- a/regress/unittests/sshkey/common.h +++ b/regress/unittests/sshkey/common.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: common.h,v 1.1 2014/06/24 01:14:18 djm Exp $ */ | 1 | /* $OpenBSD: common.h,v 1.2 2018/09/13 09:03:20 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Helpers for key API tests | 3 | * Helpers for key API tests |
4 | * | 4 | * |
@@ -14,3 +14,12 @@ struct sshbuf *load_text_file(const char *name); | |||
14 | /* Load a bignum from a file */ | 14 | /* Load a bignum from a file */ |
15 | BIGNUM *load_bignum(const char *name); | 15 | BIGNUM *load_bignum(const char *name); |
16 | 16 | ||
17 | /* Accessors for key components */ | ||
18 | const BIGNUM *rsa_n(struct sshkey *k); | ||
19 | const BIGNUM *rsa_e(struct sshkey *k); | ||
20 | const BIGNUM *rsa_p(struct sshkey *k); | ||
21 | const BIGNUM *rsa_q(struct sshkey *k); | ||
22 | const BIGNUM *dsa_g(struct sshkey *k); | ||
23 | const BIGNUM *dsa_pub_key(struct sshkey *k); | ||
24 | const BIGNUM *dsa_priv_key(struct sshkey *k); | ||
25 | |||
diff --git a/regress/unittests/sshkey/mktestdata.sh b/regress/unittests/sshkey/mktestdata.sh index 8047bc62f..93da34c64 100755 --- a/regress/unittests/sshkey/mktestdata.sh +++ b/regress/unittests/sshkey/mktestdata.sh | |||
@@ -1,5 +1,5 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # $OpenBSD: mktestdata.sh,v 1.6 2017/04/30 23:33:48 djm Exp $ | 2 | # $OpenBSD: mktestdata.sh,v 1.7 2018/09/12 01:36:45 djm Exp $ |
3 | 3 | ||
4 | PW=mekmitasdigoat | 4 | PW=mekmitasdigoat |
5 | 5 | ||
@@ -128,6 +128,18 @@ ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ | |||
128 | -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ | 128 | -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ |
129 | -V 19990101:20110101 -z 4 ed25519_1.pub | 129 | -V 19990101:20110101 -z 4 ed25519_1.pub |
130 | 130 | ||
131 | # Make a few RSA variant signature too. | ||
132 | cp rsa_1 rsa_1_sha1 | ||
133 | cp rsa_1 rsa_1_sha512 | ||
134 | cp rsa_1.pub rsa_1_sha1.pub | ||
135 | cp rsa_1.pub rsa_1_sha512.pub | ||
136 | ssh-keygen -s rsa_2 -I hugo -n user1,user2 -t ssh-rsa \ | ||
137 | -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ | ||
138 | -V 19990101:20110101 -z 1 rsa_1_sha1.pub | ||
139 | ssh-keygen -s rsa_2 -I hugo -n user1,user2 -t rsa-sha2-512 \ | ||
140 | -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ | ||
141 | -V 19990101:20110101 -z 1 rsa_1_sha512.pub | ||
142 | |||
131 | ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ | 143 | ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ |
132 | -V 19990101:20110101 -z 5 rsa_1.pub | 144 | -V 19990101:20110101 -z 5 rsa_1.pub |
133 | ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ | 145 | ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ |
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c index 99b7e21c0..65610dacc 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.6 2017/04/30 23:33:48 djm Exp $ */ | 1 | /* $OpenBSD: test_file.c,v 1.8 2018/09/13 09:03:20 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -60,9 +60,9 @@ sshkey_file_tests(void) | |||
60 | a = load_bignum("rsa_1.param.n"); | 60 | a = load_bignum("rsa_1.param.n"); |
61 | b = load_bignum("rsa_1.param.p"); | 61 | b = load_bignum("rsa_1.param.p"); |
62 | c = load_bignum("rsa_1.param.q"); | 62 | c = load_bignum("rsa_1.param.q"); |
63 | ASSERT_BIGNUM_EQ(k1->rsa->n, a); | 63 | ASSERT_BIGNUM_EQ(rsa_n(k1), a); |
64 | ASSERT_BIGNUM_EQ(k1->rsa->p, b); | 64 | ASSERT_BIGNUM_EQ(rsa_p(k1), b); |
65 | ASSERT_BIGNUM_EQ(k1->rsa->q, c); | 65 | ASSERT_BIGNUM_EQ(rsa_q(k1), c); |
66 | BN_free(a); | 66 | BN_free(a); |
67 | BN_free(b); | 67 | BN_free(b); |
68 | BN_free(c); | 68 | BN_free(c); |
@@ -105,6 +105,24 @@ sshkey_file_tests(void) | |||
105 | sshkey_free(k2); | 105 | sshkey_free(k2); |
106 | TEST_DONE(); | 106 | TEST_DONE(); |
107 | 107 | ||
108 | TEST_START("load RSA cert with SHA1 signature"); | ||
109 | ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha1"), &k2), 0); | ||
110 | ASSERT_PTR_NE(k2, NULL); | ||
111 | ASSERT_INT_EQ(k2->type, KEY_RSA_CERT); | ||
112 | ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1); | ||
113 | ASSERT_STRING_EQ(k2->cert->signature_type, "ssh-rsa"); | ||
114 | sshkey_free(k2); | ||
115 | TEST_DONE(); | ||
116 | |||
117 | TEST_START("load RSA cert with SHA512 signature"); | ||
118 | ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha512"), &k2), 0); | ||
119 | ASSERT_PTR_NE(k2, NULL); | ||
120 | ASSERT_INT_EQ(k2->type, KEY_RSA_CERT); | ||
121 | ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1); | ||
122 | ASSERT_STRING_EQ(k2->cert->signature_type, "rsa-sha2-512"); | ||
123 | sshkey_free(k2); | ||
124 | TEST_DONE(); | ||
125 | |||
108 | TEST_START("load RSA cert"); | 126 | TEST_START("load RSA cert"); |
109 | ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k2), 0); | 127 | ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k2), 0); |
110 | ASSERT_PTR_NE(k2, NULL); | 128 | ASSERT_PTR_NE(k2, NULL); |
@@ -151,9 +169,9 @@ sshkey_file_tests(void) | |||
151 | a = load_bignum("dsa_1.param.g"); | 169 | a = load_bignum("dsa_1.param.g"); |
152 | b = load_bignum("dsa_1.param.priv"); | 170 | b = load_bignum("dsa_1.param.priv"); |
153 | c = load_bignum("dsa_1.param.pub"); | 171 | c = load_bignum("dsa_1.param.pub"); |
154 | ASSERT_BIGNUM_EQ(k1->dsa->g, a); | 172 | ASSERT_BIGNUM_EQ(dsa_g(k1), a); |
155 | ASSERT_BIGNUM_EQ(k1->dsa->priv_key, b); | 173 | ASSERT_BIGNUM_EQ(dsa_priv_key(k1), b); |
156 | ASSERT_BIGNUM_EQ(k1->dsa->pub_key, c); | 174 | ASSERT_BIGNUM_EQ(dsa_pub_key(k1), c); |
157 | BN_free(a); | 175 | BN_free(a); |
158 | BN_free(b); | 176 | BN_free(b); |
159 | BN_free(c); | 177 | BN_free(c); |
diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c index 72367bde7..47a03fad4 100644 --- a/regress/unittests/sshkey/test_sshkey.c +++ b/regress/unittests/sshkey/test_sshkey.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: test_sshkey.c,v 1.14 2018/07/13 02:13:19 djm Exp $ */ | 1 | /* $OpenBSD: test_sshkey.c,v 1.17 2018/09/13 09:03:20 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -197,9 +197,6 @@ sshkey_tests(void) | |||
197 | k1 = sshkey_new(KEY_RSA); | 197 | k1 = sshkey_new(KEY_RSA); |
198 | ASSERT_PTR_NE(k1, NULL); | 198 | ASSERT_PTR_NE(k1, NULL); |
199 | ASSERT_PTR_NE(k1->rsa, NULL); | 199 | ASSERT_PTR_NE(k1->rsa, NULL); |
200 | ASSERT_PTR_NE(k1->rsa->n, NULL); | ||
201 | ASSERT_PTR_NE(k1->rsa->e, NULL); | ||
202 | ASSERT_PTR_EQ(k1->rsa->p, NULL); | ||
203 | sshkey_free(k1); | 200 | sshkey_free(k1); |
204 | TEST_DONE(); | 201 | TEST_DONE(); |
205 | 202 | ||
@@ -207,8 +204,6 @@ sshkey_tests(void) | |||
207 | k1 = sshkey_new(KEY_DSA); | 204 | k1 = sshkey_new(KEY_DSA); |
208 | ASSERT_PTR_NE(k1, NULL); | 205 | ASSERT_PTR_NE(k1, NULL); |
209 | ASSERT_PTR_NE(k1->dsa, NULL); | 206 | ASSERT_PTR_NE(k1->dsa, NULL); |
210 | ASSERT_PTR_NE(k1->dsa->g, NULL); | ||
211 | ASSERT_PTR_EQ(k1->dsa->priv_key, NULL); | ||
212 | sshkey_free(k1); | 207 | sshkey_free(k1); |
213 | TEST_DONE(); | 208 | TEST_DONE(); |
214 | 209 | ||
@@ -230,27 +225,6 @@ sshkey_tests(void) | |||
230 | sshkey_free(k1); | 225 | sshkey_free(k1); |
231 | TEST_DONE(); | 226 | TEST_DONE(); |
232 | 227 | ||
233 | TEST_START("new_private KEY_RSA"); | ||
234 | k1 = sshkey_new_private(KEY_RSA); | ||
235 | ASSERT_PTR_NE(k1, NULL); | ||
236 | ASSERT_PTR_NE(k1->rsa, NULL); | ||
237 | ASSERT_PTR_NE(k1->rsa->n, NULL); | ||
238 | ASSERT_PTR_NE(k1->rsa->e, NULL); | ||
239 | ASSERT_PTR_NE(k1->rsa->p, NULL); | ||
240 | ASSERT_INT_EQ(sshkey_add_private(k1), 0); | ||
241 | sshkey_free(k1); | ||
242 | TEST_DONE(); | ||
243 | |||
244 | TEST_START("new_private KEY_DSA"); | ||
245 | k1 = sshkey_new_private(KEY_DSA); | ||
246 | ASSERT_PTR_NE(k1, NULL); | ||
247 | ASSERT_PTR_NE(k1->dsa, NULL); | ||
248 | ASSERT_PTR_NE(k1->dsa->g, NULL); | ||
249 | ASSERT_PTR_NE(k1->dsa->priv_key, NULL); | ||
250 | ASSERT_INT_EQ(sshkey_add_private(k1), 0); | ||
251 | sshkey_free(k1); | ||
252 | TEST_DONE(); | ||
253 | |||
254 | TEST_START("generate KEY_RSA too small modulus"); | 228 | TEST_START("generate KEY_RSA too small modulus"); |
255 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 128, &k1), | 229 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 128, &k1), |
256 | SSH_ERR_KEY_LENGTH); | 230 | SSH_ERR_KEY_LENGTH); |
@@ -285,18 +259,18 @@ sshkey_tests(void) | |||
285 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &kr), 0); | 259 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &kr), 0); |
286 | ASSERT_PTR_NE(kr, NULL); | 260 | ASSERT_PTR_NE(kr, NULL); |
287 | ASSERT_PTR_NE(kr->rsa, NULL); | 261 | ASSERT_PTR_NE(kr->rsa, NULL); |
288 | ASSERT_PTR_NE(kr->rsa->n, NULL); | 262 | ASSERT_PTR_NE(rsa_n(kr), NULL); |
289 | ASSERT_PTR_NE(kr->rsa->e, NULL); | 263 | ASSERT_PTR_NE(rsa_e(kr), NULL); |
290 | ASSERT_PTR_NE(kr->rsa->p, NULL); | 264 | ASSERT_PTR_NE(rsa_p(kr), NULL); |
291 | ASSERT_INT_EQ(BN_num_bits(kr->rsa->n), 1024); | 265 | ASSERT_INT_EQ(BN_num_bits(rsa_n(kr)), 1024); |
292 | TEST_DONE(); | 266 | TEST_DONE(); |
293 | 267 | ||
294 | TEST_START("generate KEY_DSA"); | 268 | TEST_START("generate KEY_DSA"); |
295 | ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &kd), 0); | 269 | ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &kd), 0); |
296 | ASSERT_PTR_NE(kd, NULL); | 270 | ASSERT_PTR_NE(kd, NULL); |
297 | ASSERT_PTR_NE(kd->dsa, NULL); | 271 | ASSERT_PTR_NE(kd->dsa, NULL); |
298 | ASSERT_PTR_NE(kd->dsa->g, NULL); | 272 | ASSERT_PTR_NE(dsa_g(kd), NULL); |
299 | ASSERT_PTR_NE(kd->dsa->priv_key, NULL); | 273 | ASSERT_PTR_NE(dsa_priv_key(kd), NULL); |
300 | TEST_DONE(); | 274 | TEST_DONE(); |
301 | 275 | ||
302 | #ifdef OPENSSL_HAS_ECC | 276 | #ifdef OPENSSL_HAS_ECC |
@@ -318,14 +292,14 @@ sshkey_tests(void) | |||
318 | TEST_DONE(); | 292 | TEST_DONE(); |
319 | 293 | ||
320 | TEST_START("demote KEY_RSA"); | 294 | TEST_START("demote KEY_RSA"); |
321 | ASSERT_INT_EQ(sshkey_demote(kr, &k1), 0); | 295 | ASSERT_INT_EQ(sshkey_from_private(kr, &k1), 0); |
322 | ASSERT_PTR_NE(k1, NULL); | 296 | ASSERT_PTR_NE(k1, NULL); |
323 | ASSERT_PTR_NE(kr, k1); | 297 | ASSERT_PTR_NE(kr, k1); |
324 | ASSERT_INT_EQ(k1->type, KEY_RSA); | 298 | ASSERT_INT_EQ(k1->type, KEY_RSA); |
325 | ASSERT_PTR_NE(k1->rsa, NULL); | 299 | ASSERT_PTR_NE(k1->rsa, NULL); |
326 | ASSERT_PTR_NE(k1->rsa->n, NULL); | 300 | ASSERT_PTR_NE(rsa_n(k1), NULL); |
327 | ASSERT_PTR_NE(k1->rsa->e, NULL); | 301 | ASSERT_PTR_NE(rsa_e(k1), NULL); |
328 | ASSERT_PTR_EQ(k1->rsa->p, NULL); | 302 | ASSERT_PTR_EQ(rsa_p(k1), NULL); |
329 | TEST_DONE(); | 303 | TEST_DONE(); |
330 | 304 | ||
331 | TEST_START("equal KEY_RSA/demoted KEY_RSA"); | 305 | TEST_START("equal KEY_RSA/demoted KEY_RSA"); |
@@ -334,13 +308,13 @@ sshkey_tests(void) | |||
334 | TEST_DONE(); | 308 | TEST_DONE(); |
335 | 309 | ||
336 | TEST_START("demote KEY_DSA"); | 310 | TEST_START("demote KEY_DSA"); |
337 | ASSERT_INT_EQ(sshkey_demote(kd, &k1), 0); | 311 | ASSERT_INT_EQ(sshkey_from_private(kd, &k1), 0); |
338 | ASSERT_PTR_NE(k1, NULL); | 312 | ASSERT_PTR_NE(k1, NULL); |
339 | ASSERT_PTR_NE(kd, k1); | 313 | ASSERT_PTR_NE(kd, k1); |
340 | ASSERT_INT_EQ(k1->type, KEY_DSA); | 314 | ASSERT_INT_EQ(k1->type, KEY_DSA); |
341 | ASSERT_PTR_NE(k1->dsa, NULL); | 315 | ASSERT_PTR_NE(k1->dsa, NULL); |
342 | ASSERT_PTR_NE(k1->dsa->g, NULL); | 316 | ASSERT_PTR_NE(dsa_g(k1), NULL); |
343 | ASSERT_PTR_EQ(k1->dsa->priv_key, NULL); | 317 | ASSERT_PTR_EQ(dsa_priv_key(k1), NULL); |
344 | TEST_DONE(); | 318 | TEST_DONE(); |
345 | 319 | ||
346 | TEST_START("equal KEY_DSA/demoted KEY_DSA"); | 320 | TEST_START("equal KEY_DSA/demoted KEY_DSA"); |
@@ -350,7 +324,7 @@ sshkey_tests(void) | |||
350 | 324 | ||
351 | #ifdef OPENSSL_HAS_ECC | 325 | #ifdef OPENSSL_HAS_ECC |
352 | TEST_START("demote KEY_ECDSA"); | 326 | TEST_START("demote KEY_ECDSA"); |
353 | ASSERT_INT_EQ(sshkey_demote(ke, &k1), 0); | 327 | ASSERT_INT_EQ(sshkey_from_private(ke, &k1), 0); |
354 | ASSERT_PTR_NE(k1, NULL); | 328 | ASSERT_PTR_NE(k1, NULL); |
355 | ASSERT_PTR_NE(ke, k1); | 329 | ASSERT_PTR_NE(ke, k1); |
356 | ASSERT_INT_EQ(k1->type, KEY_ECDSA); | 330 | ASSERT_INT_EQ(k1->type, KEY_ECDSA); |
@@ -367,7 +341,7 @@ sshkey_tests(void) | |||
367 | #endif | 341 | #endif |
368 | 342 | ||
369 | TEST_START("demote KEY_ED25519"); | 343 | TEST_START("demote KEY_ED25519"); |
370 | ASSERT_INT_EQ(sshkey_demote(kf, &k1), 0); | 344 | ASSERT_INT_EQ(sshkey_from_private(kf, &k1), 0); |
371 | ASSERT_PTR_NE(k1, NULL); | 345 | ASSERT_PTR_NE(k1, NULL); |
372 | ASSERT_PTR_NE(kf, k1); | 346 | ASSERT_PTR_NE(kf, k1); |
373 | ASSERT_INT_EQ(k1->type, KEY_ED25519); | 347 | ASSERT_INT_EQ(k1->type, KEY_ED25519); |
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha1 b/regress/unittests/sshkey/testdata/rsa_1_sha1 new file mode 100644 index 000000000..5de3f8422 --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha1 | |||
@@ -0,0 +1,15 @@ | |||
1 | -----BEGIN RSA PRIVATE KEY----- | ||
2 | MIICXAIBAAKBgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18u | ||
3 | d6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKd | ||
4 | NSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+wIDAQAB | ||
5 | AoGAXyj5mpjmbD+YlxGIWz/zrM4hGsWgd4VteKEJxT6MMI4uzCRpkMd0ck8oHiwZ | ||
6 | GAI/SwUzIsgtONQuH3AXVsUgghW4Ynn+8ksEv0IZ918WDMDwqvqkyrVzsOsZzqYj | ||
7 | Pf8DUDKCpwFjnlknJ04yvWBZvVhWtY4OiZ8GV0Ttsu3k+GECQQD1YHfvBb5FdJBv | ||
8 | Uhde2Il+jaFia8mwVVNNaiD2ECxXx6CzGz54ZLEB9NPVfDUZK8lJ4UJDqelWNh3i | ||
9 | PF3RefWDAkEA1CVBzAFL4mNwpleVPzrfy69xP3gWOa26MxM/GE6zx9jC7HgQ3KPa | ||
10 | WKdG/FuHs085aTRDaDLmGcZ8IvMuu7NgKQJAcIOKmxR0Gd8IN7NZugjqixggb0Pj | ||
11 | mLKXXwESGiJyYtHL0zTj4Uqyi6Ya2GJ66o7UXscmnmYz828fJtTtZBdbRwJBALfi | ||
12 | C2QvA32Zv/0PEXibKXy996WSC4G3ShwXZKtHHKHvCxY5BDSbehk59VesZrVPyG2e | ||
13 | NYdOBxD0cIlCzJE56/ECQAndVkxvO8hwyEFGGwF3faHIAe/OxVb+MjaU25//Pe1/ | ||
14 | h/e6tlCk4w9CODpyV685gV394eYwMcGDcIkipTNUDZs= | ||
15 | -----END RSA PRIVATE KEY----- | ||
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha1-cert.pub b/regress/unittests/sshkey/testdata/rsa_1_sha1-cert.pub new file mode 100644 index 000000000..ff49d7598 --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha1-cert.pub | |||
@@ -0,0 +1 @@ | |||
ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAgy5PGFfSaEuSuXsjvKlMZGXYD0xlnqdZftuW9tMkUYz4AAAADAQABAAAAgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18ud6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKdNSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+wAAAAAAAAABAAAAAQAAAARodWdvAAAAEgAAAAV1c2VyMQAAAAV1c2VyMgAAAAA2i4NgAAAAAE0d4eAAAABEAAAADWZvcmNlLWNvbW1hbmQAAAALAAAABy9iaW4vbHMAAAAOc291cmNlLWFkZHJlc3MAAAAOAAAACjEwLjAuMC4wLzgAAABkAAAAFXBlcm1pdC1YMTEtZm9yd2FyZGluZwAAAAAAAAAXcGVybWl0LWFnZW50LWZvcndhcmRpbmcAAAAAAAAACnBlcm1pdC1wdHkAAAAAAAAADnBlcm1pdC11c2VyLXJjAAAAAAAAAAAAAAEXAAAAB3NzaC1yc2EAAAADAQABAAABAQD00RRenvxICSYvj54CPiYHM86OT5xwI9XORNH6Zkl3JPCQkAEdQ3hyfhraROaHsSv43wJcKyKrEg5XUZ8fZ/BoKIGU4Rd5AmL9wyPGv2RVY7gWELqXVSpu89R2tQJRmMVMD38CH0wqCTuoZirlKMTen6yfgYuFEpuqar0uOIeAyaQG6/9rVKWK36tcfM7YXx8fmGSN4eK/JhWDDjlo28YJ7ZFF9umh5baZG2Ai/vL3BJ7C3pqaEQNdKj8XqaSoDvFWKfOujk1620Rcuj3W0D0dvp/rH8xz8YkM1dMqGlYIZ4nrF5acB58Nk5FYBjtj1hu4DGEQlWL1Avk1agU4DQLrAAABDwAAAAdzc2gtcnNhAAABAF5BtPY8FbmIekK/zNq6/Lp5agKT5zEVxqAyZKhp75bLRP+kOMZBVB9ZWrekZk6IAVAOCZGQzTsD4mxIQsxBLl8k5hvEWb90/+w9/BzW9ScOGQe+y0COa0QWWR7L3k1S8WX2oAGvtDWOj7Md85nij4ZSU9/QQQFVDF8VilWPSMxUf/3I1fqyDq7AWcZkGk/bFUN6K6RsCSxIPlGmKt0IauyvSMI2IT0XeRT242RngeeUW8vFrn9TXy9YxJRW+cSeLKCuu8agBYyQMXWQ+q39eZZqVYSoo7nFEEhtaLs8d6jzgGkcE9wGJ9KLgfY/mG2vX3gI4IzncKkVJRoeiDzXFIk= RSA test key #1 | |||
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha1.pub b/regress/unittests/sshkey/testdata/rsa_1_sha1.pub new file mode 100644 index 000000000..23ef872e0 --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha1.pub | |||
@@ -0,0 +1 @@ | |||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18ud6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKdNSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+w== RSA test key #1 | |||
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha512 b/regress/unittests/sshkey/testdata/rsa_1_sha512 new file mode 100644 index 000000000..5de3f8422 --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha512 | |||
@@ -0,0 +1,15 @@ | |||
1 | -----BEGIN RSA PRIVATE KEY----- | ||
2 | MIICXAIBAAKBgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18u | ||
3 | d6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKd | ||
4 | NSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+wIDAQAB | ||
5 | AoGAXyj5mpjmbD+YlxGIWz/zrM4hGsWgd4VteKEJxT6MMI4uzCRpkMd0ck8oHiwZ | ||
6 | GAI/SwUzIsgtONQuH3AXVsUgghW4Ynn+8ksEv0IZ918WDMDwqvqkyrVzsOsZzqYj | ||
7 | Pf8DUDKCpwFjnlknJ04yvWBZvVhWtY4OiZ8GV0Ttsu3k+GECQQD1YHfvBb5FdJBv | ||
8 | Uhde2Il+jaFia8mwVVNNaiD2ECxXx6CzGz54ZLEB9NPVfDUZK8lJ4UJDqelWNh3i | ||
9 | PF3RefWDAkEA1CVBzAFL4mNwpleVPzrfy69xP3gWOa26MxM/GE6zx9jC7HgQ3KPa | ||
10 | WKdG/FuHs085aTRDaDLmGcZ8IvMuu7NgKQJAcIOKmxR0Gd8IN7NZugjqixggb0Pj | ||
11 | mLKXXwESGiJyYtHL0zTj4Uqyi6Ya2GJ66o7UXscmnmYz828fJtTtZBdbRwJBALfi | ||
12 | C2QvA32Zv/0PEXibKXy996WSC4G3ShwXZKtHHKHvCxY5BDSbehk59VesZrVPyG2e | ||
13 | NYdOBxD0cIlCzJE56/ECQAndVkxvO8hwyEFGGwF3faHIAe/OxVb+MjaU25//Pe1/ | ||
14 | h/e6tlCk4w9CODpyV685gV394eYwMcGDcIkipTNUDZs= | ||
15 | -----END RSA PRIVATE KEY----- | ||
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha512-cert.pub b/regress/unittests/sshkey/testdata/rsa_1_sha512-cert.pub new file mode 100644 index 000000000..47451968f --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha512-cert.pub | |||
@@ -0,0 +1 @@ | |||
ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAg/bUEmnMYHxlv1N7iXvnYPYdzDjlTRKoaIGEPkaQQQDwAAAADAQABAAAAgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18ud6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKdNSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+wAAAAAAAAABAAAAAQAAAARodWdvAAAAEgAAAAV1c2VyMQAAAAV1c2VyMgAAAAA2i4NgAAAAAE0d4eAAAABEAAAADWZvcmNlLWNvbW1hbmQAAAALAAAABy9iaW4vbHMAAAAOc291cmNlLWFkZHJlc3MAAAAOAAAACjEwLjAuMC4wLzgAAABkAAAAFXBlcm1pdC1YMTEtZm9yd2FyZGluZwAAAAAAAAAXcGVybWl0LWFnZW50LWZvcndhcmRpbmcAAAAAAAAACnBlcm1pdC1wdHkAAAAAAAAADnBlcm1pdC11c2VyLXJjAAAAAAAAAAAAAAEXAAAAB3NzaC1yc2EAAAADAQABAAABAQD00RRenvxICSYvj54CPiYHM86OT5xwI9XORNH6Zkl3JPCQkAEdQ3hyfhraROaHsSv43wJcKyKrEg5XUZ8fZ/BoKIGU4Rd5AmL9wyPGv2RVY7gWELqXVSpu89R2tQJRmMVMD38CH0wqCTuoZirlKMTen6yfgYuFEpuqar0uOIeAyaQG6/9rVKWK36tcfM7YXx8fmGSN4eK/JhWDDjlo28YJ7ZFF9umh5baZG2Ai/vL3BJ7C3pqaEQNdKj8XqaSoDvFWKfOujk1620Rcuj3W0D0dvp/rH8xz8YkM1dMqGlYIZ4nrF5acB58Nk5FYBjtj1hu4DGEQlWL1Avk1agU4DQLrAAABFAAAAAxyc2Etc2hhMi01MTIAAAEA7/GoZsJqrq4xYotsRbpM8arZDjCzT6kohXeD/GVy26s5E/YWXRYCrOMIzSZxjuN5rAaNRW8ffxq14JyI94566Kg2OeoxQ6rK/dTqkk7I1RyypSXunT3I4++RPs1Q+hu9eS/WBzur0/D3dMejhuc3IBg6iB0481I4pGBGcD8/KjQFfhlCuGVXwB1ALk2zfXFT1HYYrs6bYZuQqjgvArnjYJ0do3fTSDC20/ydV4BHnI3fVAY2THVjX45V2ppPadl/rpczaJqW1ZtpnpJkV8Un316stQSD0xLHUDjp89O6d9Yq5S0kDdfwTRJIPm9f2cGNakJwN5qzmmmdDroRKODYcg== RSA test key #1 | |||
diff --git a/regress/unittests/sshkey/testdata/rsa_1_sha512.pub b/regress/unittests/sshkey/testdata/rsa_1_sha512.pub new file mode 100644 index 000000000..23ef872e0 --- /dev/null +++ b/regress/unittests/sshkey/testdata/rsa_1_sha512.pub | |||
@@ -0,0 +1 @@ | |||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDLV5lUTt7FrADseB/CGhEZzpoojjEW5y8+ePvLppmK3MmMI18ud6vxzpK3bwZLYkVSyfJYI0HmIuGhdu7yMrW6wb84gbq8C31Xoe9EORcIUuGSvDKdNSM1SjlhDquRblDFB8kToqXyx1lqrXecXylxIUOL0jE+u0rU1967pDJx+w== RSA test key #1 | |||
diff --git a/regress/unittests/test_helper/fuzz.c b/regress/unittests/test_helper/fuzz.c index 99f1d036c..78b36654d 100644 --- a/regress/unittests/test_helper/fuzz.c +++ b/regress/unittests/test_helper/fuzz.c | |||
@@ -196,7 +196,6 @@ fuzz_dump(struct fuzz *fuzz) | |||
196 | dump(fuzz_ptr(fuzz), fuzz_len(fuzz)); | 196 | dump(fuzz_ptr(fuzz), fuzz_len(fuzz)); |
197 | } | 197 | } |
198 | 198 | ||
199 | #ifdef SIGINFO | ||
200 | static struct fuzz *last_fuzz; | 199 | static struct fuzz *last_fuzz; |
201 | 200 | ||
202 | static void | 201 | static void |
@@ -211,7 +210,6 @@ siginfo(int unused __attribute__((__unused__))) | |||
211 | atomicio(vwrite, STDERR_FILENO, buf, strlen(buf)); | 210 | atomicio(vwrite, STDERR_FILENO, buf, strlen(buf)); |
212 | } | 211 | } |
213 | } | 212 | } |
214 | #endif | ||
215 | 213 | ||
216 | struct fuzz * | 214 | struct fuzz * |
217 | fuzz_begin(u_int strategies, const void *p, size_t l) | 215 | fuzz_begin(u_int strategies, const void *p, size_t l) |
@@ -233,10 +231,11 @@ fuzz_begin(u_int strategies, const void *p, size_t l) | |||
233 | 231 | ||
234 | fuzz_next(ret); | 232 | fuzz_next(ret); |
235 | 233 | ||
236 | #ifdef SIGINFO | ||
237 | last_fuzz = ret; | 234 | last_fuzz = ret; |
235 | #ifdef SIGINFO | ||
238 | signal(SIGINFO, siginfo); | 236 | signal(SIGINFO, siginfo); |
239 | #endif | 237 | #endif |
238 | signal(SIGUSR1, siginfo); | ||
240 | 239 | ||
241 | return ret; | 240 | return ret; |
242 | } | 241 | } |
@@ -245,10 +244,11 @@ void | |||
245 | fuzz_cleanup(struct fuzz *fuzz) | 244 | fuzz_cleanup(struct fuzz *fuzz) |
246 | { | 245 | { |
247 | FUZZ_DBG(("cleanup, fuzz = %p", fuzz)); | 246 | FUZZ_DBG(("cleanup, fuzz = %p", fuzz)); |
248 | #ifdef SIGINFO | ||
249 | last_fuzz = NULL; | 247 | last_fuzz = NULL; |
248 | #ifdef SIGINFO | ||
250 | signal(SIGINFO, SIG_DFL); | 249 | signal(SIGINFO, SIG_DFL); |
251 | #endif | 250 | #endif |
251 | signal(SIGUSR1, SIG_DFL); | ||
252 | assert(fuzz != NULL); | 252 | assert(fuzz != NULL); |
253 | assert(fuzz->seed != NULL); | 253 | assert(fuzz->seed != NULL); |
254 | assert(fuzz->fuzzed != NULL); | 254 | assert(fuzz->fuzzed != NULL); |
diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c index 866f3495d..4cc70852c 100644 --- a/regress/unittests/test_helper/test_helper.c +++ b/regress/unittests/test_helper/test_helper.c | |||
@@ -203,7 +203,6 @@ test_info(char *s, size_t len) | |||
203 | *subtest_info != '\0' ? " - " : "", subtest_info); | 203 | *subtest_info != '\0' ? " - " : "", subtest_info); |
204 | } | 204 | } |
205 | 205 | ||
206 | #ifdef SIGINFO | ||
207 | static void | 206 | static void |
208 | siginfo(int unused __attribute__((__unused__))) | 207 | siginfo(int unused __attribute__((__unused__))) |
209 | { | 208 | { |
@@ -212,7 +211,6 @@ siginfo(int unused __attribute__((__unused__))) | |||
212 | test_info(buf, sizeof(buf)); | 211 | test_info(buf, sizeof(buf)); |
213 | atomicio(vwrite, STDERR_FILENO, buf, strlen(buf)); | 212 | atomicio(vwrite, STDERR_FILENO, buf, strlen(buf)); |
214 | } | 213 | } |
215 | #endif | ||
216 | 214 | ||
217 | void | 215 | void |
218 | test_start(const char *n) | 216 | test_start(const char *n) |
@@ -226,6 +224,7 @@ test_start(const char *n) | |||
226 | #ifdef SIGINFO | 224 | #ifdef SIGINFO |
227 | signal(SIGINFO, siginfo); | 225 | signal(SIGINFO, siginfo); |
228 | #endif | 226 | #endif |
227 | signal(SIGUSR1, siginfo); | ||
229 | } | 228 | } |
230 | 229 | ||
231 | void | 230 | void |