aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/torture_pki.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2015-01-21 14:59:09 +0100
committerAndreas Schneider <asn@cryptomilk.org>2015-02-02 14:45:52 +0100
commitc8d0b724b3bdf5c13503c81df060dd7d2e8031f7 (patch)
tree54676d2f442f6d966c9bcdb9150a2799c5d6e130 /tests/unittests/torture_pki.c
parent9e4700cdc0a97d395b2be2ac573acab236ba1edf (diff)
downloadlibssh-c8d0b724b3bdf5c13503c81df060dd7d2e8031f7.tar.gz
libssh-c8d0b724b3bdf5c13503c81df060dd7d2e8031f7.tar.xz
libssh-c8d0b724b3bdf5c13503c81df060dd7d2e8031f7.zip
tests: Add ed25519 encrypted keys export
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/unittests/torture_pki.c')
-rw-r--r--tests/unittests/torture_pki.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index a99f2084..01cf79db 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -1366,6 +1366,35 @@ static void torture_pki_write_privkey_ed25519(void **state){
rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE);
assert_true(rc == 0);
+ unlink(LIBSSH_ED25519_TESTKEY);
+ ssh_key_free(privkey);
+ /* do the same with passphrase */
+ rc = ssh_pki_export_privkey_file(origkey,
+ torture_get_testkey_passphrase(),
+ NULL,
+ NULL,
+ LIBSSH_ED25519_TESTKEY);
+ assert_true(rc == 0);
+
+ rc = ssh_pki_import_privkey_file(LIBSSH_ED25519_TESTKEY,
+ NULL,
+ NULL,
+ NULL,
+ &privkey);
+ /* opening without passphrase should fail */
+ assert_true(rc == SSH_ERROR);
+
+ rc = ssh_pki_import_privkey_file(LIBSSH_ED25519_TESTKEY,
+ torture_get_testkey_passphrase(),
+ NULL,
+ NULL,
+ &privkey);
+ assert_true(rc == 0);
+
+ rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE);
+ assert_true(rc == 0);
+ unlink(LIBSSH_ED25519_TESTKEY);
+
ssh_key_free(origkey);
ssh_key_free(privkey);
}