diff options
Diffstat (limited to 'regress/unittests/sshkey/test_file.c')
-rw-r--r-- | regress/unittests/sshkey/test_file.c | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c index c8a236937..906491f2b 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.4 2015/07/07 14:53:30 markus Exp $ */ | 1 | /* $OpenBSD: test_file.c,v 1.5 2015/10/06 01:20:59 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -54,8 +54,7 @@ sshkey_file_tests(void) | |||
54 | #ifdef WITH_SSH1 | 54 | #ifdef WITH_SSH1 |
55 | TEST_START("parse RSA1 from private"); | 55 | TEST_START("parse RSA1 from private"); |
56 | buf = load_file("rsa1_1"); | 56 | buf = load_file("rsa1_1"); |
57 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "rsa1_1", | 57 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); |
58 | &k1, NULL), 0); | ||
59 | sshbuf_free(buf); | 58 | sshbuf_free(buf); |
60 | ASSERT_PTR_NE(k1, NULL); | 59 | ASSERT_PTR_NE(k1, NULL); |
61 | a = load_bignum("rsa1_1.param.n"); | 60 | a = load_bignum("rsa1_1.param.n"); |
@@ -66,7 +65,7 @@ sshkey_file_tests(void) | |||
66 | TEST_START("parse RSA1 from private w/ passphrase"); | 65 | TEST_START("parse RSA1 from private w/ passphrase"); |
67 | buf = load_file("rsa1_1_pw"); | 66 | buf = load_file("rsa1_1_pw"); |
68 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 67 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
69 | (const char *)sshbuf_ptr(pw), "rsa1_1_pw", &k2, NULL), 0); | 68 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
70 | sshbuf_free(buf); | 69 | sshbuf_free(buf); |
71 | ASSERT_PTR_NE(k2, NULL); | 70 | ASSERT_PTR_NE(k2, NULL); |
72 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 71 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -104,8 +103,7 @@ sshkey_file_tests(void) | |||
104 | 103 | ||
105 | TEST_START("parse RSA from private"); | 104 | TEST_START("parse RSA from private"); |
106 | buf = load_file("rsa_1"); | 105 | buf = load_file("rsa_1"); |
107 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "rsa_1", | 106 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); |
108 | &k1, NULL), 0); | ||
109 | sshbuf_free(buf); | 107 | sshbuf_free(buf); |
110 | ASSERT_PTR_NE(k1, NULL); | 108 | ASSERT_PTR_NE(k1, NULL); |
111 | a = load_bignum("rsa_1.param.n"); | 109 | a = load_bignum("rsa_1.param.n"); |
@@ -122,7 +120,7 @@ sshkey_file_tests(void) | |||
122 | TEST_START("parse RSA from private w/ passphrase"); | 120 | TEST_START("parse RSA from private w/ passphrase"); |
123 | buf = load_file("rsa_1_pw"); | 121 | buf = load_file("rsa_1_pw"); |
124 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 122 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
125 | (const char *)sshbuf_ptr(pw), "rsa_1_pw", &k2, NULL), 0); | 123 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
126 | sshbuf_free(buf); | 124 | sshbuf_free(buf); |
127 | ASSERT_PTR_NE(k2, NULL); | 125 | ASSERT_PTR_NE(k2, NULL); |
128 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 126 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -131,8 +129,7 @@ sshkey_file_tests(void) | |||
131 | 129 | ||
132 | TEST_START("parse RSA from new-format"); | 130 | TEST_START("parse RSA from new-format"); |
133 | buf = load_file("rsa_n"); | 131 | buf = load_file("rsa_n"); |
134 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 132 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0); |
135 | "", "rsa_n", &k2, NULL), 0); | ||
136 | sshbuf_free(buf); | 133 | sshbuf_free(buf); |
137 | ASSERT_PTR_NE(k2, NULL); | 134 | ASSERT_PTR_NE(k2, NULL); |
138 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 135 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -142,7 +139,7 @@ sshkey_file_tests(void) | |||
142 | TEST_START("parse RSA from new-format w/ passphrase"); | 139 | TEST_START("parse RSA from new-format w/ passphrase"); |
143 | buf = load_file("rsa_n_pw"); | 140 | buf = load_file("rsa_n_pw"); |
144 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 141 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
145 | (const char *)sshbuf_ptr(pw), "rsa_n_pw", &k2, NULL), 0); | 142 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
146 | sshbuf_free(buf); | 143 | sshbuf_free(buf); |
147 | ASSERT_PTR_NE(k2, NULL); | 144 | ASSERT_PTR_NE(k2, NULL); |
148 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 145 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -197,8 +194,7 @@ sshkey_file_tests(void) | |||
197 | 194 | ||
198 | TEST_START("parse DSA from private"); | 195 | TEST_START("parse DSA from private"); |
199 | buf = load_file("dsa_1"); | 196 | buf = load_file("dsa_1"); |
200 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "dsa_1", | 197 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); |
201 | &k1, NULL), 0); | ||
202 | sshbuf_free(buf); | 198 | sshbuf_free(buf); |
203 | ASSERT_PTR_NE(k1, NULL); | 199 | ASSERT_PTR_NE(k1, NULL); |
204 | a = load_bignum("dsa_1.param.g"); | 200 | a = load_bignum("dsa_1.param.g"); |
@@ -215,7 +211,7 @@ sshkey_file_tests(void) | |||
215 | TEST_START("parse DSA from private w/ passphrase"); | 211 | TEST_START("parse DSA from private w/ passphrase"); |
216 | buf = load_file("dsa_1_pw"); | 212 | buf = load_file("dsa_1_pw"); |
217 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 213 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
218 | (const char *)sshbuf_ptr(pw), "dsa_1_pw", &k2, NULL), 0); | 214 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
219 | sshbuf_free(buf); | 215 | sshbuf_free(buf); |
220 | ASSERT_PTR_NE(k2, NULL); | 216 | ASSERT_PTR_NE(k2, NULL); |
221 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 217 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -224,8 +220,7 @@ sshkey_file_tests(void) | |||
224 | 220 | ||
225 | TEST_START("parse DSA from new-format"); | 221 | TEST_START("parse DSA from new-format"); |
226 | buf = load_file("dsa_n"); | 222 | buf = load_file("dsa_n"); |
227 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 223 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0); |
228 | "", "dsa_n", &k2, NULL), 0); | ||
229 | sshbuf_free(buf); | 224 | sshbuf_free(buf); |
230 | ASSERT_PTR_NE(k2, NULL); | 225 | ASSERT_PTR_NE(k2, NULL); |
231 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 226 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -235,7 +230,7 @@ sshkey_file_tests(void) | |||
235 | TEST_START("parse DSA from new-format w/ passphrase"); | 230 | TEST_START("parse DSA from new-format w/ passphrase"); |
236 | buf = load_file("dsa_n_pw"); | 231 | buf = load_file("dsa_n_pw"); |
237 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 232 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
238 | (const char *)sshbuf_ptr(pw), "dsa_n_pw", &k2, NULL), 0); | 233 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
239 | sshbuf_free(buf); | 234 | sshbuf_free(buf); |
240 | ASSERT_PTR_NE(k2, NULL); | 235 | ASSERT_PTR_NE(k2, NULL); |
241 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 236 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -291,8 +286,7 @@ sshkey_file_tests(void) | |||
291 | #ifdef OPENSSL_HAS_ECC | 286 | #ifdef OPENSSL_HAS_ECC |
292 | TEST_START("parse ECDSA from private"); | 287 | TEST_START("parse ECDSA from private"); |
293 | buf = load_file("ecdsa_1"); | 288 | buf = load_file("ecdsa_1"); |
294 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "ecdsa_1", | 289 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); |
295 | &k1, NULL), 0); | ||
296 | sshbuf_free(buf); | 290 | sshbuf_free(buf); |
297 | ASSERT_PTR_NE(k1, NULL); | 291 | ASSERT_PTR_NE(k1, NULL); |
298 | buf = load_text_file("ecdsa_1.param.curve"); | 292 | buf = load_text_file("ecdsa_1.param.curve"); |
@@ -315,7 +309,7 @@ sshkey_file_tests(void) | |||
315 | TEST_START("parse ECDSA from private w/ passphrase"); | 309 | TEST_START("parse ECDSA from private w/ passphrase"); |
316 | buf = load_file("ecdsa_1_pw"); | 310 | buf = load_file("ecdsa_1_pw"); |
317 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 311 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
318 | (const char *)sshbuf_ptr(pw), "ecdsa_1_pw", &k2, NULL), 0); | 312 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
319 | sshbuf_free(buf); | 313 | sshbuf_free(buf); |
320 | ASSERT_PTR_NE(k2, NULL); | 314 | ASSERT_PTR_NE(k2, NULL); |
321 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 315 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -324,8 +318,7 @@ sshkey_file_tests(void) | |||
324 | 318 | ||
325 | TEST_START("parse ECDSA from new-format"); | 319 | TEST_START("parse ECDSA from new-format"); |
326 | buf = load_file("ecdsa_n"); | 320 | buf = load_file("ecdsa_n"); |
327 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 321 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0); |
328 | "", "ecdsa_n", &k2, NULL), 0); | ||
329 | sshbuf_free(buf); | 322 | sshbuf_free(buf); |
330 | ASSERT_PTR_NE(k2, NULL); | 323 | ASSERT_PTR_NE(k2, NULL); |
331 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 324 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -335,7 +328,7 @@ sshkey_file_tests(void) | |||
335 | TEST_START("parse ECDSA from new-format w/ passphrase"); | 328 | TEST_START("parse ECDSA from new-format w/ passphrase"); |
336 | buf = load_file("ecdsa_n_pw"); | 329 | buf = load_file("ecdsa_n_pw"); |
337 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 330 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
338 | (const char *)sshbuf_ptr(pw), "ecdsa_n_pw", &k2, NULL), 0); | 331 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
339 | sshbuf_free(buf); | 332 | sshbuf_free(buf); |
340 | ASSERT_PTR_NE(k2, NULL); | 333 | ASSERT_PTR_NE(k2, NULL); |
341 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 334 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |
@@ -391,8 +384,7 @@ sshkey_file_tests(void) | |||
391 | 384 | ||
392 | TEST_START("parse Ed25519 from private"); | 385 | TEST_START("parse Ed25519 from private"); |
393 | buf = load_file("ed25519_1"); | 386 | buf = load_file("ed25519_1"); |
394 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", "ed25519_1", | 387 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); |
395 | &k1, NULL), 0); | ||
396 | sshbuf_free(buf); | 388 | sshbuf_free(buf); |
397 | ASSERT_PTR_NE(k1, NULL); | 389 | ASSERT_PTR_NE(k1, NULL); |
398 | ASSERT_INT_EQ(k1->type, KEY_ED25519); | 390 | ASSERT_INT_EQ(k1->type, KEY_ED25519); |
@@ -402,7 +394,7 @@ sshkey_file_tests(void) | |||
402 | TEST_START("parse Ed25519 from private w/ passphrase"); | 394 | TEST_START("parse Ed25519 from private w/ passphrase"); |
403 | buf = load_file("ed25519_1_pw"); | 395 | buf = load_file("ed25519_1_pw"); |
404 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, | 396 | ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, |
405 | (const char *)sshbuf_ptr(pw), "ed25519_1_pw", &k2, NULL), 0); | 397 | (const char *)sshbuf_ptr(pw), &k2, NULL), 0); |
406 | sshbuf_free(buf); | 398 | sshbuf_free(buf); |
407 | ASSERT_PTR_NE(k2, NULL); | 399 | ASSERT_PTR_NE(k2, NULL); |
408 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); | 400 | ASSERT_INT_EQ(sshkey_equal(k1, k2), 1); |