From c8d0b724b3bdf5c13503c81df060dd7d2e8031f7 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Wed, 21 Jan 2015 14:59:09 +0100 Subject: tests: Add ed25519 encrypted keys export Signed-off-by: Aris Adamantiadis Reviewed-by: Andreas Schneider --- tests/unittests/torture_pki.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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); } -- cgit v1.2.3