mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 10:26:47 +09:00
tests: Verify the keys loaded from new OpenSSH format
This runs the same test that are ran on the legacy PEM files also with the new OpenSSH key files. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
39102224b2
commit
eaaa4131de
@@ -26,7 +26,30 @@ static int setup_ecdsa_key(void **state, int ecdsa_bits)
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY,
|
||||
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0));
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY_PASSPHRASE,
|
||||
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0));
|
||||
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 1));
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY ".pub",
|
||||
torture_get_testkey_pub(SSH_KEYTYPE_ECDSA, ecdsa_bits));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_openssh_ecdsa_key(void **state, int ecdsa_bits)
|
||||
{
|
||||
const char *keystring = NULL;
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
unlink(LIBSSH_ECDSA_TESTKEY);
|
||||
unlink(LIBSSH_ECDSA_TESTKEY_PASSPHRASE);
|
||||
unlink(LIBSSH_ECDSA_TESTKEY ".pub");
|
||||
|
||||
keystring = torture_get_openssh_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0);
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY,
|
||||
keystring);
|
||||
|
||||
keystring = torture_get_openssh_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 1);
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY_PASSPHRASE,
|
||||
keystring);
|
||||
torture_write_file(LIBSSH_ECDSA_TESTKEY ".pub",
|
||||
torture_get_testkey_pub(SSH_KEYTYPE_ECDSA, ecdsa_bits));
|
||||
|
||||
@@ -54,6 +77,27 @@ static int setup_ecdsa_key_256(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_openssh_ecdsa_key_521(void **state)
|
||||
{
|
||||
setup_openssh_ecdsa_key(state, 521);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_openssh_ecdsa_key_384(void **state)
|
||||
{
|
||||
setup_openssh_ecdsa_key(state, 384);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_openssh_ecdsa_key_256(void **state)
|
||||
{
|
||||
setup_openssh_ecdsa_key(state, 256);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int teardown(void **state)
|
||||
{
|
||||
(void) state; /* unused */
|
||||
@@ -461,6 +505,15 @@ int torture_run_tests(void) {
|
||||
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_import_privkey_base64,
|
||||
setup_ecdsa_key_521,
|
||||
teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_import_privkey_base64,
|
||||
setup_openssh_ecdsa_key_256,
|
||||
teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_import_privkey_base64,
|
||||
setup_openssh_ecdsa_key_384,
|
||||
teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_import_privkey_base64,
|
||||
setup_openssh_ecdsa_key_521,
|
||||
teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_publickey_from_privatekey,
|
||||
setup_ecdsa_key_256,
|
||||
teardown),
|
||||
|
||||
Reference in New Issue
Block a user