diff options
-rwxr-xr-x | regress/unittests/sshkey/mktestdata.sh | 6 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_file.c | 20 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_sshkey.c | 10 |
3 files changed, 19 insertions, 17 deletions
diff --git a/regress/unittests/sshkey/mktestdata.sh b/regress/unittests/sshkey/mktestdata.sh index 09165af02..e11100145 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.4 2015/01/18 19:54:46 djm Exp $ | 2 | # $OpenBSD: mktestdata.sh,v 1.5 2015/07/07 14:53:30 markus Exp $ |
3 | 3 | ||
4 | PW=mekmitasdigoat | 4 | PW=mekmitasdigoat |
5 | 5 | ||
@@ -94,8 +94,8 @@ rm -f rsa1_1_pw rsa_1_pw dsa_1_pw ecdsa_1_pw ed25519_1_pw | |||
94 | rm -f rsa_n_pw dsa_n_pw ecdsa_n_pw | 94 | rm -f rsa_n_pw dsa_n_pw ecdsa_n_pw |
95 | rm -f pw *.pub *.bn.* *.param.* *.fp *.fp.bb | 95 | rm -f pw *.pub *.bn.* *.param.* *.fp *.fp.bb |
96 | 96 | ||
97 | ssh-keygen -t rsa1 -b 768 -C "RSA1 test key #1" -N "" -f rsa1_1 | 97 | ssh-keygen -t rsa1 -b 1024 -C "RSA1 test key #1" -N "" -f rsa1_1 |
98 | ssh-keygen -t rsa -b 768 -C "RSA test key #1" -N "" -f rsa_1 | 98 | ssh-keygen -t rsa -b 1024 -C "RSA test key #1" -N "" -f rsa_1 |
99 | ssh-keygen -t dsa -b 1024 -C "DSA test key #1" -N "" -f dsa_1 | 99 | ssh-keygen -t dsa -b 1024 -C "DSA test key #1" -N "" -f dsa_1 |
100 | ssh-keygen -t ecdsa -b 256 -C "ECDSA test key #1" -N "" -f ecdsa_1 | 100 | ssh-keygen -t ecdsa -b 256 -C "ECDSA test key #1" -N "" -f ecdsa_1 |
101 | ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_1 | 101 | ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_1 |
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c index fa95212bf..c8a236937 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.3 2015/03/04 23:22:35 djm Exp $ */ | 1 | /* $OpenBSD: test_file.c,v 1.4 2015/07/07 14:53:30 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -83,7 +83,7 @@ sshkey_file_tests(void) | |||
83 | 83 | ||
84 | TEST_START("RSA1 key hex fingerprint"); | 84 | TEST_START("RSA1 key hex fingerprint"); |
85 | buf = load_text_file("rsa1_1.fp"); | 85 | buf = load_text_file("rsa1_1.fp"); |
86 | cp = sshkey_fingerprint(k1, SSH_DIGEST_MD5, SSH_FP_HEX); | 86 | cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
87 | ASSERT_PTR_NE(cp, NULL); | 87 | ASSERT_PTR_NE(cp, NULL); |
88 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 88 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
89 | sshbuf_free(buf); | 89 | sshbuf_free(buf); |
@@ -167,7 +167,7 @@ sshkey_file_tests(void) | |||
167 | 167 | ||
168 | TEST_START("RSA key hex fingerprint"); | 168 | TEST_START("RSA key hex fingerprint"); |
169 | buf = load_text_file("rsa_1.fp"); | 169 | buf = load_text_file("rsa_1.fp"); |
170 | cp = sshkey_fingerprint(k1, SSH_DIGEST_MD5, SSH_FP_HEX); | 170 | cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
171 | ASSERT_PTR_NE(cp, NULL); | 171 | ASSERT_PTR_NE(cp, NULL); |
172 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 172 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
173 | sshbuf_free(buf); | 173 | sshbuf_free(buf); |
@@ -176,7 +176,7 @@ sshkey_file_tests(void) | |||
176 | 176 | ||
177 | TEST_START("RSA cert hex fingerprint"); | 177 | TEST_START("RSA cert hex fingerprint"); |
178 | buf = load_text_file("rsa_1-cert.fp"); | 178 | buf = load_text_file("rsa_1-cert.fp"); |
179 | cp = sshkey_fingerprint(k2, SSH_DIGEST_MD5, SSH_FP_HEX); | 179 | cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
180 | ASSERT_PTR_NE(cp, NULL); | 180 | ASSERT_PTR_NE(cp, NULL); |
181 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 181 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
182 | sshbuf_free(buf); | 182 | sshbuf_free(buf); |
@@ -260,7 +260,7 @@ sshkey_file_tests(void) | |||
260 | 260 | ||
261 | TEST_START("DSA key hex fingerprint"); | 261 | TEST_START("DSA key hex fingerprint"); |
262 | buf = load_text_file("dsa_1.fp"); | 262 | buf = load_text_file("dsa_1.fp"); |
263 | cp = sshkey_fingerprint(k1, SSH_DIGEST_MD5, SSH_FP_HEX); | 263 | cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
264 | ASSERT_PTR_NE(cp, NULL); | 264 | ASSERT_PTR_NE(cp, NULL); |
265 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 265 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
266 | sshbuf_free(buf); | 266 | sshbuf_free(buf); |
@@ -269,7 +269,7 @@ sshkey_file_tests(void) | |||
269 | 269 | ||
270 | TEST_START("DSA cert hex fingerprint"); | 270 | TEST_START("DSA cert hex fingerprint"); |
271 | buf = load_text_file("dsa_1-cert.fp"); | 271 | buf = load_text_file("dsa_1-cert.fp"); |
272 | cp = sshkey_fingerprint(k2, SSH_DIGEST_MD5, SSH_FP_HEX); | 272 | cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
273 | ASSERT_PTR_NE(cp, NULL); | 273 | ASSERT_PTR_NE(cp, NULL); |
274 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 274 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
275 | sshbuf_free(buf); | 275 | sshbuf_free(buf); |
@@ -360,7 +360,7 @@ sshkey_file_tests(void) | |||
360 | 360 | ||
361 | TEST_START("ECDSA key hex fingerprint"); | 361 | TEST_START("ECDSA key hex fingerprint"); |
362 | buf = load_text_file("ecdsa_1.fp"); | 362 | buf = load_text_file("ecdsa_1.fp"); |
363 | cp = sshkey_fingerprint(k1, SSH_DIGEST_MD5, SSH_FP_HEX); | 363 | cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
364 | ASSERT_PTR_NE(cp, NULL); | 364 | ASSERT_PTR_NE(cp, NULL); |
365 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 365 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
366 | sshbuf_free(buf); | 366 | sshbuf_free(buf); |
@@ -369,7 +369,7 @@ sshkey_file_tests(void) | |||
369 | 369 | ||
370 | TEST_START("ECDSA cert hex fingerprint"); | 370 | TEST_START("ECDSA cert hex fingerprint"); |
371 | buf = load_text_file("ecdsa_1-cert.fp"); | 371 | buf = load_text_file("ecdsa_1-cert.fp"); |
372 | cp = sshkey_fingerprint(k2, SSH_DIGEST_MD5, SSH_FP_HEX); | 372 | cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
373 | ASSERT_PTR_NE(cp, NULL); | 373 | ASSERT_PTR_NE(cp, NULL); |
374 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 374 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
375 | sshbuf_free(buf); | 375 | sshbuf_free(buf); |
@@ -427,7 +427,7 @@ sshkey_file_tests(void) | |||
427 | 427 | ||
428 | TEST_START("Ed25519 key hex fingerprint"); | 428 | TEST_START("Ed25519 key hex fingerprint"); |
429 | buf = load_text_file("ed25519_1.fp"); | 429 | buf = load_text_file("ed25519_1.fp"); |
430 | cp = sshkey_fingerprint(k1, SSH_DIGEST_MD5, SSH_FP_HEX); | 430 | cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
431 | ASSERT_PTR_NE(cp, NULL); | 431 | ASSERT_PTR_NE(cp, NULL); |
432 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 432 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
433 | sshbuf_free(buf); | 433 | sshbuf_free(buf); |
@@ -436,7 +436,7 @@ sshkey_file_tests(void) | |||
436 | 436 | ||
437 | TEST_START("Ed25519 cert hex fingerprint"); | 437 | TEST_START("Ed25519 cert hex fingerprint"); |
438 | buf = load_text_file("ed25519_1-cert.fp"); | 438 | buf = load_text_file("ed25519_1-cert.fp"); |
439 | cp = sshkey_fingerprint(k2, SSH_DIGEST_MD5, SSH_FP_HEX); | 439 | cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64); |
440 | ASSERT_PTR_NE(cp, NULL); | 440 | ASSERT_PTR_NE(cp, NULL); |
441 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); | 441 | ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf)); |
442 | sshbuf_free(buf); | 442 | sshbuf_free(buf); |
diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c index 9e780701a..f0ce38a4a 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.5 2015/07/03 04:39:23 djm Exp $ */ | 1 | /* $OpenBSD: test_sshkey.c,v 1.6 2015/07/07 14:53:30 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -288,13 +288,15 @@ sshkey_tests(void) | |||
288 | #endif | 288 | #endif |
289 | 289 | ||
290 | TEST_START("generate KEY_RSA"); | 290 | TEST_START("generate KEY_RSA"); |
291 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 768, &kr), 0); | 291 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 768, &kr), |
292 | SSH_ERR_INVALID_ARGUMENT); | ||
293 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &kr), 0); | ||
292 | ASSERT_PTR_NE(kr, NULL); | 294 | ASSERT_PTR_NE(kr, NULL); |
293 | ASSERT_PTR_NE(kr->rsa, NULL); | 295 | ASSERT_PTR_NE(kr->rsa, NULL); |
294 | ASSERT_PTR_NE(kr->rsa->n, NULL); | 296 | ASSERT_PTR_NE(kr->rsa->n, NULL); |
295 | ASSERT_PTR_NE(kr->rsa->e, NULL); | 297 | ASSERT_PTR_NE(kr->rsa->e, NULL); |
296 | ASSERT_PTR_NE(kr->rsa->p, NULL); | 298 | ASSERT_PTR_NE(kr->rsa->p, NULL); |
297 | ASSERT_INT_EQ(BN_num_bits(kr->rsa->n), 768); | 299 | ASSERT_INT_EQ(BN_num_bits(kr->rsa->n), 1024); |
298 | TEST_DONE(); | 300 | TEST_DONE(); |
299 | 301 | ||
300 | TEST_START("generate KEY_DSA"); | 302 | TEST_START("generate KEY_DSA"); |
@@ -397,7 +399,7 @@ sshkey_tests(void) | |||
397 | TEST_DONE(); | 399 | TEST_DONE(); |
398 | 400 | ||
399 | TEST_START("equal different keys"); | 401 | TEST_START("equal different keys"); |
400 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 768, &k1), 0); | 402 | ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &k1), 0); |
401 | ASSERT_INT_EQ(sshkey_equal(kr, k1), 0); | 403 | ASSERT_INT_EQ(sshkey_equal(kr, k1), 0); |
402 | sshkey_free(k1); | 404 | sshkey_free(k1); |
403 | ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &k1), 0); | 405 | ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &k1), 0); |