aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-11-27 20:08:54 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-11-27 22:54:13 +0100
commit7933aef747d6498c99788acfddb9bb37f83b09bc (patch)
tree80414d13b9ca1ddad74d075396551c60541e647f /tests/unittests
parent136efd6ed571bcc8c8ad18ac2bed203eb8a9d8bc (diff)
downloadlibssh-7933aef747d6498c99788acfddb9bb37f83b09bc.tar.gz
libssh-7933aef747d6498c99788acfddb9bb37f83b09bc.tar.xz
libssh-7933aef747d6498c99788acfddb9bb37f83b09bc.zip
tests: Add torture_pki_write_privkey_rsa 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 7324177e..90f614ce 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -946,6 +946,43 @@ static void torture_pki_generate_key_ecdsa(void **state)
}
#endif
+static void torture_pki_write_privkey_rsa(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_RSA_TESTKEY,
+ NULL,
+ NULL,
+ NULL,
+ &origkey);
+ assert_true(rc == 0);
+
+ unlink(LIBSSH_RSA_TESTKEY);
+
+ rc = ssh_pki_export_privkey_file(origkey,
+ "",
+ NULL,
+ NULL,
+ LIBSSH_RSA_TESTKEY);
+ assert_true(rc == 0);
+
+ rc = ssh_pki_import_privkey_file(LIBSSH_RSA_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[] = {
@@ -1028,6 +1065,9 @@ int torture_run_tests(void) {
#ifdef HAVE_ECC
unit_test(torture_pki_generate_key_ecdsa),
#endif
+ unit_test_setup_teardown(torture_pki_write_privkey_rsa,
+ setup_rsa_key,
+ teardown),
};
(void)setup_both_keys;