diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-11-27 20:09:38 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-11-27 22:54:40 +0100 |
commit | 91edc0ee217aa3e6735c5b8c7415b641c1969e2d (patch) | |
tree | 1a2df19254f7c296ca1da0a2e9a200cf7cc4a6c5 /tests | |
parent | 46bda45d9507628c92f2bf6f1f710415a43ff3ed (diff) | |
download | libssh-91edc0ee217aa3e6735c5b8c7415b641c1969e2d.tar.gz libssh-91edc0ee217aa3e6735c5b8c7415b641c1969e2d.tar.xz libssh-91edc0ee217aa3e6735c5b8c7415b641c1969e2d.zip |
tests: Add torture_pki_write_privkey_ecdsa test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/torture_pki.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c index 04fdcdcf..6edbe4c0 100644 --- a/tests/unittests/torture_pki.c +++ b/tests/unittests/torture_pki.c @@ -1020,6 +1020,45 @@ static void torture_pki_write_privkey_dsa(void **state) assert_true(rc == 0); } +#ifdef HAVE_ECC +static void torture_pki_write_privkey_ecdsa(void **state) +{ + ssh_key origkey; + ssh_key privkey; + int rc; + + (void) state; /* unused */ + + ssh_set_log_level(5); + + rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY, + NULL, + NULL, + NULL, + &origkey); + assert_true(rc == 0); + + unlink(LIBSSH_ECDSA_TESTKEY); + + rc = ssh_pki_export_privkey_file(origkey, + "", + NULL, + NULL, + LIBSSH_ECDSA_TESTKEY); + assert_true(rc == 0); + + rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY, + NULL, + NULL, + NULL, + &privkey); + assert_true(rc == 0); + + rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); + assert_true(rc == 0); +} +#endif + int torture_run_tests(void) { int rc; const UnitTest tests[] = { @@ -1108,6 +1147,11 @@ int torture_run_tests(void) { unit_test_setup_teardown(torture_pki_write_privkey_dsa, setup_dsa_key, teardown), +#ifdef HAVE_ECC + unit_test_setup_teardown(torture_pki_write_privkey_ecdsa, + setup_ecdsa_key, + teardown), +#endif }; (void)setup_both_keys; |