mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 03:00:26 +09:00
tests: Add ed25519 OpenSSH key saving
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
46bc11f977
commit
4f5660e081
@@ -1313,6 +1313,45 @@ static void torture_pki_write_privkey_ecdsa(void **state)
|
|||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_LIBCRYPTO */
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
|
|
||||||
|
static void torture_pki_write_privkey_ed25519(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_ED25519_TESTKEY,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&origkey);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
unlink(LIBSSH_ED25519_TESTKEY);
|
||||||
|
|
||||||
|
rc = ssh_pki_export_privkey_file(origkey,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
LIBSSH_ED25519_TESTKEY);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
rc = ssh_pki_import_privkey_file(LIBSSH_ED25519_TESTKEY,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&privkey);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
ssh_key_free(origkey);
|
||||||
|
ssh_key_free(privkey);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
static void torture_pki_ecdsa_name(void **state, const char *expected_name)
|
static void torture_pki_ecdsa_name(void **state, const char *expected_name)
|
||||||
{
|
{
|
||||||
@@ -1501,6 +1540,10 @@ int torture_run_tests(void) {
|
|||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_LIBCRYPTO */
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
|
unit_test_setup_teardown(torture_pki_write_privkey_ed25519,
|
||||||
|
setup_dsa_key,
|
||||||
|
teardown),
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_name256,
|
unit_test_setup_teardown(torture_pki_ecdsa_name256,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
|
|||||||
Reference in New Issue
Block a user