mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
tests: Add a testing of importing ecdsa pubkeys.
This commit is contained in:
@@ -397,6 +397,43 @@ static void torture_pki_publickey_dsa_base64(void **state)
|
|||||||
ssh_key_free(key);
|
ssh_key_free(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void torture_pki_publickey_ecdsa_base64(void **state)
|
||||||
|
{
|
||||||
|
enum ssh_keytypes_e type;
|
||||||
|
char *b64_key, *key_buf, *p;
|
||||||
|
const char *q;
|
||||||
|
ssh_key key;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
(void) state; /* unused */
|
||||||
|
|
||||||
|
key_buf = read_file(LIBSSH_ECDSA_TESTKEY ".pub");
|
||||||
|
assert_true(key_buf != NULL);
|
||||||
|
|
||||||
|
q = p = key_buf;
|
||||||
|
while (*p != ' ') p++;
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
type = ssh_key_type_from_name(q);
|
||||||
|
assert_true(type == SSH_KEYTYPE_ECDSA);
|
||||||
|
|
||||||
|
q = ++p;
|
||||||
|
while (*p != ' ') p++;
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
rc = ssh_pki_import_pubkey_base64(q, type, &key);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
assert_string_equal(q, b64_key);
|
||||||
|
|
||||||
|
free(b64_key);
|
||||||
|
free(key_buf);
|
||||||
|
ssh_key_free(key);
|
||||||
|
}
|
||||||
|
|
||||||
static void torture_pki_publickey_rsa_base64(void **state)
|
static void torture_pki_publickey_rsa_base64(void **state)
|
||||||
{
|
{
|
||||||
enum ssh_keytypes_e type;
|
enum ssh_keytypes_e type;
|
||||||
@@ -778,6 +815,9 @@ int torture_run_tests(void) {
|
|||||||
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
|
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||||
|
setup_ecdsa_key,
|
||||||
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
|
unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
|
|||||||
Reference in New Issue
Block a user