aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/torture_pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-11-27 20:09:38 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-11-27 22:54:13 +0100
commit004240af486768927a16742c457f69217f39077f (patch)
tree48ba1d51faeaa471054c4d1e92dcdfe1d3e22803 /tests/unittests/torture_pki.c
parent4e3d16e2919f213bf65c8ebb7a113f4f5b08a2a4 (diff)
downloadlibssh-004240af486768927a16742c457f69217f39077f.tar.gz
libssh-004240af486768927a16742c457f69217f39077f.tar.xz
libssh-004240af486768927a16742c457f69217f39077f.zip
tests: Add torture_pki_write_privkey_ecdsa test.
Diffstat (limited to 'tests/unittests/torture_pki.c')
-rw-r--r--tests/unittests/torture_pki.c44
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;