aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-11-27 20:09:27 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-11-27 22:54:13 +0100
commit4e3d16e2919f213bf65c8ebb7a113f4f5b08a2a4 (patch)
treecd313a275827a0f48d23dc1ca463904b9d55444b /tests/unittests
parent7933aef747d6498c99788acfddb9bb37f83b09bc (diff)
downloadlibssh-4e3d16e2919f213bf65c8ebb7a113f4f5b08a2a4.tar.gz
libssh-4e3d16e2919f213bf65c8ebb7a113f4f5b08a2a4.tar.xz
libssh-4e3d16e2919f213bf65c8ebb7a113f4f5b08a2a4.zip
tests: Add torture_pki_write_privkey_dsa test.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/torture_pki.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 90f614ce..04fdcdcf 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -983,6 +983,43 @@ static void torture_pki_write_privkey_rsa(void **state)
assert_true(rc == 0);
}
+static void torture_pki_write_privkey_dsa(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_DSA_TESTKEY,
+ NULL,
+ NULL,
+ NULL,
+ &origkey);
+ assert_true(rc == 0);
+
+ unlink(LIBSSH_DSA_TESTKEY);
+
+ rc = ssh_pki_export_privkey_file(origkey,
+ "",
+ NULL,
+ NULL,
+ LIBSSH_DSA_TESTKEY);
+ assert_true(rc == 0);
+
+ rc = ssh_pki_import_privkey_file(LIBSSH_DSA_TESTKEY,
+ NULL,
+ NULL,
+ NULL,
+ &privkey);
+ assert_true(rc == 0);
+
+ rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE);
+ assert_true(rc == 0);
+}
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
@@ -1068,6 +1105,9 @@ int torture_run_tests(void) {
unit_test_setup_teardown(torture_pki_write_privkey_rsa,
setup_rsa_key,
teardown),
+ unit_test_setup_teardown(torture_pki_write_privkey_dsa,
+ setup_dsa_key,
+ teardown),
};
(void)setup_both_keys;